Browse Source

test(neon): add some AppStorage and AppImplementation tests

Signed-off-by: Nikolas Rimikis <rimikis.nikolas@gmail.com>
pull/654/head
Nikolas Rimikis 1 year ago
parent
commit
5c0b2cbc7e
No known key found for this signature in database
GPG Key ID: 85ED1DE9786A4FF2
  1. 30
      packages/neon/neon/test/app_implementation_test.dart
  2. 14
      packages/neon/neon/test/storage_test.dart

30
packages/neon/neon/test/app_implementation_test.dart

@ -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));
});
});
}

14
packages/neon/neon/test/storage_test.dart

@ -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…
Cancel
Save