4
4
const expect = require ( 'chai' ) . expect
5
5
const dagCBOR = require ( '../src' )
6
6
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' )
9
9
10
10
const CID = require ( 'cids' )
11
11
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' )
14
14
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' )
17
17
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' )
19
31
20
32
describe . only ( 'dag-cbor interop tests' , ( ) => {
21
33
describe ( 'deserialize and compare' , ( ) => {
@@ -42,11 +54,47 @@ describe.only('dag-cbor interop tests', () => {
42
54
} )
43
55
} )
44
56
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 )
46
61
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
+ } )
48
70
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
+ } )
50
98
51
99
it ( 'obj-no-link' , ( done ) => {
52
100
dagCBOR . util . deserialize ( objNoLinkCBOR , ( err , node ) => {
@@ -62,11 +110,23 @@ describe.only('dag-cbor interop tests', () => {
62
110
} )
63
111
} )
64
112
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
+ } )
66
126
} )
67
127
68
128
describe ( 'serialise and compare' , ( ) => {
69
- it ( 'array-link' , ( done ) => {
129
+ it . skip ( 'array-link' , ( done ) => {
70
130
dagCBOR . util . serialize ( arrayLinkJSON , ( err , serialized ) => {
71
131
expect ( err ) . to . not . exist
72
132
@@ -78,9 +138,21 @@ describe.only('dag-cbor interop tests', () => {
78
138
} )
79
139
} )
80
140
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
+ } )
82
148
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
+ } )
84
156
85
157
it . skip ( 'foo' , ( done ) => { } )
86
158
0 commit comments