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

Commit 8463441

Browse files
committed
Clean up files tests.
1 parent 8c5eeb5 commit 8463441

File tree

1 file changed

+19
-19
lines changed

1 file changed

+19
-19
lines changed

test/files.js

+19-19
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,26 @@ const Readable = require('readable-stream')
99
const path = require('path')
1010
const isNode = require('detect-node')
1111

12-
let testfile
13-
let testfileBig
14-
const testfilePath = path.join(__dirname, './data/testfile.txt')
15-
16-
if (isNode) {
17-
const fs = require('fs')
18-
testfile = fs.readFileSync(testfilePath)
19-
testfileBig = fs.createReadStream(path.join(__dirname, './data/15mb.random'), { bufferSize: 128 })
20-
} else {
21-
testfile = require('raw!./data/testfile.txt')
22-
}
23-
2412
module.exports = (common) => {
2513
describe('.files/add', () => {
14+
let testfile
15+
let testfileBig
2616
let ipfs
2717

2818
before((done) => {
19+
// load test data
20+
if (isNode) {
21+
const fs = require('fs')
22+
23+
const testfilePath = path.join(__dirname, './data/testfile.txt')
24+
testfile = fs.readFileSync(testfilePath)
25+
26+
const testfileBigPath = path.join(__dirname, './data/15mb.random')
27+
testfileBig = fs.createReadStream(testfileBigPath, { bufferSize: 128 })
28+
} else {
29+
testfile = require('raw!./data/testfile.txt')
30+
}
31+
2932
common.setup((err, _ipfs) => {
3033
expect(err).to.not.exist
3134
ipfs = _ipfs
@@ -101,9 +104,10 @@ module.exports = (common) => {
101104
expect(err).to.not.exist
102105

103106
expect(res).to.have.length(1)
104-
const mh = bs58.encode(res[0].node.multihash()).toString()
105-
expect(mh).to.equal('Qmcx5werSWQPdrGVap7LARHB4QUSPRPJwxhFuHvdoXqQXT')
106107
expect(res[0].node.links).to.have.length(58)
108+
const mh = bs58.encode(res[0].node.multihash()).toString()
109+
expect(res[0].path).to.equal(mh)
110+
expect(mh).to.equal('Qme79tX2bViL26vNjPsF3DP1R9rMKMvnPYJiKTTKPrXJjq')
107111
done()
108112
})
109113
})
@@ -123,13 +127,9 @@ module.exports = (common) => {
123127
content('alice.txt'),
124128
content('files/hello.txt'),
125129
content('files/ipfs.txt'),
126-
{
127-
path: 'test-folder',
128-
dir: true
129-
}
130130
]
131131

132-
ipfs.files.add(dirs, { recursive: true }, (err, res) => {
132+
ipfs.files.add(dirs, (err, res) => {
133133
expect(err).to.not.exist
134134

135135
const added = res[res.length - 1]

0 commit comments

Comments
 (0)