2
2
'use strict'
3
3
4
4
const expect = require ( 'chai' ) . expect
5
+ const multihash = require ( 'multihashes' )
5
6
6
7
module . exports = ( ctl ) => {
7
8
describe ( '.block' , ( ) => {
8
9
describe ( '.put' , ( ) => {
9
10
it ( 'updates value' , ( done ) => {
10
- const filePath = 'test/test-data/ hello'
11
+ const data = new Buffer ( ' hello world\n' )
11
12
const expectedResult = {
12
- Key : 'QmZjTnYw2TFhn9Nn7tjmPSoTBoY7YRkwPzwSrSbabY24Kp' ,
13
- Size : 12
13
+ key : 'QmZjTnYw2TFhn9Nn7tjmPSoTBoY7YRkwPzwSrSbabY24Kp' ,
14
+ size : 12
14
15
}
15
16
16
- ctl . block . put ( filePath , ( err , res ) => {
17
+ ctl . block . put ( data , ( err , block ) => {
17
18
expect ( err ) . not . to . exist
18
- expect ( res ) . to . deep . equal ( expectedResult )
19
+ expect ( block . key ) . to . deep . equal ( multihash . fromB58String ( expectedResult . key ) )
19
20
done ( )
20
21
} )
21
22
} )
@@ -39,7 +40,7 @@ module.exports = (ctl) => {
39
40
it ( 'returns value' , ( done ) => {
40
41
ctl . block . get ( 'QmZjTnYw2TFhn9Nn7tjmPSoTBoY7YRkwPzwSrSbabY24Kp' , ( err , result ) => {
41
42
expect ( err ) . to . not . exist
42
- expect ( result . toString ( ) )
43
+ expect ( result . data . toString ( ) )
43
44
. to . equal ( 'hello world\n' )
44
45
done ( )
45
46
} )
@@ -64,9 +65,9 @@ module.exports = (ctl) => {
64
65
it ( 'returns value' , ( done ) => {
65
66
ctl . block . stat ( 'QmZjTnYw2TFhn9Nn7tjmPSoTBoY7YRkwPzwSrSbabY24Kp' , ( err , result ) => {
66
67
expect ( err ) . to . not . exist
67
- expect ( result . Key )
68
+ expect ( result . key )
68
69
. to . equal ( 'QmZjTnYw2TFhn9Nn7tjmPSoTBoY7YRkwPzwSrSbabY24Kp' )
69
- expect ( result . Size ) . to . equal ( 12 )
70
+ expect ( result . size ) . to . equal ( 12 )
70
71
done ( )
71
72
} )
72
73
} )
0 commit comments