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

Commit

Permalink
fix: make tests consistent across js-ipfs/go-ipfs (#158)
Browse files Browse the repository at this point in the history
* feat: add progress bar tests

* feat: fixing progress bar tests

* fix: consistent tests across js-ipfs and go-ipfs progress

* fix: rename progress acumulators for clarity
  • Loading branch information
dryajov authored and daviddias committed Oct 18, 2017
1 parent 5954440 commit a5a4c37
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/files.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,20 +127,20 @@ module.exports = (common) => {
const expectedMultihash = 'Qme79tX2bViL26vNjPsF3DP1R9rMKMvnPYJiKTTKPrXJjq'

let progCount = 0
let progress = 0
let accumProgress = 0
const handler = (p) => {
progCount += 1
progress += p
accumProgress = p
}

ipfs.files.add(bigFile, {progress: handler}, (err, res) => {
ipfs.files.add(bigFile, { progress: handler }, (err, res) => {
expect(err).to.not.exist()
expect(res).to.have.length(1)
const file = res[0]
expect(file.hash).to.equal(expectedMultihash)
expect(file.path).to.equal(file.hash)
expect(progCount).to.equal(58)
expect(progress).to.equal(bigFile.byteLength)
expect(accumProgress).to.equal(bigFile.byteLength)
done()
})
})
Expand Down Expand Up @@ -214,20 +214,20 @@ module.exports = (common) => {
}, 0)

let progCount = 0
let progress = 0
let accumProgress = 0
const handler = (p) => {
progCount += 1
progress += p
accumProgress += p
}

ipfs.files.add(dirs, {progress: handler}, (err, res) => {
ipfs.files.add(dirs, { progress: handler }, (err, res) => {
expect(err).to.not.exist()
const root = res[res.length - 1]

expect(root.path).to.equal('test-folder')
expect(root.hash).to.equal(expectedRootMultihash)
expect(progCount).to.equal(8)
expect(progress).to.equal(total)
expect(accumProgress).to.be.at.least(total)
done()
})
})
Expand Down

0 comments on commit a5a4c37

Please sign in to comment.