1
1
/* eslint-env mocha */
2
2
'use strict'
3
3
4
- const { Buffer } = require ( 'buffer' )
5
- const chai = require ( 'chai' )
6
- chai . use ( require ( 'dirty-chai' ) )
7
- const expect = chai . expect
4
+ const { expect } = require ( 'aegir/utils/chai' )
8
5
const IPLD = require ( 'ipld' )
9
6
const inMemory = require ( 'ipld-in-memory' )
10
7
const importer = require ( 'ipfs-unixfs-importer' )
@@ -13,6 +10,7 @@ const all = require('it-all')
13
10
const last = require ( 'it-last' )
14
11
const blockApi = require ( './helpers/block' )
15
12
const randomBytes = require ( 'it-buffer-stream' )
13
+ const uint8ArrayConcat = require ( 'uint8arrays/concat' )
16
14
17
15
const ONE_MEG = Math . pow ( 1024 , 2 )
18
16
@@ -28,7 +26,7 @@ describe('exporter subtree', () => {
28
26
} )
29
27
30
28
it ( 'exports a file 2 levels down' , async ( ) => {
31
- const content = Buffer . concat ( await all ( randomBytes ( ONE_MEG ) ) )
29
+ const content = uint8ArrayConcat ( await all ( randomBytes ( ONE_MEG ) ) )
32
30
33
31
const imported = await last ( importer ( [ {
34
32
path : './200Bytes.txt' ,
@@ -44,12 +42,12 @@ describe('exporter subtree', () => {
44
42
expect ( exported . name ) . to . equal ( '200Bytes.txt' )
45
43
expect ( exported . path ) . to . equal ( `${ imported . cid . toBaseEncodedString ( ) } /level-1/200Bytes.txt` )
46
44
47
- const data = Buffer . concat ( await all ( exported . content ( ) ) )
45
+ const data = uint8ArrayConcat ( await all ( exported . content ( ) ) )
48
46
expect ( data ) . to . deep . equal ( content )
49
47
} )
50
48
51
49
it ( 'exports a directory 1 level down' , async ( ) => {
52
- const content = Buffer . concat ( await all ( randomBytes ( ONE_MEG ) ) )
50
+ const content = uint8ArrayConcat ( await all ( randomBytes ( ONE_MEG ) ) )
53
51
const imported = await last ( importer ( [ {
54
52
path : './200Bytes.txt' ,
55
53
content : randomBytes ( ONE_MEG )
@@ -70,7 +68,7 @@ describe('exporter subtree', () => {
70
68
expect ( files [ 1 ] . name ) . to . equal ( 'level-2' )
71
69
expect ( files [ 1 ] . path ) . to . equal ( `${ imported . cid . toBaseEncodedString ( ) } /level-1/level-2` )
72
70
73
- const data = Buffer . concat ( await all ( files [ 0 ] . content ( ) ) )
71
+ const data = uint8ArrayConcat ( await all ( files [ 0 ] . content ( ) ) )
74
72
expect ( data ) . to . deep . equal ( content )
75
73
} )
76
74
@@ -88,7 +86,7 @@ describe('exporter subtree', () => {
88
86
} )
89
87
90
88
it ( 'exports starting from non-protobuf node' , async ( ) => {
91
- const content = Buffer . concat ( await all ( randomBytes ( ONE_MEG ) ) )
89
+ const content = uint8ArrayConcat ( await all ( randomBytes ( ONE_MEG ) ) )
92
90
93
91
const imported = await last ( importer ( [ {
94
92
path : './level-1/200Bytes.txt' ,
@@ -108,12 +106,12 @@ describe('exporter subtree', () => {
108
106
expect ( exported . name ) . to . equal ( '200Bytes.txt' )
109
107
expect ( exported . path ) . to . equal ( `${ cborNodeCid . toBaseEncodedString ( ) } /a/file/level-1/200Bytes.txt` )
110
108
111
- const data = Buffer . concat ( await all ( exported . content ( ) ) )
109
+ const data = uint8ArrayConcat ( await all ( exported . content ( ) ) )
112
110
expect ( data ) . to . deep . equal ( content )
113
111
} )
114
112
115
113
it ( 'uses .path to export all components of a path' , async ( ) => {
116
- const content = Buffer . concat ( await all ( randomBytes ( ONE_MEG ) ) )
114
+ const content = uint8ArrayConcat ( await all ( randomBytes ( ONE_MEG ) ) )
117
115
118
116
const imported = await last ( importer ( [ {
119
117
path : './200Bytes.txt' ,
0 commit comments