kopia lustrzana https://gitlab.com/rysiekpl/libresilient
cache plugin test: testing for rejections when content not available (ref. #8)
rodzic
fb98acc396
commit
eb0e64df2f
|
@ -45,6 +45,13 @@ describe("plugin: cache", () => {
|
|||
expect(self.LibResilientPlugins[0].name).toEqual('cache');
|
||||
});
|
||||
|
||||
test("it should error out if resource is not found", () => {
|
||||
require("../../plugins/cache.js");
|
||||
|
||||
expect.assertions(1)
|
||||
return expect(self.LibResilientPlugins[0].fetch('https://resilient.is/test.json')).rejects.toThrow(Error)
|
||||
});
|
||||
|
||||
test("it should stash successfully", () => {
|
||||
require("../../plugins/cache.js");
|
||||
expect.assertions(7);
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
return cache.match(url)
|
||||
})
|
||||
.then((response) => {
|
||||
if (typeof response === 'undefined') {
|
||||
if ((typeof response === 'undefined') || (response === null) ) {
|
||||
throw new Error('Resource not found in cache');
|
||||
} else {
|
||||
var msg = 'retrieved cached headers:'
|
||||
|
|
Ładowanie…
Reference in New Issue