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