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

Commit 8885ddb

Browse files
committed
tesT: add more tests
1 parent 10b0bde commit 8885ddb

File tree

1 file changed

+56
-5
lines changed

1 file changed

+56
-5
lines changed

test/files.spec.js

Lines changed: 56 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ describe('.files (the MFS API part)', function () {
4848

4949
after((done) => fc.dismantle(done))
5050

51-
describe('Callback API', function () {
51+
describe.only('Callback API', function () {
5252
this.timeout(120 * 1000)
5353

5454
it('add file for testing', (done) => {
@@ -106,13 +106,64 @@ describe('.files (the MFS API part)', function () {
106106
})
107107
})
108108

109-
it('files.add with progress options', (done) => {
110-
let progress = 0
111-
ipfs.files.add(testfile, { progress: (p) => { progress = p } }, (err, res) => {
109+
it('files.add file with progress option', (done) => {
110+
let progress
111+
let progressCount = 0
112+
113+
const progressHandler = (p) => {
114+
progressCount += 1
115+
progress = p
116+
}
117+
118+
ipfs.files.add(testfile, { progress: progressHandler }, (err, res) => {
119+
expect(err).to.not.exist()
120+
121+
expect(res).to.have.length(1)
122+
expect(progress).to.be.equal(100)
123+
expect(progressCount).to.be.greaterThan(0)
124+
125+
done()
126+
})
127+
})
128+
129+
it('files.add big file with progress option', (done) => {
130+
let progress
131+
let progressCount = 0
132+
133+
const progressHandler = (p) => {
134+
progressCount += 1
135+
progress = p
136+
}
137+
138+
// TODO: needs to be using a big file
139+
ipfs.files.add(testfile, { progress: progressHandler }, (err, res) => {
112140
expect(err).to.not.exist()
113141

114142
expect(res).to.have.length(1)
115-
expect(progress).to.be.greaterThan(0)
143+
expect(progress).to.be.equal(100)
144+
expect(progressCount).to.be.greaterThan(0)
145+
146+
done()
147+
})
148+
})
149+
150+
it('files.add directory with progress option', (done) => {
151+
let progress
152+
let progressCount = 0
153+
154+
const progressHandler = (p) => {
155+
progressCount += 1
156+
progress = p
157+
}
158+
159+
// TODO: needs to be using a directory
160+
ipfs.files.add(testfile, { progress: progressHandler }, (err, res) => {
161+
expect(err).to.not.exist()
162+
163+
expect(res).to.have.length(1)
164+
expect(progress).to.be.equal(100)
165+
expect(progressCount).to.be.greaterThan(0)
166+
116167
done()
117168
})
118169
})

0 commit comments

Comments
 (0)