@@ -7,6 +7,7 @@ const Readable = require('stream').Readable
77const path = require ( 'path' )
88const isNode = require ( 'detect-node' )
99const fs = require ( 'fs' )
10+ const bs58 = require ( 'bs58' )
1011
1112const testfileBig = fs . readFileSync ( path . join ( __dirname , '/../15mb.random' ) )
1213const testfile = fs . readFileSync ( path . join ( __dirname , '/../testfile.txt' ) )
@@ -26,8 +27,9 @@ describe('.add', () => {
2627 expect ( err ) . to . not . exist
2728
2829 const added = res [ 0 ] != null ? res [ 0 ] : res
29- expect ( added ) . to . have . property ( 'Hash' , 'Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP' )
30- expect ( added ) . to . have . property ( 'Name' , 'testfile.txt' )
30+ const mh = bs58 . encode ( added . multihash ( ) ) . toString ( )
31+ expect ( mh ) . to . equal ( 'Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP' )
32+ expect ( added . links ) . to . have . length ( 0 )
3133 done ( )
3234 } )
3335 } )
@@ -38,7 +40,9 @@ describe('.add', () => {
3840 expect ( err ) . to . not . exist
3941
4042 expect ( res ) . to . have . length ( 1 )
41- expect ( res [ 0 ] ) . to . have . property ( 'Hash' , 'Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP' )
43+ const mh = bs58 . encode ( res [ 0 ] . multihash ( ) ) . toString ( )
44+ expect ( mh ) . to . equal ( 'Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP' )
45+ expect ( res [ 0 ] . links ) . to . have . length ( 0 )
4246 done ( )
4347 } )
4448 } )
@@ -52,7 +56,9 @@ describe('.add', () => {
5256 expect ( err ) . to . not . exist
5357
5458 expect ( res ) . to . have . length ( 1 )
55- expect ( res [ 0 ] ) . to . have . a . property ( 'Hash' , 'Qme79tX2bViL26vNjPsF3DP1R9rMKMvnPYJiKTTKPrXJjq' )
59+ const mh = bs58 . encode ( res [ 0 ] . multihash ( ) ) . toString ( )
60+ expect ( mh ) . to . equal ( 'Qmcx5werSWQPdrGVap7LARHB4QUSPRPJwxhFuHvdoXqQXT' )
61+ expect ( res [ 0 ] . links ) . to . have . length ( 58 )
5662 done ( )
5763 } )
5864 } )
@@ -66,7 +72,9 @@ describe('.add', () => {
6672 expect ( err ) . to . not . exist
6773
6874 const added = res [ 0 ] != null ? res [ 0 ] : res
69- expect ( added ) . to . have . property ( 'Hash' , 'Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP' )
75+ const mh = bs58 . encode ( added . multihash ( ) ) . toString ( )
76+ expect ( mh ) . to . equal ( 'Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP' )
77+ expect ( added . links ) . to . have . length ( 0 )
7078 done ( )
7179 } )
7280 } )
@@ -77,14 +85,9 @@ describe('.add', () => {
7785 expect ( err ) . to . not . exist
7886
7987 const added = res [ res . length - 1 ]
80- expect ( added ) . to . have . property ( 'Hash' , 'QmRNjDeKStKGTQXnJ2NFqeQ9oW23WcpbmvCVrpDHgDg3T6' )
81-
82- // check that the symlink was replaced by the target file
83- const linkPath = 'test-folder/hello-link'
84- const filePath = 'test-folder/files/hello.txt'
85- const linkHash = res . filter ( ( e ) => e . Name === linkPath ) [ 0 ] . Hash
86- const fileHash = res . filter ( ( e ) => e . Name === filePath ) [ 0 ] . Hash
87- expect ( linkHash ) . to . equal ( fileHash )
88+ const mh = bs58 . encode ( added . multihash ( ) ) . toString ( )
89+ expect ( mh ) . to . equal ( 'QmRNjDeKStKGTQXnJ2NFqeQ9oW23WcpbmvCVrpDHgDg3T6' )
90+ expect ( added . links ) . to . have . length ( 7 )
8891
8992 done ( )
9093 } else {
@@ -101,7 +104,9 @@ describe('.add', () => {
101104
102105 const added = res [ res . length - 1 ]
103106 // same hash as the result from the cli (ipfs add test/test-folder -r)
104- expect ( added ) . to . have . property ( 'Hash' , 'QmRArDYd8Rk7Zb7K2699KqmQM1uUoejn1chtEAcqkvjzGg' )
107+ const mh = bs58 . encode ( added . multihash ( ) ) . toString ( )
108+ expect ( mh ) . to . equal ( 'QmRArDYd8Rk7Zb7K2699KqmQM1uUoejn1chtEAcqkvjzGg' )
109+ expect ( added . links ) . to . have . length ( 7 )
105110 done ( )
106111 } else {
107112 expect ( err . message ) . to . be . equal ( 'Recursive uploads are not supported in the browser' )
@@ -137,7 +142,9 @@ describe('.add', () => {
137142 expect ( err ) . to . not . exist
138143
139144 const added = res [ res . length - 1 ]
140- expect ( added ) . to . have . property ( 'Hash' , 'QmTDH2RXGn8XyDAo9YyfbZAUXwL1FCr44YJCN9HBZmL9Gj' )
145+ const mh = bs58 . encode ( added . multihash ( ) ) . toString ( )
146+ expect ( mh ) . to . equal ( 'QmTDH2RXGn8XyDAo9YyfbZAUXwL1FCr44YJCN9HBZmL9Gj' )
147+ expect ( added . links ) . to . have . length ( 6 )
141148 done ( )
142149 } )
143150 } )
@@ -151,7 +158,9 @@ describe('.add', () => {
151158 expect ( err ) . to . not . exist
152159
153160 const added = res [ 0 ] != null ? res [ 0 ] : res
154- expect ( added ) . to . have . a . property ( 'Hash' , 'QmNRCQWfgze6AbBCaT1rkrkV5tJ2aP4oTNPb5JZcXYywve' )
161+ const mh = bs58 . encode ( added . multihash ( ) ) . toString ( )
162+ expect ( mh ) . to . equal ( 'QmNRCQWfgze6AbBCaT1rkrkV5tJ2aP4oTNPb5JZcXYywve' )
163+ expect ( added . links ) . to . have . length ( 0 )
155164 done ( )
156165 } )
157166 } )
@@ -162,7 +171,9 @@ describe('.add', () => {
162171 expect ( err ) . to . not . exist
163172
164173 const added = res [ 0 ] != null ? res [ 0 ] : res
165- expect ( added ) . to . have . a . property ( 'Hash' , 'QmZmHgEX9baxUn3qMjsEXQzG6DyNcrVnwieQQTrpDdrFvt' )
174+ const mh = bs58 . encode ( added . multihash ( ) ) . toString ( )
175+ expect ( mh ) . to . equal ( 'QmRzvSX35JpzQ2Lyn55r3YwWqdVP6PPxYHFpiWpwQTff8A' )
176+ expect ( added . links ) . to . have . length ( 0 )
166177 done ( )
167178 } )
168179 } )
@@ -172,8 +183,10 @@ describe('.add', () => {
172183 let buf = new Buffer ( testfile )
173184 return apiClients . a . add ( buf )
174185 . then ( ( res ) => {
175- expect ( res ) . to . have . length ( 1 )
176- expect ( res [ 0 ] ) . to . have . property ( 'Hash' , 'Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP' )
186+ const added = res [ 0 ] != null ? res [ 0 ] : res
187+ const mh = bs58 . encode ( added . multihash ( ) ) . toString ( )
188+ expect ( mh ) . to . equal ( 'Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP' )
189+ expect ( added . links ) . to . have . length ( 0 )
177190 } )
178191 } )
179192 } )
0 commit comments