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

Commit 7d28a31

Browse files
committed
Load test directory /w browser support.
1 parent cd8a159 commit 7d28a31

File tree

1 file changed

+14
-20
lines changed

1 file changed

+14
-20
lines changed

src/files.js

Lines changed: 14 additions & 20 deletions
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
@@ -100,15 +107,9 @@ module.exports = (common) => {
100107
})
101108

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

156157
describe('.createAddStream', () => {
157158
it('stream of valid files and dirs', (done) => {
158-
if (!isNode) {
159-
return done()
160-
// can't run this test cause browserify
161-
// can't shim readFileSync in runtime
162-
}
163-
164-
const base = path.join(__dirname, 'data/test-folder')
165159
const content = (name) => ({
166160
path: `test-folder/${name}`,
167-
content: fs.readFileSync(path.join(base, name))
161+
content: directoryContent[name]
168162
})
169163
const emptyDir = (name) => ({
170164
path: `test-folder/${name}`

0 commit comments

Comments
 (0)