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

fix: files.add accepts object #234

Merged
merged 1 commit into from
Mar 9, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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