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

Commit cacb55c

Browse files
committed
clean up tests
1 parent 250aed4 commit cacb55c

File tree

1 file changed

+20
-20
lines changed

1 file changed

+20
-20
lines changed

test/test-exporter.js

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -88,52 +88,52 @@ module.exports = function (repo) {
8888
})
8989
testExport.pipe(concat((files) => {
9090
expect(files[0].path).to.equal('QmWChcSFMNcFkfeJtNd8Yru1rE6PhtCRfewi1tMwjkwKjN')
91+
expect(files[0].content).to.not.exist
92+
9193
expect(files[1].path).to.equal('QmWChcSFMNcFkfeJtNd8Yru1rE6PhtCRfewi1tMwjkwKjN/200Bytes.txt')
94+
expect(files[1].content).to.exist
95+
9296
expect(files[2].path).to.equal('QmWChcSFMNcFkfeJtNd8Yru1rE6PhtCRfewi1tMwjkwKjN/dir-another')
97+
expect(files[2].content).to.not.exist
98+
9399
expect(files[3].path).to.equal('QmWChcSFMNcFkfeJtNd8Yru1rE6PhtCRfewi1tMwjkwKjN/level-1')
100+
expect(files[3].content).to.not.exist
101+
94102
expect(files[4].path).to.equal('QmWChcSFMNcFkfeJtNd8Yru1rE6PhtCRfewi1tMwjkwKjN/level-1/200Bytes.txt')
103+
expect(files[4].content).to.exist
104+
95105
expect(files[5].path).to.equal('QmWChcSFMNcFkfeJtNd8Yru1rE6PhtCRfewi1tMwjkwKjN/level-1/level-2')
106+
expect(files[5].content).to.not.exist
107+
96108
done()
97109
}))
98110
})
99111

100112
it('returns a null stream for dir', (done) => {
101-
const hash = 'QmUNLLsPACCz1vLxQVkXqqLX5R1X345qqfHbsf67hvA3Nn' // This hash doesn't exist in the repo
113+
const hash = 'QmUNLLsPACCz1vLxQVkXqqLX5R1X345qqfHbsf67hvA3Nn'
102114
const bs = new BlockService(repo)
103115
const ds = new DAGService(bs)
104116
const testExport = exporter(hash, ds)
117+
105118
testExport.on('error', (err) => {
106119
expect(err).to.not.exist
107120
})
108-
testExport.on('data', (dir) => {
109-
expect(dir.content).to.equal(null)
121+
122+
testExport.on('data', (file) => {
123+
expect(file.content).to.not.exist
110124
done()
111125
})
112126
})
113127

114128
it('fails on non existent hash', (done) => {
115-
const hash = 'QmWChcSFMNcFkfeJtNd8Yru1rE6PhtCRfewi1tMwjkwKj3' // This hash doesn't exist in the repo
129+
// This hash doesn't exist in the repo
130+
const hash = 'QmWChcSFMNcFkfeJtNd8Yru1rE6PhtCRfewi1tMwjkwKj3'
116131
const bs = new BlockService(repo)
117132
const ds = new DAGService(bs)
118133
const testExport = exporter(hash, ds)
119134
testExport.on('error', (err) => {
120-
const error = err.toString()
121135
expect(err).to.exist
122-
const browser = error.includes('Error: key not found:')
123-
const node = error.includes('no such file or directory')
124-
// the browser and node js return different errors
125-
if (browser) {
126-
expect(error).to.contain('Error: key not found:')
127-
done()
128-
}
129-
if (node) {
130-
expect(error).to.contain('no such file or directory')
131-
done()
132-
}
133-
if (!node && !browser) {
134-
expect(node).to.equal(true)
135-
done()
136-
}
136+
done()
137137
})
138138
})
139139
})

0 commit comments

Comments
 (0)