-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
test.js
98 lines (88 loc) · 1.79 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
import test from 'ava';
import {parse, stringify} from './index.js';
test('parse = should parse all props', t => {
t.deepEqual(
parse('Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)'),
{
name: 'Sindre Sorhus',
email: 'sindresorhus@gmail.com',
url: 'https://sindresorhus.com',
},
);
});
test('parse - should parse name', t => {
t.deepEqual(
parse('Sindre Sorhus'),
{
name: 'Sindre Sorhus',
},
);
});
test('parse - should parse email', t => {
t.deepEqual(
parse('<sindresorhus@gmail.com>'),
{
email: 'sindresorhus@gmail.com',
},
);
});
test('parse - should parse URL', t => {
t.deepEqual(
parse('(https://sindresorhus.com)'),
{
url: 'https://sindresorhus.com',
},
);
});
test('stringify - should stringify all props', t => {
t.is(
stringify({
name: 'Sindre Sorhus',
email: 'sindresorhus@gmail.com',
url: 'https://sindresorhus.com',
}),
'Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)',
);
});
test('stringify - should stringify name', t => {
t.is(
stringify({
name: 'Sindre Sorhus',
}),
'Sindre Sorhus',
);
});
test('stringify - should stringify email', t => {
t.is(
stringify({
email: 'sindresorhus@gmail.com',
}),
'<sindresorhus@gmail.com>',
);
});
test('stringify - should stringify url', t => {
t.is(
stringify({
url: 'https://sindresorhus.com',
}),
'(https://sindresorhus.com)',
);
});
test('stringify - should stringify name and email', t => {
t.is(
stringify({
name: 'Sindre Sorhus',
email: 'sindresorhus@gmail.com',
}),
'Sindre Sorhus <sindresorhus@gmail.com>',
);
});
test('stringify - should stringify name and url', t => {
t.is(
stringify({
name: 'Sindre Sorhus',
url: 'https://sindresorhus.com',
}),
'Sindre Sorhus (https://sindresorhus.com)',
);
});