-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.js
58 lines (49 loc) · 1.81 KB
/
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
'use strict'
const test = require('tape')
const sortLines = require('.')
test('sorts by mode of transport', (t) => {
t.plan(1)
t.deepEqual([
{type: 'line', id: '3', name: 'foo', mode: 'bus'},
{type: 'line', id: '4', name: 'bar', mode: 'walking'},
{type: 'line', id: '1', name: 'bar', mode: 'train'},
{type: 'line', id: '2', name: 'bar', mode: 'ferry'}
].sort(sortLines), [
{type: 'line', id: '1', name: 'bar', mode: 'train'},
{type: 'line', id: '2', name: 'bar', mode: 'ferry'},
{type: 'line', id: '3', name: 'foo', mode: 'bus'},
{type: 'line', id: '4', name: 'bar', mode: 'walking'}
])
})
test('sorts by name', (t) => {
t.plan(1)
t.deepEqual([
{type: 'line', id: '4', name: '245', mode: 'bus'},
{type: 'line', id: '2', name: 'M45', mode: 'bus'},
{type: 'line', id: '5', name: '300', mode: 'bus'},
{type: 'line', id: '1', name: 'M5', mode: 'bus'},
{type: 'line', id: '3', name: '10', mode: 'bus'}
].sort(sortLines), [
{type: 'line', id: '1', name: 'M5', mode: 'bus'},
{type: 'line', id: '2', name: 'M45', mode: 'bus'},
{type: 'line', id: '3', name: '10', mode: 'bus'},
{type: 'line', id: '4', name: '245', mode: 'bus'},
{type: 'line', id: '5', name: '300', mode: 'bus'}
])
})
test('kitchen sink', (t) => {
t.plan(1)
t.deepEqual([
{type: 'line', id: '1', name: '11', mode: 'train'},
{type: 'line', id: '5', name: '300', mode: 'bus'},
{type: 'line', id: '2', name: '100', mode: 'train'},
{type: 'line', id: '4', name: 'M45', mode: 'bus'},
{type: 'line', id: '3', name: '10', mode: 'ferry'}
].sort(sortLines), [
{type: 'line', id: '1', name: '11', mode: 'train'},
{type: 'line', id: '2', name: '100', mode: 'train'},
{type: 'line', id: '3', name: '10', mode: 'ferry'},
{type: 'line', id: '4', name: 'M45', mode: 'bus'},
{type: 'line', id: '5', name: '300', mode: 'bus'}
])
})