gun-ipfs plugin: added a stub test for unpublished content handling (ref. #8)

merge-requests/3/merge
Michał 'rysiek' Woźniak 2021-09-07 17:53:20 +00:00
rodzic 24ad9a10c8
commit 95db2721d4
1 zmienionych plików z 24 dodań i 2 usunięć

Wyświetl plik

@ -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'))
}
})
});