11/* eslint-env mocha */
22'use strict'
33
4- const expect = require ( 'chai' ) . expect
4+ const chai = require ( 'chai' )
5+ chai . use ( require ( 'dirty-chai' ) )
6+ const expect = chai . expect
57const loadFixture = require ( 'aegir/fixtures' )
68
79const UnixFS = require ( '../src' )
@@ -10,10 +12,11 @@ const raw = loadFixture(__dirname, 'fixtures/raw.unixfs')
1012const directory = loadFixture ( __dirname , 'fixtures/directory.unixfs' )
1113const file = loadFixture ( __dirname , 'fixtures/file.txt.unixfs' )
1214const symlink = loadFixture ( __dirname , 'fixtures/symlink.txt.unixfs' )
15+ const Buffer = require ( 'safe-buffer' ) . Buffer
1316
1417describe ( 'unixfs-format' , ( ) => {
1518 it ( 'raw' , ( done ) => {
16- const data = new UnixFS ( 'raw' , new Buffer ( 'bananas' ) )
19+ const data = new UnixFS ( 'raw' , Buffer . from ( 'bananas' ) )
1720 const marsheled = data . marshal ( )
1821 const unmarsheled = UnixFS . unmarshal ( marsheled )
1922 expect ( data . type ) . to . equal ( unmarsheled . type )
@@ -100,16 +103,16 @@ describe('unixfs-format', () => {
100103 try {
101104 data = new UnixFS ( 'bananas' )
102105 } catch ( err ) {
103- expect ( err ) . to . exist
104- expect ( data ) . to . not . exist
106+ expect ( err ) . to . exist ( )
107+ expect ( data ) . to . not . exist ( )
105108 done ( )
106109 }
107110 } )
108111
109112 describe ( 'interop' , ( ) => {
110113 it ( 'raw' , ( done ) => {
111114 const unmarsheled = UnixFS . unmarshal ( raw )
112- expect ( unmarsheled . data ) . to . deep . equal ( new Buffer ( 'Hello UnixFS\n' ) )
115+ expect ( unmarsheled . data ) . to . eql ( Buffer . from ( 'Hello UnixFS\n' ) )
113116 expect ( unmarsheled . type ) . to . equal ( 'file' )
114117 expect ( unmarsheled . marshal ( ) ) . to . deep . equal ( raw )
115118 done ( )
@@ -125,7 +128,7 @@ describe('unixfs-format', () => {
125128
126129 it ( 'file' , ( done ) => {
127130 const unmarsheled = UnixFS . unmarshal ( file )
128- expect ( unmarsheled . data ) . to . deep . equal ( new Buffer ( 'Hello UnixFS\n' ) )
131+ expect ( unmarsheled . data ) . to . deep . equal ( Buffer . from ( 'Hello UnixFS\n' ) )
129132 expect ( unmarsheled . type ) . to . equal ( 'file' )
130133 expect ( unmarsheled . marshal ( ) ) . to . deep . equal ( file )
131134 done ( )
@@ -136,7 +139,7 @@ describe('unixfs-format', () => {
136139
137140 it ( 'symlink' , ( done ) => {
138141 const unmarsheled = UnixFS . unmarshal ( symlink )
139- expect ( unmarsheled . data ) . to . deep . equal ( new Buffer ( 'file.txt' ) )
142+ expect ( unmarsheled . data ) . to . deep . equal ( Buffer . from ( 'file.txt' ) )
140143 expect ( unmarsheled . type ) . to . equal ( 'symlink' )
141144 // TODO: waiting on https://github.com/ipfs/js-ipfs-data-importing/issues/3#issuecomment-182440079
142145 // expect(unmarsheled.marshal()).to.deep.equal(symlink)
0 commit comments