cache plugin test: testing for rejections when content not available (ref. #8)

merge-requests/1/head
Michał 'rysiek' Woźniak 2021-08-30 14:09:53 +00:00
rodzic fb98acc396
commit eb0e64df2f
2 zmienionych plików z 8 dodań i 1 usunięć

Wyświetl plik

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

Wyświetl plik

@ -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:'