Skip to content
This repository was archived by the owner on Mar 10, 2020. It is now read-only.

Commit 46fa99a

Browse files
committed
Load test directory /w browser support.
1 parent 962a0f8 commit 46fa99a

File tree

1 file changed

+14
-22
lines changed

1 file changed

+14
-22
lines changed

src/files.js

+14-22
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,23 @@ const concat = require('concat-stream')
1111
const through = require('through2')
1212

1313
module.exports = (common) => {
14-
describe('.files', () => {
14+
describe.only('.files', () => {
1515
let smallFile
1616
let bigFile
17+
let directoryContent
1718
let ipfs
1819

1920
before((done) => {
20-
smallFile = fs.readFileSync(path.join(__dirname, './data/testfile.txt')
21-
)
22-
bigFile = fs.readFileSync(path.join(__dirname, './data/15mb.random')
23-
)
21+
smallFile = fs.readFileSync(path.join(__dirname, './data/testfile.txt'))
22+
bigFile = fs.readFileSync(path.join(__dirname, './data/15mb.random'))
23+
directoryContent = {
24+
'pp.txt': fs.readFileSync(path.join(__dirname, './data/test-folder/pp.txt')),
25+
'holmes.txt': fs.readFileSync(path.join(__dirname, './data/test-folder/holmes.txt')),
26+
'jungle.txt': fs.readFileSync(path.join(__dirname, './data/test-folder/jungle.txt')),
27+
'alice.txt': fs.readFileSync(path.join(__dirname, './data/test-folder/alice.txt')),
28+
'files/hello.txt': fs.readFileSync(path.join(__dirname, './data/test-folder/files/hello.txt')),
29+
'files/ipfs.txt': fs.readFileSync(path.join(__dirname, './data/test-folder/files/ipfs.txt')),
30+
}
2431

2532
common.setup((err, _ipfs) => {
2633
expect(err).to.not.exist
@@ -101,15 +108,9 @@ module.exports = (common) => {
101108
})
102109

103110
it('add a nested dir as array', (done) => {
104-
if (!isNode) {
105-
return done()
106-
// can't run this test cause browserify
107-
// can't shim readFileSync in runtime
108-
}
109-
const base = path.join(__dirname, 'data/test-folder')
110111
const content = (name) => ({
111112
path: `test-folder/${name}`,
112-
content: fs.readFileSync(path.join(base, name))
113+
content: directoryContent[name]
113114
})
114115
const emptyDir = (name) => ({
115116
path: `test-folder/${name}`
@@ -139,16 +140,9 @@ module.exports = (common) => {
139140

140141
describe('.createAddStream', () => {
141142
it('stream of valid files and dirs', (done) => {
142-
if (!isNode) {
143-
return done()
144-
// can't run this test cause browserify
145-
// can't shim readFileSync in runtime
146-
}
147-
148-
const base = path.join(__dirname, 'data/test-folder')
149143
const content = (name) => ({
150144
path: `test-folder/${name}`,
151-
content: fs.readFileSync(path.join(base, name))
145+
content: directoryContent[name]
152146
})
153147
const emptyDir = (name) => ({
154148
path: `test-folder/${name}`
@@ -175,13 +169,11 @@ module.exports = (common) => {
175169
expect(tuple.node.links).to.have.length(6)
176170
}
177171
})
178-
179172
stream.on('end', done)
180173

181174
files.forEach((file) => {
182175
stream.write(file)
183176
})
184-
185177
stream.end()
186178
})
187179
})

0 commit comments

Comments
 (0)