From 5c0b2cbc7ec6ba54a3f8ae4e579a06083890a5c1 Mon Sep 17 00:00:00 2001 From: Nikolas Rimikis Date: Tue, 29 Aug 2023 08:33:51 +0200 Subject: [PATCH] test(neon): add some AppStorage and AppImplementation tests Signed-off-by: Nikolas Rimikis --- .../neon/test/app_implementation_test.dart | 30 +++++++++++++++++++ packages/neon/neon/test/storage_test.dart | 14 +++++++++ 2 files changed, 44 insertions(+) create mode 100644 packages/neon/neon/test/app_implementation_test.dart create mode 100644 packages/neon/neon/test/storage_test.dart diff --git a/packages/neon/neon/test/app_implementation_test.dart b/packages/neon/neon/test/app_implementation_test.dart new file mode 100644 index 00000000..4747ac76 --- /dev/null +++ b/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())); + expect(apps.find(app2.id), equals(app2)); + }); + }); +} diff --git a/packages/neon/neon/test/storage_test.dart b/packages/neon/neon/test/storage_test.dart new file mode 100644 index 00000000..bda8df24 --- /dev/null +++ b/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())); + + SharedPreferences.setMockInitialValues({}); + await AppStorage.init(); + + expect(AppStorage.reqireDatabase, isA()); + }); +}