-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
80 lines (65 loc) · 1.84 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
/* global describe, it */
var anyPath = require('./')
require('chai').should()
require('tap').mochaGlobals()
describe('any-test', function () {
it('handles windows style paths', function (done) {
var o = anyPath({
'./foo/bar/README.md': 99
})
o['.\\foo\\bar\\README.md'].should.equal(99)
return done()
})
it('handles *nix style paths', function (done) {
var o = anyPath({
'.\\foo\\bar\\README.md': 99
})
o['./foo/bar/README.md'].should.equal(99)
return done()
})
it('handles mixed paths', function (done) {
var o = {
'./foo\/bar/README.md': 99
}
anyPath(o)
o['.\\foo/bar\\README.md'].should.equal(99)
return done()
})
it('handles no path', function (done) {
var o = {
'README.md': 99
}
anyPath(o)
o['README.md'].should.equal(99)
return done()
})
it('updates all permutations when a simple value is changed', function (done) {
var o = anyPath({
'.\\foo\\bar\\README.md': 99
})
o['./foo/bar/README.md'] = 202
o['./foo\/bar/README.md'].should.equal(202)
o['.\\foo\\bar\\README.md'].should.equal(202)
return done()
})
it("updates all permutations when an inner object's value is changed", function (done) {
var o = anyPath({
'.\\foo\\bar\\README.md': {name: 'README.md'}
})
o['./foo/bar/README.md'].name = 'package.json'
o['./foo\/bar/README.md'].name.should.equal('package.json')
o['.\\foo\\bar\\README.md'].name.should.equal('package.json')
return done()
})
describe('restore', function () {
it('returns object back to its initial state', function (done) {
var o = anyPath({
'.\\foo\\bar\\README.md': {name: 'README.md'}
})
o.__restore__().should.deep.equal({
'.\\foo\\bar\\README.md': {name: 'README.md'}
})
return done()
})
})
})