39 lines
1.1 KiB
Dart
39 lines
1.1 KiB
Dart
|
|
import 'package:bible_tracker/models/tracker.dart';
|
||
|
|
import 'package:flutter_test/flutter_test.dart';
|
||
|
|
|
||
|
|
void main() {
|
||
|
|
group('Tracker', () {
|
||
|
|
test('JSON round-trips including read chapters', () {
|
||
|
|
final original = Tracker(
|
||
|
|
id: 'abc',
|
||
|
|
name: 'My Plan',
|
||
|
|
colorValue: 0xFF3F51B5,
|
||
|
|
startDate: DateTime.utc(2024, 1, 2, 3, 4, 5),
|
||
|
|
readChapters: const <String>{'0:1', '0:2', '65:22'},
|
||
|
|
);
|
||
|
|
|
||
|
|
final Map<String, dynamic> json = original.toJson();
|
||
|
|
final Tracker decoded = Tracker.fromJson(json);
|
||
|
|
|
||
|
|
expect(decoded, original);
|
||
|
|
});
|
||
|
|
|
||
|
|
test('copyWith replaces a subset of fields', () {
|
||
|
|
final original = Tracker(
|
||
|
|
id: 'abc',
|
||
|
|
name: 'Old',
|
||
|
|
colorValue: 0xFF000000,
|
||
|
|
startDate: DateTime(2024, 1, 1),
|
||
|
|
);
|
||
|
|
final Tracker updated = original.copyWith(
|
||
|
|
name: 'New',
|
||
|
|
readChapters: const <String>{'0:1'},
|
||
|
|
);
|
||
|
|
expect(updated.id, 'abc');
|
||
|
|
expect(updated.name, 'New');
|
||
|
|
expect(updated.colorValue, 0xFF000000);
|
||
|
|
expect(updated.readChapters, const <String>{'0:1'});
|
||
|
|
});
|
||
|
|
});
|
||
|
|
}
|