-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest.js
74 lines (62 loc) · 1.56 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
import assert from 'node:assert/strict'
import test from 'node:test'
import {parse, stringify} from './index.js'
test('space-separated-tokens', async function (t) {
await t.test('.parse()', () => {
assert.equal(typeof parse, 'function', 'should be a method')
assert.deepEqual(
// @ts-expect-error runtime
parse(),
[],
'should return an empty array for an empty value'
)
assert.deepEqual(
parse(' '),
[],
'should return an empty array for a single whitespace'
)
assert.deepEqual(
parse('\n\t\t '),
[],
'should return an empty array for a several whitespace characters'
)
assert.deepEqual(
parse(' foo bar 💩\t\n\t'),
['foo', 'bar', '💩'],
'should work'
)
})
await t.test('.stringify()', () => {
assert.equal(typeof stringify, 'function', 'should be a method')
assert.deepEqual(
stringify([]),
'',
'should return an empty string for an empty array'
)
assert.deepEqual(
stringify(['']),
'',
'should return an empty string for an empty entry'
)
assert.deepEqual(
stringify(['', '']),
'',
'should return an empty string for two empty entries'
)
assert.deepEqual(
stringify(['', 'foo']),
'foo',
'should ignore initial empty entries'
)
assert.deepEqual(
stringify(['foo', '']),
'foo',
'should ignore final empty values'
)
assert.deepEqual(
stringify(['a', 'b', 'd d']),
'a b d d',
'should do its best'
)
})
})