diff --git a/__tests__/plugins/gun-ipfs.test.js b/__tests__/plugins/gun-ipfs.test.js index d8bdf64..9206e47 100644 --- a/__tests__/plugins/gun-ipfs.test.js +++ b/__tests__/plugins/gun-ipfs.test.js @@ -15,13 +15,24 @@ describe("plugin: gun-ipfs", () => { self.log = function(component, ...items) { console.debug(component + ' :: ', ...items) } - self.Ipfs = { + global.Ipfs = { create: ()=>{ return Promise.resolve({}) } } + self.Ipfs = global.Ipfs self.gunUser = jest.fn(()=>{ - return {} + return { + get: () => { + return { + get: ()=>{ + return { + once: (arg)=>{ arg(undefined) } + } + } + } + } + } }) global.Gun = jest.fn((nodes)=>{ return { @@ -61,4 +72,15 @@ describe("plugin: gun-ipfs", () => { self.LibResilientPlugins[0].publish([true, 5]) }).toThrow('Only accepts: string, Array of string, Response.') }) + + test("fetching should error out for unpublished content", async ()=>{ + require("../../plugins/gun-ipfs.js"); + + expect.assertions(1) + try { + await self.LibResilientPlugins[0].fetch(self.location.origin + '/test.json') + } catch(e) { + expect(e).toEqual(new Error('IPFS address is undefined for: /test.json')) + } + }) });