mirror of
https://github.com/Permissionless-Software-Foundation/bch-js.git
synced 2026-09-21 16:51:59 -07:00
feat(ipfs): Added IPFS class for uploading and download files from IPFS
This commit is contained in:
@@ -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)
|
||||
})
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user