|
| 1 | +import 'package:powersync_core/src/sync/options.dart'; |
| 2 | +import 'package:test/test.dart'; |
| 3 | + |
| 4 | +void main() { |
| 5 | + group('sync options', () { |
| 6 | + test('can merge with changes', () { |
| 7 | + final a = ResolvedSyncOptions(SyncOptions( |
| 8 | + params: {'client': 'a'}, |
| 9 | + crudThrottleTime: const Duration(seconds: 1), |
| 10 | + )); |
| 11 | + |
| 12 | + final (b, didChange) = a.applyFrom(SyncOptions( |
| 13 | + params: {'client': 'a'}, |
| 14 | + retryDelay: const Duration(seconds: 1), |
| 15 | + )); |
| 16 | + |
| 17 | + expect(b.params, {'client': 'a'}); |
| 18 | + expect(b.crudThrottleTime, const Duration(seconds: 1)); |
| 19 | + expect(b.retryDelay, const Duration(seconds: 1)); |
| 20 | + expect(didChange, isTrue); |
| 21 | + }); |
| 22 | + |
| 23 | + test('can merge without changes', () { |
| 24 | + final a = ResolvedSyncOptions(SyncOptions( |
| 25 | + params: {'client': 'a'}, |
| 26 | + crudThrottleTime: const Duration(seconds: 1), |
| 27 | + )); |
| 28 | + |
| 29 | + final (_, didChange) = a.applyFrom(SyncOptions( |
| 30 | + // This is the default, so no change from a |
| 31 | + retryDelay: const Duration(seconds: 5), |
| 32 | + )); |
| 33 | + |
| 34 | + expect(didChange, isFalse); |
| 35 | + }); |
| 36 | + }); |
| 37 | +} |
0 commit comments