-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathreport.test.js
34 lines (32 loc) · 1.02 KB
/
report.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
const { sortPages } = require('./report');
const { test, expect } = require('@jest/globals');
test('sortPages should sort 2 pages by highest count', () => {
const pages = {
'http://www.example.com': 3,
'http://www.example.com/1': 2,
};
const actual = sortPages(pages);
const expected = [
['http://www.example.com', 3],
['http://www.example.com/1', 2],
];
expect(actual).toEqual(expected);
});
test('sortPages should sort 5 pages by highest count', () => {
const pages = {
'http://www.example.com': 3,
'http://www.example.com/1': 9,
'http://www.example.com/2': 5,
'http://www.example.com/3': 1,
'http://www.example.com/4': 4,
};
const actual = sortPages(pages);
const expected = [
['http://www.example.com/1', 9],
['http://www.example.com/2', 5],
['http://www.example.com/4', 4],
['http://www.example.com', 3],
['http://www.example.com/3', 1],
];
expect(actual).toEqual(expected);
});