@@ -9,7 +9,8 @@ const loadFixture = require('aegir/fixtures')
9
9
10
10
const {
11
11
createMfs,
12
- EMPTY_DIRECTORY_HASH
12
+ EMPTY_DIRECTORY_HASH ,
13
+ EMPTY_DIRECTORY_HASH_BASE32
13
14
} = require ( './helpers' )
14
15
15
16
describe ( 'stat' , function ( ) {
@@ -86,6 +87,20 @@ describe('stat', function () {
86
87
} )
87
88
} )
88
89
90
+ it ( 'returns only a base32 hash' , ( ) => {
91
+ const path = `/directory-${ Math . random ( ) } `
92
+
93
+ return mfs . mkdir ( path )
94
+ . then ( ( ) => mfs . stat ( path , {
95
+ hash : true ,
96
+ cidBase : 'base32'
97
+ } ) )
98
+ . then ( stats => {
99
+ expect ( Object . keys ( stats ) . length ) . to . equal ( 1 )
100
+ expect ( stats . hash ) . to . equal ( EMPTY_DIRECTORY_HASH_BASE32 )
101
+ } )
102
+ } )
103
+
89
104
it ( 'returns only the size' , ( ) => {
90
105
const path = `/directory-${ Math . random ( ) } `
91
106
@@ -134,4 +149,23 @@ describe('stat', function () {
134
149
expect ( stats . type ) . to . equal ( 'file' )
135
150
} )
136
151
} )
152
+
153
+ it ( 'stats a large file with base32' , ( ) => {
154
+ const filePath = '/stat/large-file.txt'
155
+
156
+ return mfs . write ( filePath , largeFile , {
157
+ create : true ,
158
+ parents : true
159
+ } )
160
+ . then ( ( ) => mfs . stat ( filePath , {
161
+ cidBase : 'base32'
162
+ } ) )
163
+ . then ( ( stats ) => {
164
+ expect ( stats . hash . startsWith ( 'b' ) ) . to . equal ( true )
165
+ expect ( stats . size ) . to . equal ( largeFile . length )
166
+ expect ( stats . cumulativeSize ) . to . equal ( 490800 )
167
+ expect ( stats . blocks ) . to . equal ( 2 )
168
+ expect ( stats . type ) . to . equal ( 'file' )
169
+ } )
170
+ } )
137
171
} )
0 commit comments