@@ -6,6 +6,7 @@ chai.use(require('dirty-chai'))
66const expect = chai . expect
77const Block = require ( 'ipfs-block' )
88const CID = require ( 'cids' )
9+ const prettyBytes = require ( 'pretty-bytes' )
910
1011module . exports = ( repo ) => {
1112 describe ( 'stat' , ( ) => {
@@ -33,18 +34,23 @@ module.exports = (repo) => {
3334 } )
3435
3536 it ( 'get human stats' , async ( ) => {
36- const stats = await repo . stat ( { human : true } )
37- expect ( stats ) . to . exist ( )
38- expect ( stats ) . to . have . property ( 'numObjects' )
39- expect ( stats ) . to . have . property ( 'version' )
40- expect ( stats ) . to . have . property ( 'repoPath' )
41- expect ( stats ) . to . have . property ( 'repoSize' )
42- expect ( stats ) . to . have . property ( 'storageMax' )
37+ const { repoSize, storageMax } = await repo . stat ( )
4338
44- expect ( stats . numObjects > '0' ) . to . eql ( true )
45- expect ( stats . version > '0' ) . to . eql ( true )
46- expect ( stats . repoSize > '0' ) . to . eql ( true )
47- expect ( stats . storageMax > '0' ) . to . eql ( true )
39+ const humanizedRepoSize = prettyBytes ( repoSize . toNumber ( ) ) . toUpperCase ( )
40+ const humanizedStorageMax = prettyBytes ( storageMax . toNumber ( ) ) . toUpperCase ( )
41+
42+ const humanizedStats = await repo . stat ( { human : true } )
43+
44+ expect ( humanizedStats ) . to . exist ( )
45+ expect ( humanizedStats ) . to . have . property ( 'numObjects' )
46+ expect ( humanizedStats ) . to . have . property ( 'version' ) . and . be . above ( 0 )
47+ expect ( humanizedStats ) . to . have . property ( 'repoPath' )
48+ expect ( humanizedStats ) . to . have . property ( 'repoSize' ) . that . equals ( humanizedRepoSize )
49+ expect ( humanizedStats ) . to . have . property ( 'storageMax' ) . that . equals ( humanizedStorageMax )
50+
51+ expect ( humanizedStats . numObjects > '0' ) . to . eql ( true )
52+ expect ( humanizedStats . repoSize > '0' ) . to . eql ( true )
53+ expect ( humanizedStats . storageMax > '0' ) . to . eql ( true )
4854 } )
4955 } )
5056}
0 commit comments