|
1 | | -/* eslint-env mocha */ |
| 1 | +/* eslint-env mocha, browser */ |
2 | 2 | 'use strict' |
3 | 3 |
|
4 | 4 | const { fixtures } = require('./utils') |
@@ -48,6 +48,36 @@ module.exports = (createCommon, options) => { |
48 | 48 | } |
49 | 49 | }) |
50 | 50 |
|
| 51 | + it('should add a File as tuple', function (done) { |
| 52 | + if (!supportsFileReader) return this.skip('skip in node') |
| 53 | + |
| 54 | + const tuple = { |
| 55 | + path: 'filename.txt', |
| 56 | + content: new self.File(['should add a File'], 'filename.txt', { type: 'text/plain' }) |
| 57 | + } |
| 58 | + |
| 59 | + ipfs.add(tuple, (err, filesAdded) => { |
| 60 | + expect(err).to.not.exist() |
| 61 | + expect(filesAdded[0].hash).to.be.eq('QmTVfLxf3qXiJgr4KwG6UBckcNvTqBp93Rwy5f7h3mHsVC') |
| 62 | + done() |
| 63 | + }) |
| 64 | + }) |
| 65 | + |
| 66 | + it('should add a File as array of tuple', function (done) { |
| 67 | + if (!supportsFileReader) return this.skip('skip in node') |
| 68 | + |
| 69 | + const tuple = { |
| 70 | + path: 'filename.txt', |
| 71 | + content: new self.File(['should add a File'], 'filename.txt', { type: 'text/plain' }) |
| 72 | + } |
| 73 | + |
| 74 | + ipfs.add([tuple], (err, filesAdded) => { |
| 75 | + expect(err).to.not.exist() |
| 76 | + expect(filesAdded[0].hash).to.be.eq('QmTVfLxf3qXiJgr4KwG6UBckcNvTqBp93Rwy5f7h3mHsVC') |
| 77 | + done() |
| 78 | + }) |
| 79 | + }) |
| 80 | + |
51 | 81 | it('should add a Buffer', (done) => { |
52 | 82 | ipfs.add(fixtures.smallFile.data, (err, filesAdded) => { |
53 | 83 | expect(err).to.not.exist() |
|
0 commit comments