test: use setUp and tearDown

This commit is contained in:
Lukas Lihotzki 2021-06-09 17:12:14 +02:00
parent a5cbbf5cf4
commit ae2aafbd52
1 changed files with 10 additions and 21 deletions

View File

@ -36,6 +36,16 @@ void main() {
avatarUrl: 'mxc://bla', avatarUrl: 'mxc://bla',
room: Room(id: '!localpart:server.abc', client: client), room: Room(id: '!localpart:server.abc', client: client),
); );
setUp(() async {
await client.checkHomeserver('https://fakeserver.notexisting',
checkWellKnown: false);
await client.login(
identifier: AuthenticationUserIdentifier(user: 'test'),
password: '1234');
});
tearDown(() async {
await client.logout();
});
test('create', () async { test('create', () async {
expect(user1.powerLevel, 0); expect(user1.powerLevel, 0);
expect(user1.stateKey, '@alice:example.com'); expect(user1.stateKey, '@alice:example.com');
@ -86,36 +96,21 @@ void main() {
user3.calcDisplayname(mxidLocalPartFallback: false), 'Unknown user'); user3.calcDisplayname(mxidLocalPartFallback: false), 'Unknown user');
}); });
test('kick', () async { test('kick', () async {
await client.checkHomeserver('https://fakeserver.notexisting',
checkWellKnown: false);
await user1.kick(); await user1.kick();
}); });
test('ban', () async { test('ban', () async {
await client.checkHomeserver('https://fakeserver.notexisting',
checkWellKnown: false);
await user1.ban(); await user1.ban();
}); });
test('unban', () async { test('unban', () async {
await client.checkHomeserver('https://fakeserver.notexisting',
checkWellKnown: false);
await user1.unban(); await user1.unban();
}); });
test('setPower', () async { test('setPower', () async {
await client.checkHomeserver('https://fakeserver.notexisting',
checkWellKnown: false);
await user1.setPower(50); await user1.setPower(50);
}); });
test('startDirectChat', () async { test('startDirectChat', () async {
await client.checkHomeserver('https://fakeserver.notexisting',
checkWellKnown: false);
await client.login(
identifier: AuthenticationUserIdentifier(user: 'test'),
password: '1234');
await user1.startDirectChat(); await user1.startDirectChat();
}); });
test('getPresence', () async { test('getPresence', () async {
await client.checkHomeserver('https://fakeserver.notexisting',
checkWellKnown: false);
await client.handleSync(SyncUpdate.fromJson({ await client.handleSync(SyncUpdate.fromJson({
'presence': { 'presence': {
'events': [ 'events': [
@ -130,18 +125,12 @@ void main() {
expect(user1.presence.presence.presence, PresenceType.online); expect(user1.presence.presence.presence, PresenceType.online);
}); });
test('canBan', () async { test('canBan', () async {
await client.checkHomeserver('https://fakeserver.notexisting',
checkWellKnown: false);
expect(user1.canBan, false); expect(user1.canBan, false);
}); });
test('canKick', () async { test('canKick', () async {
await client.checkHomeserver('https://fakeserver.notexisting',
checkWellKnown: false);
expect(user1.canKick, false); expect(user1.canKick, false);
}); });
test('canChangePowerLevel', () async { test('canChangePowerLevel', () async {
await client.checkHomeserver('https://fakeserver.notexisting',
checkWellKnown: false);
expect(user1.canChangePowerLevel, false); expect(user1.canChangePowerLevel, false);
}); });
test('dispose client', () async { test('dispose client', () async {