-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpath-analyzer.js
More file actions
57 lines (43 loc) · 1.31 KB
/
Copy pathpath-analyzer.js
File metadata and controls
57 lines (43 loc) · 1.31 KB
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
import { assert } from 'chai'
import { pathDepth } from '../lib/path-analyzer.js'
describe('path-analyzer', () => {
it('empty', function () {
assert.isNull(pathDepth(''))
})
it('foo.bar.baz', function () {
assert.deepEqual(pathDepth(this.test.title), 0)
})
it('foo[3]', function () {
assert.deepEqual(pathDepth(this.test.title), 0)
})
it('[]', function () {
assert.deepEqual(pathDepth(this.test.title), 1)
})
it('foo.bar[]', function () {
assert.deepEqual(pathDepth(this.test.title), 1)
})
it('foo.bar[1,3].baz', function () {
assert.deepEqual(pathDepth(this.test.title), 1)
})
it(`foo['bar'][].baz`, function () {
assert.deepEqual(pathDepth(this.test.title), 1)
})
it(`foo.bar[].baz[].gee`, function () {
assert.deepEqual(pathDepth(this.test.title), 1)
})
it(`foo.bar[:].baz[].gee`, function () {
assert.deepEqual(pathDepth(this.test.title), 2)
})
it(`foo.bar[:#].baz[].gee[]`, function () {
assert.deepEqual(pathDepth(this.test.title), 2)
})
it('foo[].bar{bee,gee}', function () {
assert.deepEqual(pathDepth(this.test.title), 2)
})
it('foo[].bar[]{bee,gee}', function () {
assert.deepEqual(pathDepth(this.test.title), 2)
})
it('foo[:].bar[]{bee,gee}', function () {
assert.deepEqual(pathDepth(this.test.title), 3)
})
})