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

Commit d8a28b5

Browse files
authored
Merge pull request #509 from ipfs/test/non-sequential-files
test: add test for add files to dir non sequentially
2 parents 4fdb6f6 + 1c853a1 commit d8a28b5

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

src/files-regular/add.js

+27
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,33 @@ module.exports = (createCommon, options) => {
325325
})
326326
})
327327

328+
it('should add files to a directory non sequentially', function (done) {
329+
const content = path => ({
330+
path: `test-dir/${path}`,
331+
content: fixtures.directory.files[path.split('/').pop()]
332+
})
333+
334+
const input = [
335+
content('a/pp.txt'),
336+
content('a/holmes.txt'),
337+
content('b/jungle.txt'),
338+
content('a/alice.txt')
339+
]
340+
341+
ipfs.add(input, (err, filesAdded) => {
342+
expect(err).to.not.exist()
343+
344+
const toPath = ({ path }) => path
345+
const nonSeqDirFilePaths = input.map(toPath).filter(p => p.includes('/a/'))
346+
const filesAddedPaths = filesAdded.map(toPath)
347+
348+
expect(nonSeqDirFilePaths.every(p => filesAddedPaths.includes(p)))
349+
.to.be.true()
350+
351+
done()
352+
})
353+
})
354+
328355
it('should fail when passed invalid input', (done) => {
329356
const nonValid = 'sfdasfasfs'
330357

0 commit comments

Comments
 (0)