29 lines
1.0 KiB
Dart
29 lines
1.0 KiB
Dart
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:marianum_mobile/access/user_role.dart';
|
|
import 'package:marianum_mobile/state/app/modules/capabilities/bloc/capabilities_state.dart';
|
|
|
|
void main() {
|
|
test('parses the server wire values', () {
|
|
expect(UserRole.parse('STUDENT'), UserRole.student);
|
|
expect(UserRole.parse('TEACHER'), UserRole.teacher);
|
|
expect(UserRole.parse('STAFF'), UserRole.staff);
|
|
expect(UserRole.parse('PARENT'), UserRole.parent);
|
|
});
|
|
|
|
test('missing or unknown values are unknown, never an error', () {
|
|
expect(UserRole.parse(null), UserRole.unknown);
|
|
expect(UserRole.parse('ALUMNUS'), UserRole.unknown);
|
|
});
|
|
|
|
test('hydrated capability states from older versions stay readable', () {
|
|
final state = CapabilitiesState.fromJson({
|
|
'viewForeignTimetables': true,
|
|
'pushNotifications': true,
|
|
'userType': 'TEACHER',
|
|
'loaded': true,
|
|
});
|
|
expect(state.role, UserRole.teacher);
|
|
expect(CapabilitiesState.fromJson({}).role, UserRole.unknown);
|
|
});
|
|
}
|