|
| 1 | +/* eslint max-nested-callbacks: ["error", 8] */ |
1 | 2 | /* eslint-env mocha */ |
2 | 3 | 'use strict' |
3 | 4 |
|
@@ -37,58 +38,76 @@ describe('IPLD format resolver (local)', () => { |
37 | 38 |
|
38 | 39 | describe('empty node', () => { |
39 | 40 | describe('resolver.resolve', () => { |
40 | | - it('root', () => { |
41 | | - const result = resolver.resolve(emptyNodeBlock, '/') |
42 | | - expect(result.value).to.be.eql({}) |
| 41 | + it('root', (done) => { |
| 42 | + resolver.resolve(emptyNodeBlock, '/', (err, result) => { |
| 43 | + expect(err).to.not.exist |
| 44 | + expect(result.value).to.be.eql({}) |
| 45 | + done() |
| 46 | + }) |
43 | 47 | }) |
44 | 48 | }) |
45 | 49 |
|
46 | | - it('resolver.tree', () => { |
47 | | - const paths = resolver.tree(emptyNodeBlock) |
48 | | - expect(paths).to.eql([]) |
| 50 | + it('resolver.tree', (done) => { |
| 51 | + resolver.tree(emptyNodeBlock, (err, paths) => { |
| 52 | + expect(err).to.not.exist |
| 53 | + expect(paths).to.eql([]) |
| 54 | + done() |
| 55 | + }) |
49 | 56 | }) |
50 | 57 |
|
51 | | - it.skip('resolver.patch', (done) => {}) |
| 58 | + it.skip('resolver.patch', () => {}) |
52 | 59 | }) |
53 | 60 |
|
54 | 61 | describe('node', () => { |
55 | 62 | describe('resolver.resolve', () => { |
56 | | - it('path within scope', () => { |
57 | | - const result = resolver.resolve(nodeBlock, 'name') |
58 | | - expect(result.value).to.equal('I am a node') |
| 63 | + it('path within scope', (done) => { |
| 64 | + resolver.resolve(nodeBlock, 'name', (err, result) => { |
| 65 | + expect(err).to.not.exist |
| 66 | + expect(result.value).to.equal('I am a node') |
| 67 | + done() |
| 68 | + }) |
59 | 69 | }) |
60 | 70 |
|
61 | | - it('path within scope, but nested', () => { |
62 | | - const result = resolver.resolve(nodeBlock, 'nest/foo/bar') |
63 | | - expect(result.value).to.equal('baz') |
| 71 | + it('path within scope, but nested', (done) => { |
| 72 | + resolver.resolve(nodeBlock, 'nest/foo/bar', (err, result) => { |
| 73 | + expect(err).to.not.exist |
| 74 | + expect(result.value).to.equal('baz') |
| 75 | + done() |
| 76 | + }) |
64 | 77 | }) |
65 | 78 |
|
66 | | - it('path out of scope', () => { |
67 | | - const result = resolver.resolve(nodeBlock, 'someLink/a/b/c') |
68 | | - expect(result.value).to.eql({ '/': 'LINK' }) |
69 | | - expect(result.remainderPath).to.equal('a/b/c') |
| 79 | + it('path out of scope', (done) => { |
| 80 | + resolver.resolve(nodeBlock, 'someLink/a/b/c', (err, result) => { |
| 81 | + expect(err).to.not.exist |
| 82 | + expect(result.value).to.eql({ '/': 'LINK' }) |
| 83 | + expect(result.remainderPath).to.equal('a/b/c') |
| 84 | + done() |
| 85 | + }) |
70 | 86 | }) |
71 | 87 | }) |
72 | 88 |
|
73 | | - it('resolver.tree', () => { |
74 | | - const paths = resolver.tree(nodeBlock) |
75 | | - expect(paths).to.eql([{ |
76 | | - path: 'name', |
77 | | - value: 'I am a node' |
78 | | - }, { |
79 | | - // TODO: confirm how to represent links in tree |
80 | | - path: 'someLink//', |
81 | | - value: 'LINK' |
82 | | - }, { |
83 | | - path: 'nest/foo/bar', |
84 | | - value: 'baz' |
85 | | - }, { |
86 | | - path: 'array/0/a', |
87 | | - value: 'b' |
88 | | - }, { |
89 | | - path: 'array/1', |
90 | | - value: 2 |
91 | | - }]) |
| 89 | + it('resolver.tree', (done) => { |
| 90 | + resolver.tree(nodeBlock, (err, paths) => { |
| 91 | + expect(err).to.not.exist |
| 92 | + expect(paths).to.eql([{ |
| 93 | + path: 'name', |
| 94 | + value: 'I am a node' |
| 95 | + }, { |
| 96 | + // TODO: confirm how to represent links in tree |
| 97 | + path: 'someLink//', |
| 98 | + value: 'LINK' |
| 99 | + }, { |
| 100 | + path: 'nest/foo/bar', |
| 101 | + value: 'baz' |
| 102 | + }, { |
| 103 | + path: 'array/0/a', |
| 104 | + value: 'b' |
| 105 | + }, { |
| 106 | + path: 'array/1', |
| 107 | + value: 2 |
| 108 | + }]) |
| 109 | + done() |
| 110 | + }) |
92 | 111 | }) |
93 | 112 |
|
94 | 113 | it.skip('resolver.patch', () => {}) |
|
0 commit comments