Skip to content
This repository was archived by the owner on Aug 11, 2021. It is now read-only.

Commit fe76021

Browse files
committed
remaining tests
1 parent 24dd23b commit fe76021

16 files changed

+86
-14
lines changed
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

test/interop.spec.js

Lines changed: 86 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,30 @@
44
const expect = require('chai').expect
55
const dagCBOR = require('../src')
66
const loadFixture = require('aegir/fixtures')
7-
const bs58 = require('base-x')('123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz')
8-
// const bs58 = require('bs58')
7+
// const bs58 = require('base-x')('123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz')
8+
const bs58 = require('bs58')
99

1010
const CID = require('cids')
1111

12-
const arrayLinkCBOR = loadFixture(__dirname, '/test-data/array-link.cbor')
13-
const arrayLinkJSON = require('./test-data/array-link.json')
12+
const arrayLinkCBOR = loadFixture(__dirname, '/fixtures/array-link.cbor')
13+
const arrayLinkJSON = require('./fixtures/array-link.json')
1414

15-
const objNoLinkCBOR = loadFixture(__dirname, '/test-data/obj-no-link.cbor')
16-
const objNoLinkJSON = require('./test-data/obj-no-link.json')
15+
const emptyArrayCBOR = loadFixture(__dirname, '/fixtures/empty-array.cbor')
16+
const emptyArrayJSON = require('./fixtures/empty-array.json')
1717

18-
const expectedCIDs = require('./test-data/expected.json')
18+
const emptyObjCBOR = loadFixture(__dirname, '/fixtures/empty-obj.cbor')
19+
const emptyObjJSON = require('./fixtures/empty-obj.json')
20+
21+
const fooCBOR = loadFixture(__dirname, '/fixtures/foo.cbor')
22+
const fooJSON = require('./fixtures/foo.json')
23+
24+
const objNoLinkCBOR = loadFixture(__dirname, '/fixtures/obj-no-link.cbor')
25+
const objNoLinkJSON = require('./fixtures/obj-no-link.json')
26+
27+
const objWithLinkCBOR = loadFixture(__dirname, '/fixtures/obj-with-link.cbor')
28+
const objWithLinkJSON = require('./fixtures/obj-with-link.json')
29+
30+
const expectedCIDs = require('./fixtures/expected.json')
1931

2032
describe.only('dag-cbor interop tests', () => {
2133
describe('deserialize and compare', () => {
@@ -42,11 +54,47 @@ describe.only('dag-cbor interop tests', () => {
4254
})
4355
})
4456

45-
it.skip('empty-array', (done) => {})
57+
it('empty-array', (done) => {
58+
dagCBOR.util.deserialize(emptyArrayCBOR, (err, node) => {
59+
expect(err).to.not.exist
60+
expect(node).to.eql(emptyArrayJSON)
4661

47-
it.skip('empty-obj', (done) => {})
62+
dagCBOR.util.cid(node, (err, cid) => {
63+
expect(err).to.not.exist
64+
const cidStr = cid.toBaseEncodedString()
65+
expect(cidStr).to.eql(expectedCIDs['empty-array']['/'])
66+
done()
67+
})
68+
})
69+
})
4870

49-
it.skip('foo', (done) => {})
71+
it('empty-obj', (done) => {
72+
dagCBOR.util.deserialize(emptyObjCBOR, (err, node) => {
73+
expect(err).to.not.exist
74+
expect(node).to.eql(emptyObjJSON)
75+
76+
dagCBOR.util.cid(node, (err, cid) => {
77+
expect(err).to.not.exist
78+
const cidStr = cid.toBaseEncodedString()
79+
expect(cidStr).to.eql(expectedCIDs['empty-obj']['/'])
80+
done()
81+
})
82+
})
83+
})
84+
85+
it.skip('foo', (done) => {
86+
dagCBOR.util.deserialize(fooCBOR, (err, node) => {
87+
expect(err).to.not.exist
88+
expect(node).to.eql(fooJSON)
89+
90+
dagCBOR.util.cid(node, (err, cid) => {
91+
expect(err).to.not.exist
92+
const cidStr = cid.toBaseEncodedString()
93+
expect(cidStr).to.eql(expectedCIDs['foo']['/'])
94+
done()
95+
})
96+
})
97+
})
5098

5199
it('obj-no-link', (done) => {
52100
dagCBOR.util.deserialize(objNoLinkCBOR, (err, node) => {
@@ -62,11 +110,23 @@ describe.only('dag-cbor interop tests', () => {
62110
})
63111
})
64112

65-
it.skip('obj-with-link', (done) => {})
113+
it.skip('obj-with-link', (done) => {
114+
dagCBOR.util.deserialize(objWithLinkCBOR, (err, node) => {
115+
expect(err).to.not.exist
116+
expect(node).to.eql(objWithLinkJSON)
117+
118+
dagCBOR.util.cid(node, (err, cid) => {
119+
expect(err).to.not.exist
120+
const cidStr = cid.toBaseEncodedString()
121+
expect(cidStr).to.eql(expectedCIDs['obj-with-link']['/'])
122+
done()
123+
})
124+
})
125+
})
66126
})
67127

68128
describe('serialise and compare', () => {
69-
it('array-link', (done) => {
129+
it.skip('array-link', (done) => {
70130
dagCBOR.util.serialize(arrayLinkJSON, (err, serialized) => {
71131
expect(err).to.not.exist
72132

@@ -78,9 +138,21 @@ describe.only('dag-cbor interop tests', () => {
78138
})
79139
})
80140

81-
it.skip('empty-array', (done) => {})
141+
it('empty-array', (done) => {
142+
dagCBOR.util.serialize(emptyArrayJSON, (err, serialized) => {
143+
expect(err).to.not.exist
144+
expect(serialized).to.eql(emptyArrayCBOR)
145+
done()
146+
})
147+
})
82148

83-
it.skip('empty-obj', (done) => {})
149+
it('empty-obj', (done) => {
150+
dagCBOR.util.serialize(emptyObjJSON, (err, serialized) => {
151+
expect(err).to.not.exist
152+
expect(serialized).to.eql(emptyObjCBOR)
153+
done()
154+
})
155+
})
84156

85157
it.skip('foo', (done) => {})
86158

0 commit comments

Comments
 (0)