|
1 | | -// ignore_for_file: prefer_const_constructors |
2 | | -import 'package:ht_kv_storage_service/src/storage_keys.dart'; |
| 1 | +// ignore_for_file: lines_longer_than_80_chars |
| 2 | + |
| 3 | +import 'package:ht_kv_storage_service/ht_kv_storage_service.dart'; |
3 | 4 | import 'package:test/test.dart'; |
4 | 5 |
|
5 | 6 | void main() { |
6 | | - group('StorageKeys', () { |
7 | | - test('constants have correct values', () { |
8 | | - expect(StorageKeys.pendingSignInEmail, equals('pending_signin_email')); |
9 | | - expect(StorageKeys.hasSeenOnboarding, equals('has_seen_onboarding')); |
| 7 | + group('StorageKey Enum', () { |
| 8 | + test('stringValue getter returns correct values', () { |
| 9 | + // Check the stringValue getter for each enum member |
| 10 | + expect( |
| 11 | + StorageKey.pendingSignInEmail.stringValue, |
| 12 | + equals('pending_signin_email'), |
| 13 | + ); |
| 14 | + expect( |
| 15 | + StorageKey.hasSeenOnboarding.stringValue, |
| 16 | + equals('has_seen_onboarding'), |
| 17 | + ); |
10 | 18 | }); |
11 | 19 |
|
12 | | - // Since the constructor is private, we cannot test instantiation directly, |
13 | | - // which is the intended behavior. |
| 20 | + // Test that all enum values are covered in the stringValue getter's switch statement. |
| 21 | + // This helps prevent forgetting to update the getter when adding new keys. |
| 22 | + test('stringValue getter covers all enum values', () { |
| 23 | + for (final key in StorageKey.values) { |
| 24 | + // Expecting the getter not to throw an error is a basic check that |
| 25 | + // the switch statement handles all cases. |
| 26 | + expect(() => key.stringValue, returnsNormally); |
| 27 | + } |
| 28 | + }); |
14 | 29 | }); |
15 | 30 | } |
0 commit comments