1
1
/* eslint-env mocha */
2
2
'use strict'
3
3
4
- const expect = require ( 'chai' ) . expect
4
+ const chai = require ( 'chai' )
5
+ chai . use ( require ( 'dirty-chai' ) )
6
+ const expect = chai . expect
5
7
const loadFixture = require ( 'aegir/fixtures' )
6
8
7
9
const UnixFS = require ( '../src' )
@@ -10,10 +12,11 @@ const raw = loadFixture(__dirname, 'fixtures/raw.unixfs')
10
12
const directory = loadFixture ( __dirname , 'fixtures/directory.unixfs' )
11
13
const file = loadFixture ( __dirname , 'fixtures/file.txt.unixfs' )
12
14
const symlink = loadFixture ( __dirname , 'fixtures/symlink.txt.unixfs' )
15
+ const Buffer = require ( 'safe-buffer' ) . Buffer
13
16
14
17
describe ( 'unixfs-format' , ( ) => {
15
18
it ( 'raw' , ( done ) => {
16
- const data = new UnixFS ( 'raw' , new Buffer ( 'bananas' ) )
19
+ const data = new UnixFS ( 'raw' , Buffer . from ( 'bananas' ) )
17
20
const marsheled = data . marshal ( )
18
21
const unmarsheled = UnixFS . unmarshal ( marsheled )
19
22
expect ( data . type ) . to . equal ( unmarsheled . type )
@@ -100,16 +103,16 @@ describe('unixfs-format', () => {
100
103
try {
101
104
data = new UnixFS ( 'bananas' )
102
105
} catch ( err ) {
103
- expect ( err ) . to . exist
104
- expect ( data ) . to . not . exist
106
+ expect ( err ) . to . exist ( )
107
+ expect ( data ) . to . not . exist ( )
105
108
done ( )
106
109
}
107
110
} )
108
111
109
112
describe ( 'interop' , ( ) => {
110
113
it ( 'raw' , ( done ) => {
111
114
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' ) )
113
116
expect ( unmarsheled . type ) . to . equal ( 'file' )
114
117
expect ( unmarsheled . marshal ( ) ) . to . deep . equal ( raw )
115
118
done ( )
@@ -125,7 +128,7 @@ describe('unixfs-format', () => {
125
128
126
129
it ( 'file' , ( done ) => {
127
130
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' ) )
129
132
expect ( unmarsheled . type ) . to . equal ( 'file' )
130
133
expect ( unmarsheled . marshal ( ) ) . to . deep . equal ( file )
131
134
done ( )
@@ -136,7 +139,7 @@ describe('unixfs-format', () => {
136
139
137
140
it ( 'symlink' , ( done ) => {
138
141
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' ) )
140
143
expect ( unmarsheled . type ) . to . equal ( 'symlink' )
141
144
// TODO: waiting on https://github.com/ipfs/js-ipfs-data-importing/issues/3#issuecomment-182440079
142
145
// expect(unmarsheled.marshal()).to.deep.equal(symlink)
0 commit comments