|
2 | 2 | var test = require('tap-only'); |
3 | 3 | var undefsafe = require('../lib/undefsafe'); |
4 | 4 | var fixture = { |
5 | | - "commits": [ |
| 5 | + commits: [ |
6 | 6 | { |
7 | | - "modified": [ |
8 | | - "one", |
9 | | - "two" |
10 | | - ] |
| 7 | + modified: ['one', 'two'] |
11 | 8 | }, |
12 | 9 | { |
13 | | - "modified": [ |
14 | | - "two", |
15 | | - "four" |
16 | | - ] |
| 10 | + modified: ['two', 'four'] |
17 | 11 | } |
18 | 12 | ] |
19 | 13 | }; |
20 | 14 |
|
21 | | -test('2.0.0: match all.*', function (t) { |
| 15 | +test('2.0.0: match all.*', function(t) { |
22 | 16 | var res = undefsafe(fixture, '*.*.*.1'); |
23 | 17 | t.deepEqual(res, ['two', 'four']); |
24 | 18 | t.end(); |
25 | 19 | }); |
26 | 20 |
|
27 | | - |
28 | | -test('2.0.0: match all.*', function (t) { |
| 21 | +test('2.0.0: match all.*', function(t) { |
29 | 22 | var res = undefsafe(fixture, 'commits.*.modified.*.b'); |
30 | 23 | t.deepEqual(res, ['one', 'two', 'two', 'four']); |
31 | 24 | t.end(); |
32 | 25 | }); |
33 | 26 |
|
34 | | - |
35 | | -test('get value on first * selector', function (t) { |
| 27 | +test('get value on first * selector', function(t) { |
36 | 28 | var res = undefsafe(fixture, 'commits.*.modified.0'); |
37 | 29 | t.deepEqual(res, ['one', 'two']); |
38 | 30 | t.end(); |
39 | 31 | }); |
40 | 32 |
|
41 | | -test('walking multiple routes', function (t) { |
| 33 | +test('walking multiple routes', function(t) { |
42 | 34 | var res = undefsafe(fixture, 'commits.*.modified.*', 'four'); |
43 | 35 | t.equal(res, 'four'); |
44 | 36 | t.end(); |
45 | 37 | }); |
46 | 38 |
|
47 | | - |
48 | | -test('get specific match * selector', function (t) { |
| 39 | +test('get specific match * selector', function(t) { |
49 | 40 | var res = undefsafe(fixture, 'commits.*.modified.*', 'two'); |
50 | 41 | t.equal(res, 'two'); |
51 | 42 | t.end(); |
52 | 43 | }); |
53 | 44 |
|
54 | | -test('match * selector returns undefined', function (t) { |
| 45 | +test('match * selector returns undefined', function(t) { |
55 | 46 | var res = undefsafe(fixture, 'commits.*.modified.*', 'three'); |
56 | 47 | t.equal(res, undefined); |
57 | 48 | t.end(); |
58 | 49 | }); |
59 | 50 |
|
60 | | -test('match * selector works on objects', function (t) { |
| 51 | +test('match * selector works on objects', function(t) { |
61 | 52 | var res = undefsafe(fixture, '*.*.modified.*', 'one'); |
62 | 53 | t.equal(res, 'one'); |
63 | 54 | t.end(); |
|
0 commit comments