1
0
mirror of https://github.com/go-vikunja/app synced 2024-10-04 13:18:31 +00:00
app-mirror-github/test/parse_repeat_after_test.dart

77 lines
2.3 KiB
Dart
Raw Permalink Normal View History

2021-06-04 09:34:25 +00:00
import 'package:test/test.dart';
import 'package:vikunja_app/utils/repeat_after_parse.dart';
void main() {
test('Repeat after hours', () {
Duration testDuration = Duration(hours: 6);
expect(getRepeatAfterTypeFromDuration(testDuration), 'Hours');
expect(getRepeatAfterValueFromDuration(testDuration), 6);
});
test('Repeat after days', () {
Duration testDuration = Duration(days: 6);
expect(getRepeatAfterTypeFromDuration(testDuration), 'Days');
expect(getRepeatAfterValueFromDuration(testDuration), 6);
});
test('Repeat after weeks', () {
Duration testDuration = Duration(days: 6 * 7);
expect(getRepeatAfterTypeFromDuration(testDuration), 'Weeks');
expect(getRepeatAfterValueFromDuration(testDuration), 6);
});
test('Repeat after months', () {
Duration testDuration = Duration(days: 6 * 30);
expect(getRepeatAfterTypeFromDuration(testDuration), 'Months');
expect(getRepeatAfterValueFromDuration(testDuration), 6);
});
test('Repeat after years', () {
Duration testDuration = Duration(days: 6 * 365);
expect(getRepeatAfterTypeFromDuration(testDuration), 'Years');
expect(getRepeatAfterValueFromDuration(testDuration), 6);
});
test('Repeat null value', () {
Duration testDuration = Duration();
expect(getRepeatAfterTypeFromDuration(testDuration), null);
expect(getRepeatAfterValueFromDuration(testDuration), null);
});
test('Hours to duration', () {
2022-09-07 20:59:28 +00:00
Duration? parsedDuration = getDurationFromType('6', 'Hours');
2021-06-04 09:34:25 +00:00
expect(parsedDuration, Duration(hours: 6));
});
test('Days to duration', () {
2022-09-07 20:59:28 +00:00
Duration? parsedDuration = getDurationFromType('6', 'Days');
2021-06-04 09:34:25 +00:00
expect(parsedDuration, Duration(days: 6));
});
test('Weeks to duration', () {
2022-09-07 20:59:28 +00:00
Duration? parsedDuration = getDurationFromType('6', 'Weeks');
2021-06-04 09:34:25 +00:00
expect(parsedDuration, Duration(days: 6 * 7));
});
test('Months to duration', () {
2022-09-07 20:59:28 +00:00
Duration? parsedDuration = getDurationFromType('6', 'Months');
2021-06-04 09:34:25 +00:00
expect(parsedDuration, Duration(days: 6 * 30));
});
test('Years to duration', () {
2022-09-07 20:59:28 +00:00
Duration? parsedDuration = getDurationFromType('6', 'Years');
2021-06-04 09:34:25 +00:00
expect(parsedDuration, Duration(days: 6 * 365));
});
test('null to duration', () {
2022-09-07 20:59:28 +00:00
Duration? parsedDuration = getDurationFromType(null, null);
2021-06-04 09:34:25 +00:00
expect(parsedDuration, Duration());
});
}