1 | import test from 'ava';
|
2 | import parser from '../parser';
|
3 |
|
4 | test('It should sort modules correctly', t => {
|
5 | const modules = [
|
6 | {
|
7 | status: 'FAILED',
|
8 | link: 'www.vorlesungen.uzh.ch/HS16/suche/sm-50018688.modveranst.html'
|
9 | },
|
10 | {
|
11 | status: 'PASSED',
|
12 | link: 'www.vorlesungen.uzh.ch/HS16/suche/sm-50018689.modveranst.html'
|
13 | }
|
14 | ];
|
15 |
|
16 | const output = [
|
17 | {
|
18 | status: 'PASSED',
|
19 | link: 'www.vorlesungen.uzh.ch/HS16/suche/sm-50018689.modveranst.html#0'
|
20 | },
|
21 | {
|
22 | status: 'FAILED',
|
23 | link: 'www.vorlesungen.uzh.ch/HS16/suche/sm-50018688.modveranst.html#1'
|
24 | }
|
25 | ];
|
26 |
|
27 | t.deepEqual(output, parser.filterDuplicates(modules));
|
28 | });
|
29 |
|
30 | test('It should sort semesters reverse-chronologically', t => {
|
31 | const older = {
|
32 | link: 'http://www.vorlesungen.uzh.ch/FS09/lehrangebot/fak-50000003/sc-50427948/cga-50427948010/cg-50427949/sm-50345595/person-1092257.details.html'
|
33 | };
|
34 | const newer = {
|
35 | link: 'http://www.vorlesungen.uzh.ch/FS16/lehrangebot/fak-50000003/sc-50427948/cga-50427948010/cg-50427949/sm-50345595/person-1092257.details.html'
|
36 | };
|
37 |
|
38 | t.deepEqual(parser.groupBySemester([newer, older]), [{semester: 'FS16', credits: [newer]}, {semester: 'FS09', credits: [older]}]);
|
39 | });
|