init
This commit is contained in:
@@ -0,0 +1,60 @@
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:kickkings_support/models/account.dart';
|
||||
|
||||
void main() {
|
||||
test('admins can read and write support', () {
|
||||
const account = Account(
|
||||
id: '1',
|
||||
username: 'ada',
|
||||
isAdmin: true,
|
||||
permissions: {},
|
||||
);
|
||||
|
||||
expect(account.canReadSupport, isTrue);
|
||||
expect(account.canWriteSupport, isTrue);
|
||||
});
|
||||
|
||||
test('support read does not grant write', () {
|
||||
final account = Account.fromJson({
|
||||
'id': '1',
|
||||
'username': 'ada',
|
||||
'isAdmin': false,
|
||||
'permissions': {
|
||||
'support': {'read': true, 'write': false},
|
||||
},
|
||||
});
|
||||
|
||||
expect(account.canReadSupport, isTrue);
|
||||
expect(account.canWriteSupport, isFalse);
|
||||
});
|
||||
|
||||
test('missing support permission cannot enter the inbox', () {
|
||||
final account = Account.fromJson({
|
||||
'id': '1',
|
||||
'username': 'ada',
|
||||
'isAdmin': false,
|
||||
'permissions': {
|
||||
'players': {'read': true},
|
||||
},
|
||||
});
|
||||
|
||||
expect(account.canReadSupport, isFalse);
|
||||
expect(account.canWriteSupport, isFalse);
|
||||
});
|
||||
|
||||
test('account json round trip keeps support flags', () {
|
||||
final account = Account.fromJson({
|
||||
'id': 'acct',
|
||||
'username': 'ada',
|
||||
'isAdmin': false,
|
||||
'permissions': {
|
||||
'support': {'read': true, 'write': true},
|
||||
},
|
||||
});
|
||||
|
||||
final restored = Account.fromJson(account.toJson());
|
||||
expect(restored.canReadSupport, isTrue);
|
||||
expect(restored.canWriteSupport, isTrue);
|
||||
expect(restored.username, 'ada');
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user