1 |
|
2 | describe('find-scripts', function () {
|
3 | const find = require('./find-scripts')
|
4 | const scripts = {
|
5 | foo: 'foo',
|
6 | bar: 'bar',
|
7 | barMore: 'bar-more',
|
8 | baz: 'baz'
|
9 | }
|
10 |
|
11 | it('is a function', function () {
|
12 | console.assert(typeof find === 'function')
|
13 | })
|
14 |
|
15 | it('finds nothing', function () {
|
16 | const found = find('a', scripts)
|
17 | console.assert(Array.isArray(found))
|
18 | console.assert(found.length === 0)
|
19 | })
|
20 |
|
21 | it('finds 1 partial match', function () {
|
22 | const found = find('f', scripts)
|
23 | console.assert(Array.isArray(found))
|
24 | console.assert(found.length === 1)
|
25 | console.assert(found[0] === 'foo')
|
26 | })
|
27 |
|
28 | it('finds 1 full match', function () {
|
29 | const found = find('foo', scripts)
|
30 | console.assert(Array.isArray(found))
|
31 | console.assert(found.length === 1)
|
32 | console.assert(found[0] === 'foo')
|
33 | })
|
34 |
|
35 | it('finds several', function () {
|
36 | const found = find('b', scripts)
|
37 | console.assert(Array.isArray(found))
|
38 | console.assert(found.length === 3)
|
39 | })
|
40 |
|
41 | it('finds an exact match if possible', function () {
|
42 | const found = find('bar', scripts)
|
43 | console.assert(Array.isArray(found))
|
44 | console.assert(found.length === 1, found)
|
45 | console.assert(found[0] === 'bar')
|
46 | })
|
47 | })
|