diff --git a/src/files-regular/add.js b/src/files-regular/add.js index abdd1ae87..def121f12 100644 --- a/src/files-regular/add.js +++ b/src/files-regular/add.js @@ -1,4 +1,4 @@ -/* eslint-env mocha */ +/* eslint-env mocha, browser */ 'use strict' const { fixtures } = require('./utils') @@ -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()