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

Commit

Permalink
resolves #193 test that handler was called not specific number of tim…
Browse files Browse the repository at this point in the history
…es it was called (#194)
  • Loading branch information
alanshaw authored and daviddias committed Jan 5, 2018
1 parent 36674d9 commit c677526
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/files.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,10 @@ module.exports = (common) => {
})

it('a BIG buffer with progress enabled', (done) => {
let progCount = 0
let progCalled = false
let accumProgress = 0
function handler (p) {
progCount += 1
progCalled = true
accumProgress = p
}

Expand All @@ -112,7 +112,7 @@ module.exports = (common) => {
expect(file.hash).to.equal(bigFile.cid)
expect(file.path).to.equal(bigFile.cid)

expect(progCount).to.equal(58)
expect(progCalled).to.be.true()
expect(accumProgress).to.equal(bigFile.data.length)
done()
})
Expand Down Expand Up @@ -223,18 +223,18 @@ module.exports = (common) => {
return i + (entry.content ? entry.content.length : 0)
}, 0)

let progCount = 0
let progCalled = false
let accumProgress = 0
const handler = (p) => {
progCount += 1
progCalled = true
accumProgress += p
}

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

expect(progCount).to.equal(8)
expect(progCalled).to.be.true()
expect(accumProgress).to.be.at.least(total)
expect(root.path).to.equal('test-folder')
expect(root.hash).to.equal(directory.cid)
Expand Down

0 comments on commit c677526

Please sign in to comment.