Skip to content

Commit 2a91fe1

Browse files
authored
Merge pull request #404 from rohansen856/utils_test
Utils test
2 parents 77848da + badbf4a commit 2a91fe1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+3529
-0
lines changed

pubspec.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ dependencies:
6363
tutorial_coach_mark: ^1.2.11
6464
url_launcher: ^6.1.14
6565
uuid: ^4.2.2
66+
built_collection: ^5.1.1
6667

6768
dev_dependencies:
6869
build_runner: null
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import 'package:flutter_test/flutter_test.dart';
2+
import 'package:shared_preferences/shared_preferences.dart';
3+
import 'package:taskwarrior/app/utils/app_settings/app_settings.dart';
4+
import 'package:taskwarrior/app/utils/language/supported_language.dart';
5+
6+
void main() {
7+
group('AppSettings', () {
8+
setUp(() async {
9+
SharedPreferences.setMockInitialValues({});
10+
await AppSettings.init();
11+
});
12+
13+
test('should initialize settings correctly', () async {
14+
expect(AppSettings.isDarkMode, true);
15+
expect(AppSettings.selectedLanguage, SupportedLanguage.english);
16+
});
17+
18+
test('should save settings correctly', () async {
19+
await AppSettings.saveSettings(false, SupportedLanguage.english);
20+
expect(AppSettings.isDarkMode, true);
21+
expect(AppSettings.selectedLanguage, SupportedLanguage.english);
22+
});
23+
});
24+
25+
group('SelectedTheme', () {
26+
setUp(() async {
27+
SharedPreferences.setMockInitialValues({});
28+
await SelectedTheme.init();
29+
});
30+
31+
test('should save and retrieve theme mode correctly', () async {
32+
await SelectedTheme.saveMode(false);
33+
expect(SelectedTheme.getMode(), false);
34+
35+
await SelectedTheme.saveMode(true);
36+
expect(SelectedTheme.getMode(), true);
37+
});
38+
});
39+
}
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
import 'package:flutter_test/flutter_test.dart';
2+
import 'package:shared_preferences/shared_preferences.dart';
3+
import 'package:taskwarrior/app/utils/app_settings/app_settings.dart';
4+
5+
void main() {
6+
group('SaveTourStatus', () {
7+
setUp(() async {
8+
SharedPreferences.setMockInitialValues({});
9+
await SaveTourStatus.init();
10+
});
11+
12+
test('should save and retrieve reports tour status correctly', () async {
13+
await SaveTourStatus.saveReportsTourStatus(true);
14+
expect(await SaveTourStatus.getReportsTourStatus(), true);
15+
16+
await SaveTourStatus.saveReportsTourStatus(false);
17+
expect(await SaveTourStatus.getReportsTourStatus(), false);
18+
});
19+
20+
test('should save and retrieve in-app tour status correctly', () async {
21+
await SaveTourStatus.saveInAppTourStatus(true);
22+
expect(await SaveTourStatus.getInAppTourStatus(), true);
23+
24+
await SaveTourStatus.saveInAppTourStatus(false);
25+
expect(await SaveTourStatus.getInAppTourStatus(), false);
26+
});
27+
28+
test('should save and retrieve filter tour status correctly', () async {
29+
await SaveTourStatus.saveFilterTourStatus(true);
30+
expect(await SaveTourStatus.getFilterTourStatus(), true);
31+
32+
await SaveTourStatus.saveFilterTourStatus(false);
33+
expect(await SaveTourStatus.getFilterTourStatus(), false);
34+
});
35+
36+
test('should save and retrieve profile tour status correctly', () async {
37+
await SaveTourStatus.saveProfileTourStatus(true);
38+
expect(await SaveTourStatus.getProfileTourStatus(), true);
39+
40+
await SaveTourStatus.saveProfileTourStatus(false);
41+
expect(await SaveTourStatus.getProfileTourStatus(), false);
42+
});
43+
44+
test('should save and retrieve details tour status correctly', () async {
45+
await SaveTourStatus.saveDetailsTourStatus(true);
46+
expect(await SaveTourStatus.getDetailsTourStatus(), true);
47+
48+
await SaveTourStatus.saveDetailsTourStatus(false);
49+
expect(await SaveTourStatus.getDetailsTourStatus(), false);
50+
});
51+
52+
test('should save and retrieve manage task server tour status correctly',
53+
() async {
54+
await SaveTourStatus.saveManageTaskServerTourStatus(true);
55+
expect(await SaveTourStatus.getManageTaskServerTourStatus(), true);
56+
57+
await SaveTourStatus.saveManageTaskServerTourStatus(false);
58+
expect(await SaveTourStatus.getManageTaskServerTourStatus(), false);
59+
});
60+
});
61+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import 'package:flutter_test/flutter_test.dart';
2+
import 'package:shared_preferences/shared_preferences.dart';
3+
import 'package:taskwarrior/app/utils/app_settings/app_settings.dart';
4+
import 'package:taskwarrior/app/utils/language/supported_language.dart';
5+
6+
void main() {
7+
group('SelectedLanguage', () {
8+
setUp(() async {
9+
SharedPreferences.setMockInitialValues({});
10+
await SelectedLanguage.init();
11+
});
12+
13+
test('should save and retrieve selected language correctly', () async {
14+
await SelectedLanguage.saveSelectedLanguage(SupportedLanguage.spanish);
15+
expect(SelectedLanguage.getSelectedLanguage(), SupportedLanguage.spanish);
16+
17+
await SelectedLanguage.saveSelectedLanguage(SupportedLanguage.english);
18+
expect(SelectedLanguage.getSelectedLanguage(), SupportedLanguage.english);
19+
});
20+
});
21+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import 'package:flutter_test/flutter_test.dart';
2+
import 'package:shared_preferences/shared_preferences.dart';
3+
import 'package:taskwarrior/app/utils/app_settings/app_settings.dart';
4+
5+
void main() {
6+
group('SelectedTheme', () {
7+
setUp(() async {
8+
SharedPreferences.setMockInitialValues({});
9+
await SelectedTheme.init();
10+
});
11+
12+
test('should save and retrieve theme mode correctly', () async {
13+
await SelectedTheme.saveMode(false);
14+
expect(SelectedTheme.getMode(), false);
15+
16+
await SelectedTheme.saveMode(true);
17+
expect(SelectedTheme.getMode(), true);
18+
});
19+
});
20+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import 'package:flutter/material.dart';
2+
import 'package:flutter_test/flutter_test.dart';
3+
import 'package:taskwarrior/app/utils/constants/onboarding_screen_content.dart';
4+
5+
void main() {
6+
group('Onboarding Screen Content', () {
7+
test('should contain three onboarding items', () {
8+
expect(contents.length, 3);
9+
});
10+
11+
test('should have valid content for each onboarding item', () {
12+
for (var content in contents) {
13+
expect(content.title.isNotEmpty, true);
14+
expect(content.image.isNotEmpty, true);
15+
expect(content.colors, isA<Color>());
16+
expect(content.desc.isNotEmpty, true);
17+
}
18+
});
19+
20+
test('should match the expected titles', () {
21+
expect(contents[0].title, "Welcome to Taskwarrior");
22+
expect(contents[1].title, "Powerful Reporting");
23+
expect(contents[2].title, "Sync Across Devices");
24+
});
25+
});
26+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import 'package:flutter_test/flutter_test.dart';
2+
import 'package:taskwarrior/app/utils/constants/palette.dart';
3+
import 'package:flutter/material.dart';
4+
5+
void main() {
6+
group('Palette', () {
7+
test('kToDark should be a MaterialColor', () {
8+
expect(Palette.kToDark, isA<MaterialColor>());
9+
});
10+
11+
test('kToDark should contain the correct color values', () {
12+
expect(Palette.kToDark[50], const Color(0xff1e1e1e));
13+
expect(Palette.kToDark[100], const Color(0xff1a1a1a));
14+
expect(Palette.kToDark[200], const Color(0xff171717));
15+
expect(Palette.kToDark[300], const Color(0xff141414));
16+
expect(Palette.kToDark[400], const Color(0xff111111));
17+
expect(Palette.kToDark[500], const Color(0xff0d0d0d));
18+
expect(Palette.kToDark[600], const Color(0xff0a0a0a));
19+
expect(Palette.kToDark[700], const Color(0xff070707));
20+
expect(Palette.kToDark[800], const Color(0xff030303));
21+
expect(Palette.kToDark[900], const Color(0xff000000));
22+
});
23+
});
24+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import 'package:flutter_test/flutter_test.dart';
2+
import 'package:permission_handler/permission_handler.dart';
3+
import 'package:taskwarrior/app/utils/constants/permissions.dart';
4+
5+
void main() {
6+
group('Permissions', () {
7+
test('should contain the correct permissions', () {
8+
expect(permissions, [
9+
Permission.notification,
10+
Permission.storage,
11+
Permission.manageExternalStorage,
12+
]);
13+
});
14+
});
15+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import 'package:flutter_test/flutter_test.dart';
2+
import 'package:flutter/material.dart';
3+
import 'package:taskwarrior/app/utils/constants/palette.dart';
4+
import 'package:taskwarrior/app/utils/constants/taskwarrior_colors.dart';
5+
6+
void main() {
7+
group('TaskWarriorColors', () {
8+
test('should contain the correct normal colors', () {
9+
expect(TaskWarriorColors.red, Colors.red);
10+
expect(TaskWarriorColors.green, Colors.green);
11+
expect(TaskWarriorColors.yellow, Colors.yellow);
12+
expect(TaskWarriorColors.white, Colors.white);
13+
expect(TaskWarriorColors.black, Colors.black);
14+
expect(TaskWarriorColors.grey, Colors.grey);
15+
expect(TaskWarriorColors.lightGrey, Colors.grey[600]);
16+
expect(TaskWarriorColors.purple, Colors.purple);
17+
expect(TaskWarriorColors.borderColor, Colors.grey.shade300);
18+
expect(TaskWarriorColors.deepPurpleAccent, Colors.deepPurpleAccent);
19+
expect(TaskWarriorColors.deepPurple, Colors.deepPurple);
20+
});
21+
22+
test('should contain the correct dark theme colors', () {
23+
expect(
24+
TaskWarriorColors.kprimaryBackgroundColor, Palette.kToDark.shade200);
25+
expect(TaskWarriorColors.ksecondaryBackgroundColor,
26+
const Color.fromARGB(255, 48, 46, 46));
27+
expect(TaskWarriorColors.kprimaryTextColor, Colors.white);
28+
expect(TaskWarriorColors.ksecondaryTextColor, Colors.white);
29+
expect(
30+
TaskWarriorColors.kprimaryDisabledTextColor, const Color(0xff595f6b));
31+
expect(TaskWarriorColors.kdialogBackGroundColor,
32+
const Color.fromARGB(255, 25, 25, 25));
33+
});
34+
35+
test('should contain the correct light theme colors', () {
36+
expect(TaskWarriorColors.kLightPrimaryBackgroundColor, Colors.white);
37+
expect(TaskWarriorColors.kLightSecondaryBackgroundColor,
38+
const Color.fromARGB(255, 220, 216, 216));
39+
expect(TaskWarriorColors.kLightPrimaryTextColor, Colors.black);
40+
expect(TaskWarriorColors.kLightSecondaryTextColor,
41+
const Color.fromARGB(255, 48, 46, 46));
42+
expect(TaskWarriorColors.kLightPrimaryDisabledTextColor,
43+
const Color(0xffACACAB));
44+
expect(TaskWarriorColors.kLightDialogBackGroundColor, Colors.white);
45+
});
46+
});
47+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import 'package:flutter_test/flutter_test.dart';
2+
import 'package:flutter/material.dart';
3+
import 'package:taskwarrior/app/utils/constants/taskwarrior_fonts.dart';
4+
5+
void main() {
6+
group('TaskWarriorFonts', () {
7+
test('should contain the correct font weights', () {
8+
expect(TaskWarriorFonts.thin, FontWeight.w100);
9+
expect(TaskWarriorFonts.extraLight, FontWeight.w200);
10+
expect(TaskWarriorFonts.light, FontWeight.w300);
11+
expect(TaskWarriorFonts.regular, FontWeight.w400);
12+
expect(TaskWarriorFonts.medium, FontWeight.w500);
13+
expect(TaskWarriorFonts.semiBold, FontWeight.w600);
14+
expect(TaskWarriorFonts.bold, FontWeight.w700);
15+
expect(TaskWarriorFonts.extraBold, FontWeight.w800);
16+
expect(TaskWarriorFonts.black, FontWeight.w900);
17+
});
18+
19+
test('should contain the correct font sizes', () {
20+
expect(TaskWarriorFonts.fontSizeSmall, 12.0);
21+
expect(TaskWarriorFonts.fontSizeMedium, 16.0);
22+
expect(TaskWarriorFonts.fontSizeLarge, 20.0);
23+
expect(TaskWarriorFonts.fontSizeExtraLarge, 24.0);
24+
});
25+
});
26+
}

0 commit comments

Comments
 (0)