Skip to content
This repository was archived by the owner on Mar 10, 2020. It is now read-only.
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
32 changes: 31 additions & 1 deletion src/files-regular/add.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint-env mocha */
/* eslint-env mocha, browser */
'use strict'

const { fixtures } = require('./utils')
Expand Down Expand Up @@ -48,6 +48,36 @@ module.exports = (createCommon, options) => {
}
})

it('should add a File as tuple', function (done) {
if (!supportsFileReader) return this.skip('skip in node')

const tuple = {
path: 'filename.txt',
content: new self.File(['should add a File'], 'filename.txt', { type: 'text/plain' })
}

ipfs.add(tuple, (err, filesAdded) => {
expect(err).to.not.exist()
expect(filesAdded[0].hash).to.be.eq('QmTVfLxf3qXiJgr4KwG6UBckcNvTqBp93Rwy5f7h3mHsVC')
done()
})
})

it('should add a File as array of tuple', function (done) {
if (!supportsFileReader) return this.skip('skip in node')

const tuple = {
path: 'filename.txt',
content: new self.File(['should add a File'], 'filename.txt', { type: 'text/plain' })
}

ipfs.add([tuple], (err, filesAdded) => {
expect(err).to.not.exist()
expect(filesAdded[0].hash).to.be.eq('QmTVfLxf3qXiJgr4KwG6UBckcNvTqBp93Rwy5f7h3mHsVC')
done()
})
})

it('should add a Buffer', (done) => {
ipfs.add(fixtures.smallFile.data, (err, filesAdded) => {
expect(err).to.not.exist()
Expand Down