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

Commit fdf6e01

Browse files
committed
fix(files.get): Big file test
1 parent 037bf97 commit fdf6e01

File tree

1 file changed

+27
-19
lines changed

1 file changed

+27
-19
lines changed

test/api/get.spec.js

Lines changed: 27 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ const path = require('path')
1717
// const extract = require('tar-stream').extract
1818

1919
const testfile = fs.readFileSync(path.join(__dirname, '/../testfile.txt'))
20+
2021
let testfileBig
2122

2223
if (isNode) {
@@ -93,35 +94,42 @@ describe('.get', () => {
9394
return done()
9495
}
9596

96-
apiClients.a.get('Qme79tX2bViL26vNjPsF3DP1R9rMKMvnPYJiKTTKPrXJjq', (err, res) => {
97+
apiClients.a.get('Qme79tX2bViL26vNjPsF3DP1R9rMKMvnPYJiKTTKPrXJjq', (err, files) => {
9798
expect(err).to.not.exist
9899

99-
// Do not blow out the memory of nodejs :)
100-
streamEqual(res, testfileBig, (err, equal) => {
101-
expect(err).to.not.exist
102-
expect(equal).to.be.true
103-
done()
100+
files.on('data', (file) => {
101+
// Do not blow out the memory of nodejs :)
102+
streamEqual(file.content, testfileBig, (err, equal) => {
103+
expect(err).to.not.exist
104+
expect(equal).to.be.true
105+
done()
106+
})
104107
})
105108
})
106109
})
107110

108111
describe('promise', () => {
109112
it('get', (done) => {
110113
apiClients.a.get('Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP')
111-
.then((res) => {
112-
let buf = ''
113-
res
114-
.on('error', (err) => {
115-
throw err
116-
})
117-
.on('data', (data) => {
118-
buf += data
119-
})
120-
.on('end', () => {
121-
expect(buf).to.contain(testfile.toString())
122-
done()
123-
})
114+
.then((files) => {
115+
files.on('data', (file) => {
116+
let buf = ''
117+
file.content
118+
.on('error', (err) => {
119+
throw err
120+
})
121+
.on('data', (data) => {
122+
buf += data.toString()
123+
})
124+
.on('end', () => {
125+
expect(buf).to.contain(testfile.toString())
126+
done()
127+
})
128+
})
124129
})
130+
.catch((err) => {
131+
expect(err).to.not.exist
132+
})
125133
})
126134
})
127135
})

0 commit comments

Comments
 (0)