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

Adds call to progress bar function #179

Merged
merged 6 commits into from
Sep 5, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
adds test for optional progress function
  • Loading branch information
bmordan committed Sep 4, 2017
commit b24de1775aa300f014eebaf3bcf605c0ff84f717
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
"pull-generate": "^2.2.0",
"pull-zip": "^2.0.1",
"rimraf": "^2.6.1",
"sinon": "^3.2.1",
"split": "^1.0.0"
},
"dependencies": {
Expand Down Expand Up @@ -90,4 +91,4 @@
"jbenet <juan@benet.ai>",
"nginnever <ginneversource@gmail.com>"
]
}
}
32 changes: 32 additions & 0 deletions test/test-importer.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const extend = require('deep-extend')
const chai = require('chai')
chai.use(require('dirty-chai'))
const expect = chai.expect
const sinon = require('sinon')
const BlockService = require('ipfs-block-service')
const pull = require('pull-stream')
const mh = require('multihashes')
Expand Down Expand Up @@ -417,6 +418,37 @@ module.exports = (repo) => {
}
}
})

it('will call a progress function', (done) => {
options.progress = sinon.spy()
pull(
pull.values([{
path: '1.2MiB.txt',
content: pull.values([bigFile])
}]),
importer(ipldResolver, options),
pull.collect(() => {
expect(options.progress.called).to.be.true
expect(options.progress.args[0][0]).to.equal(1024)
done()
})
)
})

it('only if it is passed', (done) => {
options.progress = false
pull(
pull.values([{
path: '200Bytes.txt',
content: pull.values([smallFile])
}]),
importer(ipldResolver, options),
pull.collect(() => {
expect(options.progress.notCalled).to.be.true
done()
})
)
})
})
})
}