mirror of
https://github.com/Permissionless-Software-Foundation/bch-js.git
synced 2026-09-21 16:51:59 -07:00
fix(tests): Completing unit tests
This commit is contained in:
+40
-1
@@ -37,13 +37,25 @@ describe(`#IPFS`, () => {
|
||||
assert.equal(true, false, "Unexpected result")
|
||||
} catch (err) {
|
||||
//console.log(`err.message: ${err.message}`)
|
||||
assert.include(err.message,`Could not find this file`)
|
||||
assert.include(err.message, `Could not find this file`)
|
||||
}
|
||||
})
|
||||
|
||||
it("should return true if the file is uploaded", async () => {
|
||||
//const path = `/home/trout/work/personal/bch-js/test/unit/ipfs.js`
|
||||
try {
|
||||
const mock = {
|
||||
successful: [
|
||||
{
|
||||
id: 'file id'
|
||||
}
|
||||
],
|
||||
failed: []
|
||||
}
|
||||
sandbox
|
||||
.stub(bchjs.IPFS.uppy, 'upload')
|
||||
.resolves(mock)
|
||||
|
||||
const path = `${__dirname}/ipfs.js`
|
||||
const result = await bchjs.IPFS.uploadFile(path)
|
||||
|
||||
@@ -55,5 +67,32 @@ describe(`#IPFS`, () => {
|
||||
assert.equal(true, false, "Unexpected result")
|
||||
}
|
||||
})
|
||||
it("Should throw error if the file was not uploaded", async () => {
|
||||
//const path = `/home/trout/work/personal/bch-js/test/unit/ipfs.js`
|
||||
try {
|
||||
const mock = {
|
||||
successful: [],
|
||||
failed: [
|
||||
{
|
||||
id: 'file id'
|
||||
}
|
||||
]
|
||||
}
|
||||
sandbox
|
||||
.stub(bchjs.IPFS.uppy, 'upload')
|
||||
.resolves(mock)
|
||||
|
||||
const path = `${__dirname}/ipfs.js`
|
||||
await bchjs.IPFS.uploadFile(path)
|
||||
|
||||
assert.equal(true, false, "Unexpected result")
|
||||
|
||||
|
||||
} catch (err) {
|
||||
//console.log(err)
|
||||
assert.include(err.message, `The file could not be uploaded`)
|
||||
|
||||
}
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user