diff --git a/test/models/chart_test.dart b/test/models/chart_test.dart new file mode 100644 index 0000000..3a23162 --- /dev/null +++ b/test/models/chart_test.dart @@ -0,0 +1,30 @@ +import 'package:flutter_test/flutter_test.dart'; +import 'package:taskwarrior/app/models/chart.dart'; + +void main() { + group('ChartData', () { + test('should create an instance with correct values', () { + final chartData = ChartData('2024-12-12', 100, 200); + + expect(chartData.x, '2024-12-12'); + expect(chartData.y1, 100); + expect(chartData.y2, 200); + }); + + test('should handle null or empty values correctly', () { + final chartData = ChartData('', 0, 0); + + expect(chartData.x, ''); + expect(chartData.y1, 0); + expect(chartData.y2, 0); + }); + + test('should handle negative values correctly', () { + final chartData = ChartData('2024-12-12', -100, -200); + + expect(chartData.x, '2024-12-12'); + expect(chartData.y1, -100); + expect(chartData.y2, -200); + }); + }); +} diff --git a/test/models/data_test.dart b/test/models/data_test.dart new file mode 100644 index 0000000..567b016 --- /dev/null +++ b/test/models/data_test.dart @@ -0,0 +1,103 @@ +import 'package:flutter_test/flutter_test.dart'; +import 'package:mockito/mockito.dart'; +import 'package:taskwarrior/app/models/data.dart'; +import 'package:taskwarrior/app/models/json/task.dart'; +import 'package:taskwarrior/app/services/notification_services.dart'; +import 'package:flutter/widgets.dart'; +import 'dart:io'; + +class MockNotificationService extends Mock implements NotificationService {} + +void main() { + TestWidgetsFlutterBinding.ensureInitialized(); + + group('Data', () { + late Data data; + late Directory home; + late MockNotificationService mockNotificationService; + + setUp(() { + WidgetsFlutterBinding.ensureInitialized(); + home = Directory.systemTemp.createTempSync(); + data = Data(home); + mockNotificationService = MockNotificationService(); + + when(mockNotificationService.initiliazeNotification()) + .thenAnswer((_) async {}); + }); + + test('should update tasks with status "waiting" or "until" correctly', + () async { + final task1 = Task((b) => b + ..uuid = '1' + ..status = 'pending' + ..wait = DateTime.now().toUtc().subtract(const Duration(days: 1)) + ..description = 'Test Task' + ..entry = DateTime.now().toUtc()); + final task2 = Task((b) => b + ..uuid = '2' + ..status = 'deleted' + ..until = DateTime.now().toUtc().subtract(const Duration(days: 1)) + ..description = 'Test Task' + ..entry = DateTime.now().toUtc()); + + final updatedTasks = data.pendingData(); + expect( + updatedTasks.any( + (task) => task.uuid == task1.uuid && task.status == task1.status), + isFalse); + expect( + updatedTasks.any( + (task) => task.uuid == task2.uuid && task.status == task2.status), + isFalse); + }); + + test('should correctly return pending data', () { + final task = Task((b) => b + ..uuid = '1' + ..status = 'pending' + ..description = 'Test Task' + ..entry = DateTime.now().toUtc()); + + data.updateWaitOrUntil([task]); + final tasks = data.pendingData(); + expect(tasks.any((t) => t.uuid == '1' && t.description == 'Test Task'), + isFalse); + }); + + test('should correctly return completed data', () { + final task = Task((b) => b + ..uuid = '1' + ..status = 'completed' + ..description = 'Test Task' + ..entry = DateTime.now().toUtc()); + + data.updateWaitOrUntil([task]); + final tasks = data.completedData(); + expect(tasks.any((t) => t.uuid == '1' && t.description == 'Test Task'), + isFalse); + }); + + test('should correctly return waiting data', () { + final task = Task((b) => b + ..uuid = '1' + ..status = 'waiting' + ..description = 'Test Task' + ..entry = DateTime.now().toUtc()); + + data.updateWaitOrUntil([task]); + final tasks = data.waitingData(); + expect(tasks.any((t) => t.uuid == '1' && t.description == 'Test Task'), + isFalse); + }); + + test('should correctly export data', () { + final exportedData = data.export(); + expect(exportedData, isNotNull); + }); + + tearDown(() { + home.deleteSync(recursive: true); + }); + }); +} diff --git a/test/models/filters_test.dart b/test/models/filters_test.dart new file mode 100644 index 0000000..8d57734 --- /dev/null +++ b/test/models/filters_test.dart @@ -0,0 +1,104 @@ +import 'package:flutter_test/flutter_test.dart'; +import 'package:taskwarrior/app/models/filters.dart'; +import 'package:taskwarrior/app/services/tag_filter.dart'; + +void main() { + group('Filters', () { + late Filters filters; + late bool pendingFilter; + late bool waitingFilter; + late String projectFilter; + late bool tagUnion; + late Map tags; + + setUp(() { + pendingFilter = false; + waitingFilter = false; + projectFilter = 'TestProject'; + tagUnion = false; + tags = { + 'tag1': const TagFilterMetadata(display: 'Tag 1', selected: false), + 'tag2': const TagFilterMetadata(display: 'Tag 2', selected: true), + }; + + filters = Filters( + pendingFilter: pendingFilter, + waitingFilter: waitingFilter, + togglePendingFilter: () { + pendingFilter = !pendingFilter; + }, + toggleWaitingFilter: () { + waitingFilter = !waitingFilter; + }, + tagFilters: TagFilters( + tagUnion: tagUnion, + toggleTagUnion: () { + tagUnion = !tagUnion; + }, + tags: tags, + toggleTagFilter: (String tag) { + tags[tag] = TagFilterMetadata( + display: tags[tag]!.display, + selected: !tags[tag]!.selected, + ); + }, + ), + projects: [], + projectFilter: projectFilter, + toggleProjectFilter: (String project) { + projectFilter = project; + }, + ); + }); + + test('should correctly initialize with given parameters', () { + expect(filters.pendingFilter, pendingFilter); + expect(filters.waitingFilter, waitingFilter); + expect(filters.projectFilter, projectFilter); + expect(filters.tagFilters.tagUnion, tagUnion); + expect(filters.tagFilters.tags, tags); + }); + + test('should correctly toggle pending filter', () { + filters.togglePendingFilter(); + expect(pendingFilter, isTrue); + + filters.togglePendingFilter(); + expect(pendingFilter, isFalse); + }); + + test('should correctly toggle waiting filter', () { + filters.toggleWaitingFilter(); + expect(waitingFilter, isTrue); + + filters.toggleWaitingFilter(); + expect(waitingFilter, isFalse); + }); + + test('should correctly toggle project filter', () { + const newProject = 'NewProject'; + filters.toggleProjectFilter(newProject); + expect(projectFilter, newProject); + + const anotherProject = 'AnotherProject'; + filters.toggleProjectFilter(anotherProject); + expect(projectFilter, anotherProject); + }); + + test('should correctly toggle tag union', () { + filters.tagFilters.toggleTagUnion(); + expect(tagUnion, isTrue); + + filters.tagFilters.toggleTagUnion(); + expect(tagUnion, isFalse); + }); + + test('should correctly toggle tag filter', () { + filters.tagFilters.toggleTagFilter('tag1'); + expect(tags['tag1']!.selected, isTrue); + + filters.tagFilters.toggleTagFilter('tag1'); + expect(tags['tag1']!.selected, isFalse); + }); + }); +} diff --git a/test/models/json/annotation_test.dart b/test/models/json/annotation_test.dart new file mode 100644 index 0000000..6d2ee94 --- /dev/null +++ b/test/models/json/annotation_test.dart @@ -0,0 +1,44 @@ +// test/annotation_test.dart + +import 'package:flutter_test/flutter_test.dart'; +import 'package:intl/intl.dart'; +import 'package:taskwarrior/app/models/json/annotation.dart'; + +void main() { + group('Annotation', () { + late Annotation annotation; + late DateTime entry; + late String description; + + setUp(() { + entry = DateTime.now().toUtc(); // Ensure the DateTime is in UTC + description = 'Test description'; + + annotation = Annotation((b) => b + ..entry = entry + ..description = description); + }); + + test('should correctly initialize with given parameters', () { + expect(annotation.entry, entry); + expect(annotation.description, description); + }); + + test('should correctly convert to JSON', () { + final json = annotation.toJson(); + expect(DateFormat("yyyyMMdd'T'HH").format(DateTime.parse(json['entry'])), + DateFormat("yyyyMMdd'T'HH").format(entry)); + expect(json['description'], description); + }); + + test('should correctly create from JSON', () { + final json = { + 'entry': entry.toIso8601String(), + 'description': description, + }; + final newAnnotation = Annotation.fromJson(json); + expect(newAnnotation.entry, entry); + expect(newAnnotation.description, description); + }); + }); +} diff --git a/test/models/json/iso_8601_basic_test.dart b/test/models/json/iso_8601_basic_test.dart new file mode 100644 index 0000000..07d05f9 --- /dev/null +++ b/test/models/json/iso_8601_basic_test.dart @@ -0,0 +1,30 @@ +import 'package:flutter_test/flutter_test.dart'; +import 'package:intl/intl.dart'; +import 'package:taskwarrior/app/models/json/iso_8601_basic.dart'; +import 'package:taskwarrior/app/models/json/serializers.dart'; + +void main() { + group('Iso8601BasicDateTimeSerializer', () { + late Iso8601BasicDateTimeSerializer serializer; + late DateTime dateTime; + late DateFormat dateFormat; + + setUp(() { + serializer = Iso8601BasicDateTimeSerializer(); + dateTime = DateTime.utc(2024, 12, 12, 13, 30, 40, 495); + dateFormat = DateFormat('yMMddTHHmmss\'Z\''); + }); + + test('should throw ArgumentError if dateTime is not in UTC', () { + expect( + () => serializer.serialize(serializers, dateTime.toLocal()), + throwsArgumentError, + ); + }); + + test('should correctly serialize UTC dateTime', () { + final serialized = serializer.serialize(serializers, dateTime); + expect(serialized, dateFormat.format(dateTime)); + }); + }); +} diff --git a/test/models/json/serializer_test.dart b/test/models/json/serializer_test.dart new file mode 100644 index 0000000..9b2f73f --- /dev/null +++ b/test/models/json/serializer_test.dart @@ -0,0 +1,42 @@ +import 'package:flutter_test/flutter_test.dart'; +import 'package:intl/intl.dart'; +import 'package:taskwarrior/app/models/json/serializers.dart'; +import 'package:taskwarrior/app/models/json/annotation.dart'; +import 'package:taskwarrior/app/models/json/task.dart'; + +void main() { + group('Serializers', () { + test('should correctly serialize and deserialize Annotation', () { + final annotation = Annotation((b) => b + ..entry = DateTime.now().toUtc() + ..description = 'Test description'); + + final serialized = + serializers.serializeWith(Annotation.serializer, annotation); + final deserialized = + serializers.deserializeWith(Annotation.serializer, serialized!); + + expect(DateFormat("yyyyMMdd'T'HH").format(deserialized!.entry), + DateFormat("yyyyMMdd'T'HH").format(annotation.entry)); + expect(deserialized.description, annotation.description); + }); + + test('should correctly serialize and deserialize Task', () { + final task = Task((b) => b + ..uuid = '1' + ..status = 'pending' + ..description = 'Test Task' + ..entry = DateTime.now().toUtc()); + + final serialized = serializers.serializeWith(Task.serializer, task); + final deserialized = + serializers.deserializeWith(Task.serializer, serialized!); + + expect(DateFormat("yyyyMMdd'T'HH").format(deserialized!.entry), + DateFormat("yyyyMMdd'T'HH").format(task.entry)); + expect(deserialized.uuid, task.uuid); + expect(deserialized.status, task.status); + expect(deserialized.description, task.description); + }); + }); +} diff --git a/test/models/json/task_test.dart b/test/models/json/task_test.dart new file mode 100644 index 0000000..2660b52 --- /dev/null +++ b/test/models/json/task_test.dart @@ -0,0 +1,51 @@ +import 'package:flutter_test/flutter_test.dart'; +import 'package:intl/intl.dart'; +import 'package:taskwarrior/app/models/json/task.dart'; + +void main() { + group('Task', () { + late Task task; + late DateTime entry; + late String uuid; + late String description; + + setUp(() { + entry = DateTime.now().toUtc(); + uuid = '123e4567-e89b-12d3-a456-426614174000'; + description = 'Test task'; + + task = Task((b) => b + ..entry = entry + ..uuid = uuid + ..status = 'pending' + ..description = description); + }); + + test('should correctly initialize with given parameters', () { + expect(task.entry, entry); + expect(task.uuid, uuid); + expect(task.description, description); + }); + + test('should correctly convert to JSON', () { + final json = task.toJson(); + expect(DateFormat("yyyyMMdd'T'HH").format(DateTime.parse(json['entry'])), + DateFormat("yyyyMMdd'T'HH").format(entry)); + expect(json['uuid'], uuid); + expect(json['description'], description); + }); + + test('should correctly create from JSON', () { + final json = { + 'entry': entry.toIso8601String(), + 'uuid': uuid, + 'status': 'pending', + 'description': description, + }; + final newTask = Task.fromJson(json); + expect(newTask.entry, entry); + expect(newTask.uuid, uuid); + expect(newTask.description, description); + }); + }); +} diff --git a/test/models/onboarding_model_test.dart b/test/models/onboarding_model_test.dart new file mode 100644 index 0000000..d43db08 --- /dev/null +++ b/test/models/onboarding_model_test.dart @@ -0,0 +1,25 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:taskwarrior/app/models/onboarding_model.dart'; + +void main() { + group('OnboardingModel', () { + late OnboardingModel model; + + setUp(() { + model = OnboardingModel( + title: 'Welcome', + image: 'assets/images/welcome.png', + desc: 'Welcome to the app!', + colors: Colors.blue, + ); + }); + + test('should correctly initialize with given parameters', () { + expect(model.title, 'Welcome'); + expect(model.image, 'assets/images/welcome.png'); + expect(model.desc, 'Welcome to the app!'); + expect(model.colors, Colors.blue); + }); + }); +} diff --git a/test/models/size_config_model_test.dart b/test/models/size_config_model_test.dart new file mode 100644 index 0000000..7dfcdc6 --- /dev/null +++ b/test/models/size_config_model_test.dart @@ -0,0 +1,35 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:taskwarrior/app/models/size_config_model.dart'; + +void main() { + group('SizeConfig', () { + late SizeConfig sizeConfig; + + setUp(() { + sizeConfig = SizeConfig(); + }); + + testWidgets('should initialize screen dimensions correctly', + (WidgetTester tester) async { + await tester.pumpWidget( + MaterialApp( + home: Builder( + builder: (BuildContext context) { + sizeConfig.init(context); + return Container(); + }, + ), + ), + ); + + final mediaQueryData = + MediaQuery.of(tester.element(find.byType(Container))); + + expect(sizeConfig.screenW, mediaQueryData.size.width); + expect(sizeConfig.screenH, mediaQueryData.size.height); + expect(sizeConfig.blockH, mediaQueryData.size.width / 100); + expect(sizeConfig.blockV, mediaQueryData.size.height / 100); + }); + }); +} diff --git a/test/models/storage/client_test.dart b/test/models/storage/client_test.dart new file mode 100644 index 0000000..d4bbbf2 --- /dev/null +++ b/test/models/storage/client_test.dart @@ -0,0 +1,24 @@ +import 'package:flutter_test/flutter_test.dart'; +import 'package:mockito/mockito.dart'; +import 'package:package_info_plus/package_info_plus.dart'; +import 'package:taskwarrior/app/models/storage/client.dart'; + +class MockPackageInfo extends Mock implements PackageInfo {} + +void main() { + group('client', () { + test('should return package name and version', () async { + PackageInfo.setMockInitialValues( + appName: 'App', + packageName: 'com.example.app', + version: '1.0.0', + buildNumber: '1', + buildSignature: '', + ); + + final result = await client(); + + expect(result, 'com.example.app 1.0.0'); + }); + }); +} diff --git a/test/models/storage/exceptions/bad_certificate_exception_test.dart b/test/models/storage/exceptions/bad_certificate_exception_test.dart new file mode 100644 index 0000000..ad0c4f8 --- /dev/null +++ b/test/models/storage/exceptions/bad_certificate_exception_test.dart @@ -0,0 +1,21 @@ +import 'dart:io'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:mockito/annotations.dart'; +import 'package:taskwarrior/app/models/storage/exceptions/bad_certificate_exception.dart'; +import 'bad_certificate_exception_test.mocks.dart'; + +@GenerateMocks([X509Certificate]) +void main() { + group('BadCertificateException', () { + test('should create an instance with correct properties', () { + final home = Directory('/mock/home'); + final mockCertificate = MockX509Certificate(); + + final exception = + BadCertificateException(home: home, certificate: mockCertificate); + + expect(exception.home, home); + expect(exception.certificate, mockCertificate); + }); + }); +} diff --git a/test/models/storage/exceptions/bad_certificate_exception_test.mocks.dart b/test/models/storage/exceptions/bad_certificate_exception_test.mocks.dart new file mode 100644 index 0000000..b7bf410 --- /dev/null +++ b/test/models/storage/exceptions/bad_certificate_exception_test.mocks.dart @@ -0,0 +1,99 @@ +// Mocks generated by Mockito 5.4.4 from annotations +// in taskwarrior/test/models/storage/exceptions/bad_certificate_exception_test.dart. +// Do not manually edit this file. + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:io' as _i2; +import 'dart:typed_data' as _i3; + +import 'package:mockito/mockito.dart' as _i1; +import 'package:mockito/src/dummies.dart' as _i4; + +// ignore_for_file: type=lint +// ignore_for_file: avoid_redundant_argument_values +// ignore_for_file: avoid_setters_without_getters +// ignore_for_file: comment_references +// ignore_for_file: deprecated_member_use +// ignore_for_file: deprecated_member_use_from_same_package +// ignore_for_file: implementation_imports +// ignore_for_file: invalid_use_of_visible_for_testing_member +// ignore_for_file: prefer_const_constructors +// ignore_for_file: unnecessary_parenthesis +// ignore_for_file: camel_case_types +// ignore_for_file: subtype_of_sealed_class + +class _FakeDateTime_0 extends _i1.SmartFake implements DateTime { + _FakeDateTime_0( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} + +/// A class which mocks [X509Certificate]. +/// +/// See the documentation for Mockito's code generation for more information. +class MockX509Certificate extends _i1.Mock implements _i2.X509Certificate { + MockX509Certificate() { + _i1.throwOnMissingStub(this); + } + + @override + _i3.Uint8List get der => (super.noSuchMethod( + Invocation.getter(#der), + returnValue: _i3.Uint8List(0), + ) as _i3.Uint8List); + + @override + String get pem => (super.noSuchMethod( + Invocation.getter(#pem), + returnValue: _i4.dummyValue( + this, + Invocation.getter(#pem), + ), + ) as String); + + @override + _i3.Uint8List get sha1 => (super.noSuchMethod( + Invocation.getter(#sha1), + returnValue: _i3.Uint8List(0), + ) as _i3.Uint8List); + + @override + String get subject => (super.noSuchMethod( + Invocation.getter(#subject), + returnValue: _i4.dummyValue( + this, + Invocation.getter(#subject), + ), + ) as String); + + @override + String get issuer => (super.noSuchMethod( + Invocation.getter(#issuer), + returnValue: _i4.dummyValue( + this, + Invocation.getter(#issuer), + ), + ) as String); + + @override + DateTime get startValidity => (super.noSuchMethod( + Invocation.getter(#startValidity), + returnValue: _FakeDateTime_0( + this, + Invocation.getter(#startValidity), + ), + ) as DateTime); + + @override + DateTime get endValidity => (super.noSuchMethod( + Invocation.getter(#endValidity), + returnValue: _FakeDateTime_0( + this, + Invocation.getter(#endValidity), + ), + ) as DateTime); +} diff --git a/test/models/storage/exceptions/taskserver_configuration_exception_test.dart b/test/models/storage/exceptions/taskserver_configuration_exception_test.dart new file mode 100644 index 0000000..d8eb8d1 --- /dev/null +++ b/test/models/storage/exceptions/taskserver_configuration_exception_test.dart @@ -0,0 +1,14 @@ +import 'package:flutter_test/flutter_test.dart'; +import 'package:taskwarrior/app/models/storage/exceptions/taskserver_configuration_exception.dart'; + +void main() { + group('TaskserverConfigurationException', () { + test('should create an instance with correct message', () { + const message = 'Configuration error'; + final exception = TaskserverConfigurationException(message); + + expect(exception.message, message); + expect(exception.toString(), message); + }); + }); +} diff --git a/test/models/storage/tabs_test.dart b/test/models/storage/tabs_test.dart new file mode 100644 index 0000000..baf5a20 --- /dev/null +++ b/test/models/storage/tabs_test.dart @@ -0,0 +1,66 @@ +import 'dart:io'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:taskwarrior/app/models/storage/tabs.dart'; +import 'package:uuid/uuid.dart'; + +void main() { + late Directory testProfile; + late Tabs tabs; + + setUp(() { + testProfile = Directory( + '${Directory.systemTemp.path}/test_profile_${const Uuid().v1()}'); + testProfile.createSync(); + tabs = Tabs(testProfile); + }); + + tearDown(() { + if (testProfile.existsSync()) { + testProfile.deleteSync(recursive: true); + } + }); + group("Tabs test", () { + test('Initial tab index defaults to 0', () { + expect(tabs.initialTabIndex(), 0); + }); + + test('Can set and get initial tab index', () { + tabs.setInitialTabIndex(2); + expect(tabs.initialTabIndex(), 2); + }); + + test('Can add a new tab', () { + var initialTabCount = tabs.tabUuids().length; + tabs.addTab(); + expect(tabs.tabUuids().length, initialTabCount + 1); + }); + + test('Can remove a tab', () { + var initialTabCount = tabs.tabUuids().length; + tabs.addTab(); + tabs.removeTab(0); + expect(tabs.tabUuids().length, initialTabCount); + }); + + test('Removing a tab updates the initial index', () { + tabs.addTab(); + tabs.addTab(); + tabs.setInitialTabIndex(1); + tabs.removeTab(1); + expect(tabs.initialTabIndex(), 0); + }); + + test('Can rename a tab and retrieve its alias', () { + tabs.addTab(); + var tabUuid = tabs.tabUuids().first; + tabs.renameTab(tab: tabUuid, name: 'New Tab Name'); + expect(tabs.alias(tabUuid), 'New Tab Name'); + }); + + test('Alias returns null for non-existent alias files', () { + tabs.addTab(); + var tabUuid = tabs.tabUuids().first; + expect(tabs.alias(tabUuid), isNull); + }); + }); +} diff --git a/test/models/storage_test.dart b/test/models/storage_test.dart new file mode 100644 index 0000000..d32213f --- /dev/null +++ b/test/models/storage_test.dart @@ -0,0 +1,61 @@ +import 'dart:io'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:taskwarrior/app/models/data.dart'; +import 'package:taskwarrior/app/models/storage.dart'; +import 'package:taskwarrior/app/models/storage/tabs.dart'; +import 'package:taskwarrior/app/utils/home_path/impl/gui_pem_file_paths.dart'; +import 'package:taskwarrior/app/utils/home_path/impl/home.dart'; +import 'package:taskwarrior/app/utils/home_path/impl/taskrc.dart'; +import 'package:taskwarrior/app/utils/taskfunctions/query.dart'; + +void main() { + group('Storage', () { + late Directory profile; + late Storage storage; + + setUp(() { + profile = Directory.systemTemp.createTempSync(); + storage = Storage(profile); + }); + + tearDown(() { + profile.deleteSync(recursive: true); + }); + + test('should correctly initialize with given directory', () { + expect(storage.profile, profile); + }); + + test('should correctly initialize Data with profile directory', () { + expect(storage.data, isA()); + expect(storage.profile, profile); + }); + + test('should correctly initialize GUIPemFiles with profile directory', () { + expect(storage.guiPemFiles, isA()); + expect(storage.profile, profile); + }); + + test('should correctly initialize Home with profile directory', () { + expect(storage.home, isA()); + expect(storage.home.home, profile); + expect( + storage.home.pemFilePaths?.key, storage.guiPemFiles.pemFilePaths.key); + }); + + test('should correctly initialize Query with profile directory', () { + expect(storage.query, isA()); + expect(storage.profile, profile); + }); + + test('should correctly initialize Tabs with profile directory', () { + expect(storage.tabs, isA()); + expect(storage.tabs.profile, profile); + }); + + test('should correctly initialize Taskrc with profile directory', () { + expect(storage.taskrc, isA()); + expect(storage.profile, profile); + }); + }); +} diff --git a/test/models/tag_mets_data_test.dart b/test/models/tag_mets_data_test.dart new file mode 100644 index 0000000..e688781 --- /dev/null +++ b/test/models/tag_mets_data_test.dart @@ -0,0 +1,41 @@ +import 'package:flutter_test/flutter_test.dart'; +import 'package:taskwarrior/app/models/tag_meta_data.dart'; + +void main() { + group('TagMetadata', () { + late TagMetadata tagMetadata; + late DateTime lastModified; + late int frequency; + late bool selected; + + setUp(() { + lastModified = DateTime.now(); + frequency = 5; + selected = true; + + tagMetadata = TagMetadata( + lastModified: lastModified, + frequency: frequency, + selected: selected, + ); + }); + + test('should correctly initialize with given parameters', () { + expect(tagMetadata.lastModified, lastModified); + expect(tagMetadata.frequency, frequency); + expect(tagMetadata.selected, selected); + }); + + test('should correctly convert to JSON', () { + final json = tagMetadata.toJson(); + expect(json['lastModified'], lastModified); + expect(json['frequency'], frequency); + expect(json['selected'], selected); + }); + + test('should correctly convert to string', () { + final string = tagMetadata.toString(); + expect(string, tagMetadata.toJson().toString()); + }); + }); +}