kopia lustrzana https://gitlab.com/rysiekpl/libresilient
gun-ipfs plugin: added a stub test for unpublished content handling (ref. #8)
rodzic
24ad9a10c8
commit
95db2721d4
|
@ -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'))
|
||||
}
|
||||
})
|
||||
});
|
||||
|
|
Ładowanie…
Reference in New Issue