Files
GitJournal/test/sorting_mode_test.dart
Vishesh Handa 88552fe8e9 Revert "Workaround intl bug by harding 'en' locale"
This reverts commit 303192d9d575b26a77a00f7a62212f310ec1e329.
This reverts commit cd9d128b47ed523036f7ae1232ec7adcf04ed8a9.

GitJournal is used by non-English speakers (a lot in China and Russia)
and while we don't support those languages completely, we do support
them a little bit. I don't want to loose this functionality. It would be
better for us to fix the bug in intl.
2020-06-10 09:31:08 +02:00

57 lines
1.5 KiB
Dart

import 'package:gitjournal/core/note.dart';
import 'package:gitjournal/core/notes_folder_fs.dart';
import 'package:gitjournal/core/sorting_mode.dart';
import 'package:test/test.dart';
void main() {
group('Sorting Mode', () {
test('Created', () async {
var folder = NotesFolderFS(null, '/tmp/');
var n1 = Note(folder, '/tmp/1.md');
n1.created = DateTime(2020, 10, 01);
var n2 = Note(folder, '/tmp/2.md');
n2.created = DateTime(2020, 10, 02);
var n3 = Note(folder, '/tmp/3.md');
n3.created = null;
var n4 = Note(folder, '/tmp/4.md');
n4.created = null;
var notes = [n1, n2, n3, n4];
var sortFn = SortingMode.Created.sortingFunction();
notes.sort(sortFn);
expect(notes[0], n2);
expect(notes[1], n1);
expect(notes[2], n3);
expect(notes[3], n4);
});
test('Modified', () async {
var folder = NotesFolderFS(null, '/tmp/');
var n1 = Note(folder, '/tmp/1.md');
n1.modified = DateTime(2020, 10, 01);
var n2 = Note(folder, '/tmp/2.md');
n2.modified = DateTime(2020, 10, 02);
var n3 = Note(folder, '/tmp/3.md');
n3.modified = null;
var n4 = Note(folder, '/tmp/4.md');
n4.modified = null;
var notes = [n1, n2, n3, n4];
var sortFn = SortingMode.Modified.sortingFunction();
notes.sort(sortFn);
expect(notes[0], n2);
expect(notes[1], n1);
expect(notes[2], n3);
expect(notes[3], n4);
});
});
}