1 |
|
2 | var tape = require('tape')
|
3 | var m = require('../util')
|
4 | var mount = m.mount
|
5 | var unmount = m.unmount
|
6 |
|
7 | tape('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 |
|
22 | tape('without mount without path should throw', function (t) {
|
23 |
|
24 | t.throws(function () {
|
25 | mount({}, {thing: 'async'})
|
26 | })
|
27 |
|
28 | t.end()
|
29 | })
|
30 |
|
31 | tape('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 |
|
48 | tape('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 |
|
64 | tape('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 |
|