|
| 1 | +/* eslint-env mocha */ |
| 2 | +'use strict' |
| 3 | + |
| 4 | +const expect = require('chai').expect |
| 5 | +const dagCBOR = require('../src') |
| 6 | +const resolver = dagCBOR.resolver |
| 7 | +const Block = require('ipfs-block') |
| 8 | + |
| 9 | +describe('IPLD format resolver (local)', () => { |
| 10 | + let emptyNodeBlock |
| 11 | + let nodeBlock |
| 12 | + |
| 13 | + before(() => { |
| 14 | + const emptyNode = {} |
| 15 | + const node = { |
| 16 | + name: 'I am a node', |
| 17 | + someLink: { '/': 'LINK' }, |
| 18 | + nest: { |
| 19 | + foo: { |
| 20 | + bar: 'baz' |
| 21 | + } |
| 22 | + }, |
| 23 | + array: [ |
| 24 | + { a: 'b' }, |
| 25 | + 2 |
| 26 | + ] |
| 27 | + |
| 28 | + } |
| 29 | + |
| 30 | + emptyNodeBlock = new Block(dagCBOR.util.serialize(emptyNode)) |
| 31 | + nodeBlock = new Block(dagCBOR.util.serialize(node)) |
| 32 | + }) |
| 33 | + |
| 34 | + it('multicodec is dag-cbor', () => { |
| 35 | + expect(resolver.multicodec).to.equal('dag-cbor') |
| 36 | + }) |
| 37 | + |
| 38 | + describe('empty node', () => { |
| 39 | + describe('resolver.resolve', () => { |
| 40 | + it.skip('path', () => { |
| 41 | + }) |
| 42 | + }) |
| 43 | + |
| 44 | + it('resolver.tree', () => { |
| 45 | + const paths = resolver.tree(emptyNodeBlock) |
| 46 | + expect(paths).to.eql([]) |
| 47 | + }) |
| 48 | + |
| 49 | + it.skip('resolver.patch', (done) => {}) |
| 50 | + }) |
| 51 | + |
| 52 | + describe('node', () => { |
| 53 | + describe.skip('resolver.resolve', () => { |
| 54 | + it('path', () => { |
| 55 | + }) |
| 56 | + }) |
| 57 | + |
| 58 | + it('resolver.tree', () => { |
| 59 | + const paths = resolver.tree(nodeBlock) |
| 60 | + expect(paths).to.eql([{ |
| 61 | + path: 'name', |
| 62 | + value: 'I am a node' |
| 63 | + }, { |
| 64 | + // TODO confirm how to represent links in tree |
| 65 | + path: 'someLink//', |
| 66 | + value: 'LINK' |
| 67 | + }, { |
| 68 | + path: 'nest/foo/bar', |
| 69 | + value: 'baz' |
| 70 | + } |
| 71 | + // TODO fix array in .tree |
| 72 | + /*, { |
| 73 | + path: 'array/0/a', |
| 74 | + value: 'b' |
| 75 | + }, { |
| 76 | + path: 'array/1', |
| 77 | + value: '2' |
| 78 | + } */]) |
| 79 | + }) |
| 80 | + |
| 81 | + it.skip('resolver.patch', () => {}) |
| 82 | + }) |
| 83 | +}) |
0 commit comments