UNPKG

1.3 kBJavaScriptView Raw
1
2var tape = require('tape')
3var m = require('../util')
4var mount = m.mount
5var unmount = m.unmount
6
7tape('mount manifest at root', function (t) {
8
9 var manf = {}
10
11 mount(manf, [], {thing: 'async'})
12
13 t.deepEqual(manf, {thing: 'async'})
14
15 mount(manf, ['foo'], {thing: 'async'})
16
17 t.deepEqual(manf, {thing: 'async', foo: {thing: 'async'}})
18
19 t.end()
20})
21
22tape('without mount without path should throw', function (t) {
23
24 t.throws(function () {
25 mount({}, {thing: 'async'})
26 })
27
28 t.end()
29})
30
31tape('unmount', function (t) {
32 var manf = {}
33
34 mount(manf, ['foo'], {one: 'async'})
35 mount(manf, ['bar'], {two: 'async'})
36
37 t.deepEqual(manf, {foo: {one: 'async'}, bar: {two: 'async'}})
38
39 unmount(manf, ['foo'])
40
41 t.deepEqual(manf, {bar: {two: 'async'}})
42
43 t.end()
44
45})
46
47
48tape('deep unmount', function (t) {
49 var manf = {}
50
51 mount(manf, ['foo'], {one: 'async'})
52 mount(manf, ['foo', 'bar'], {two: 'async'})
53
54 t.deepEqual(manf, {foo: {one: 'async', bar: {two: 'async'}}})
55
56 unmount(manf, ['foo', 'bar'])
57
58 t.deepEqual(manf, {foo: {one: 'async'}})
59
60 t.end()
61
62})
63
64tape('deep unmount 2', function (t) {
65
66 var manf = {}
67
68 m.mount(manf, ['foo', 'bar'], {two: 'async'})
69
70 t.deepEqual(manf, {foo: {bar: {two: 'async'}}})
71
72 m.unmount(manf, ['foo', 'bar'])
73
74 t.deepEqual(manf, {})
75
76 t.end()
77
78})
79