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

Commit

Permalink
fix: files.add accepts object
Browse files Browse the repository at this point in the history
  • Loading branch information
dryajov authored and daviddias committed Mar 9, 2018
1 parent 8f25e9b commit 88a635a
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion js/src/files.js
Original file line number Diff line number Diff line change
Expand Up @@ -614,7 +614,29 @@ module.exports = (common) => {
], done)
})

it('with ipfs path, nested value', (done) => {
it('with ipfs path, as object and nested value', (done) => {
const file = {
path: 'a/testfile.txt',
content: smallFile.data
}

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

filesAdded.forEach((file) => {
if (file.path === 'a') {
ipfs.files.get(`/ipfs/${file.hash}/testfile.txt`, (err, files) => {
expect(err).to.not.exist()
expect(files).to.be.length(1)
expect(files[0].content.toString('utf8')).to.contain('Plz add me!')
done()
})
}
})
})
})

it('with ipfs path, as array and nested value', (done) => {
const file = {
path: 'a/testfile.txt',
content: smallFile.data
Expand Down

0 comments on commit 88a635a

Please sign in to comment.