feat(ipfs): Added IPFS class for uploading and download files from IPFS

This commit is contained in:
Chris Troutner
2020-05-11 10:47:44 -07:00
parent 67129f8a27
commit 267d481ac6
6 changed files with 332 additions and 2 deletions
+42
View File
@@ -0,0 +1,42 @@
const assert = require("chai").assert
// const axios = require("axios")
const sinon = require("sinon")
const BCHJS = require("../../src/bch-js")
const bchjs = new BCHJS()
// const mockData = require("./fixtures/electrumx-mock")
describe(`#IPFS`, () => {
let sandbox
beforeEach(() => (sandbox = sinon.createSandbox()))
afterEach(() => sandbox.restore())
describe("#initUppy", () => {
it("should initialize uppy", () => {
bchjs.IPFS.initUppy()
// console.log(`bchjs.IPFS.uppy: `, bchjs.IPFS.uppy)
})
})
describe("#upload", () => {
it("should throw an error if file does not exist", async () => {
try {
const path = "/non-existant-file"
await bchjs.IPFS.upload(path)
assert.equal(true, false, "Unexpected result")
} catch (err) {
console.log(`err.message: ${err.message}`)
}
})
it("should do something", async () => {
const path = `/home/trout/work/personal/bch-js/test/unit/ipfs.js`
await bchjs.IPFS.upload(path)
})
})
})