kopia lustrzana https://gitlab.com/rysiekpl/libresilient
service-worker: test for all plugins failing added (ref. #8)
rodzic
65965075f0
commit
7588cad783
|
@ -144,7 +144,6 @@ describe("service-worker", () => {
|
|||
})
|
||||
require("../service-worker.js");
|
||||
var response = await self.trigger('fetch', new Request('/test.json', {method: "POST"}))
|
||||
console.log(response)
|
||||
expect(response.method).toEqual('POST')
|
||||
expect(await response.json()).toEqual({ test: "success" })
|
||||
})
|
||||
|
@ -367,4 +366,29 @@ describe("service-worker", () => {
|
|||
expect(self.LibResilientConfig.plugins['dependency1-test'].indirect).toEqual(true)
|
||||
expect(self.LibResilientConfig.plugins['dependency2-test'].indirect).toEqual(true)
|
||||
})
|
||||
|
||||
test("should error out if all plugins fail", async () => {
|
||||
self.LibResilientConfig = {
|
||||
plugins: {
|
||||
'reject-all': {}
|
||||
},
|
||||
loggedComponents: [
|
||||
'service-worker'
|
||||
]
|
||||
}
|
||||
self.LibResilientPlugins.push({
|
||||
name: 'reject-all',
|
||||
description: 'Reject all requests.',
|
||||
version: '0.0.1',
|
||||
fetch: (request, init)=>{ return Promise.reject(request); }
|
||||
})
|
||||
require("../service-worker.js");
|
||||
expect.assertions(1)
|
||||
try {
|
||||
await self.trigger('fetch', new Request('/test.json', {method: "GET"}))
|
||||
} catch(e) {
|
||||
expect(e).toEqual(self.location.origin + '/test.json')
|
||||
}
|
||||
})
|
||||
|
||||
});
|
||||
|
|
Ładowanie…
Reference in New Issue