Skip to content

Commit

Permalink
Merge pull request ipfs#509 from ipfs/test/non-sequential-files
Browse files Browse the repository at this point in the history
test: add test for add files to dir non sequentially
  • Loading branch information
Stebalien authored Aug 1, 2019
2 parents 4fdb6f6 + 1c853a1 commit d8a28b5
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions src/files-regular/add.js
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,33 @@ module.exports = (createCommon, options) => {
})
})

it('should add files to a directory non sequentially', function (done) {
const content = path => ({
path: `test-dir/${path}`,
content: fixtures.directory.files[path.split('/').pop()]
})

const input = [
content('a/pp.txt'),
content('a/holmes.txt'),
content('b/jungle.txt'),
content('a/alice.txt')
]

ipfs.add(input, (err, filesAdded) => {
expect(err).to.not.exist()

const toPath = ({ path }) => path
const nonSeqDirFilePaths = input.map(toPath).filter(p => p.includes('/a/'))
const filesAddedPaths = filesAdded.map(toPath)

expect(nonSeqDirFilePaths.every(p => filesAddedPaths.includes(p)))
.to.be.true()

done()
})
})

it('should fail when passed invalid input', (done) => {
const nonValid = 'sfdasfasfs'

Expand Down

0 comments on commit d8a28b5

Please sign in to comment.