Nikolas Rimikis
1 year ago
committed by
GitHub
20 changed files with 156 additions and 113 deletions
@ -0,0 +1,30 @@
|
||||
import 'package:mocktail/mocktail.dart'; |
||||
import 'package:neon/src/models/app_implementation.dart'; |
||||
import 'package:test/test.dart'; |
||||
|
||||
// ignore: missing_override_of_must_be_overridden |
||||
class AppImplementationMock extends Mock implements AppImplementation {} |
||||
|
||||
void main() { |
||||
group('group name', () { |
||||
test('AccountFind', () { |
||||
final app1 = AppImplementationMock(); |
||||
final app2 = AppImplementationMock(); |
||||
|
||||
final apps = { |
||||
app1, |
||||
app2, |
||||
}; |
||||
|
||||
when(() => app1.id).thenReturn('app1'); |
||||
when(() => app2.id).thenReturn('app2'); |
||||
|
||||
expect(apps.tryFind(null), isNull); |
||||
expect(apps.tryFind('invalidID'), isNull); |
||||
expect(apps.tryFind(app2.id), equals(app2)); |
||||
|
||||
expect(() => apps.find('invalidID'), throwsA(isA<StateError>())); |
||||
expect(apps.find(app2.id), equals(app2)); |
||||
}); |
||||
}); |
||||
} |
@ -0,0 +1,14 @@
|
||||
import 'package:neon/src/settings/models/storage.dart'; |
||||
import 'package:shared_preferences/shared_preferences.dart'; |
||||
import 'package:test/test.dart'; |
||||
|
||||
void main() { |
||||
test('AppStorage', () async { |
||||
expect(() => AppStorage.reqireDatabase, throwsA(isA<StateError>())); |
||||
|
||||
SharedPreferences.setMockInitialValues({}); |
||||
await AppStorage.init(); |
||||
|
||||
expect(AppStorage.reqireDatabase, isA<SharedPreferences>()); |
||||
}); |
||||
} |
Loading…
Reference in new issue