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

Commit 2ff8312

Browse files
committed
fix: tidy up tests
1 parent 8885ddb commit 2ff8312

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

src/utils/progress-stream.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@ class ProgressStream extends Transform {
4242
return callback()
4343
}
4444

45+
if (typeof chunk.Message !== 'undefined' ||
46+
typeof chunk.Code !== 'undefined') {
47+
this.emit('error', chunk)
48+
}
49+
4550
callback(null, chunk)
4651
}
4752
}

test/files.spec.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -119,15 +119,15 @@ describe('.files (the MFS API part)', function () {
119119
expect(err).to.not.exist()
120120

121121
expect(res).to.have.length(1)
122-
expect(progress).to.be.equal(100)
123-
expect(progressCount).to.be.greaterThan(0)
122+
expect(progress).to.be.equal(testfile.byteLength)
123+
expect(progressCount).to.be.equal(1)
124124

125125
done()
126126
})
127127
})
128128

129129
it('files.add big file with progress option', (done) => {
130-
let progress
130+
let progress = 0
131131
let progressCount = 0
132132

133133
const progressHandler = (p) => {
@@ -140,15 +140,15 @@ describe('.files (the MFS API part)', function () {
140140
expect(err).to.not.exist()
141141

142142
expect(res).to.have.length(1)
143-
expect(progress).to.be.equal(100)
144-
expect(progressCount).to.be.greaterThan(0)
143+
expect(progress).to.be.equal(testfile.byteLength)
144+
expect(progressCount).to.be.equal(1)
145145

146146
done()
147147
})
148148
})
149149

150150
it('files.add directory with progress option', (done) => {
151-
let progress
151+
let progress = 0
152152
let progressCount = 0
153153

154154
const progressHandler = (p) => {
@@ -161,8 +161,8 @@ describe('.files (the MFS API part)', function () {
161161
expect(err).to.not.exist()
162162

163163
expect(res).to.have.length(1)
164-
expect(progress).to.be.equal(100)
165-
expect(progressCount).to.be.greaterThan(0)
164+
expect(progress).to.be.equal(testfile.byteLength)
165+
expect(progressCount).to.be.equal(1)
166166

167167
done()
168168
})

0 commit comments

Comments
 (0)