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

Commit 9b58c39

Browse files
author
Alan Shaw
authored
test: add tests for file support as tuple (#479)
License: MIT Signed-off-by: Alan Shaw <[email protected]>
1 parent 1d7de2c commit 9b58c39

File tree

1 file changed

+31
-1
lines changed

1 file changed

+31
-1
lines changed

src/files-regular/add.js

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* eslint-env mocha */
1+
/* eslint-env mocha, browser */
22
'use strict'
33

44
const { fixtures } = require('./utils')
@@ -48,6 +48,36 @@ module.exports = (createCommon, options) => {
4848
}
4949
})
5050

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+
5181
it('should add a Buffer', (done) => {
5282
ipfs.add(fixtures.smallFile.data, (err, filesAdded) => {
5383
expect(err).to.not.exist()

0 commit comments

Comments
 (0)