cache plugin tests: ~73% coverage (ref. #8)

merge-requests/9/merge
Michał 'rysiek' Woźniak 2021-08-30 14:41:45 +00:00
rodzic eb0e64df2f
commit 28d099a834
1 zmienionych plików z 27 dodań i 1 usunięć

Wyświetl plik

@ -52,7 +52,7 @@ describe("plugin: cache", () => {
return expect(self.LibResilientPlugins[0].fetch('https://resilient.is/test.json')).rejects.toThrow(Error)
});
test("it should stash successfully", () => {
test("it should stash a url successfully", () => {
require("../../plugins/cache.js");
expect.assertions(7);
return self.LibResilientPlugins[0].stash('https://resilient.is/test.json').then((result)=>{
@ -70,4 +70,30 @@ describe("plugin: cache", () => {
})
});
test("it should clear a url successfully", () => {
require("../../plugins/cache.js");
expect.assertions(3);
return self.LibResilientPlugins[0].stash('https://resilient.is/test.json').then((result)=>{
expect(result).toBe(undefined)
return self.LibResilientPlugins[0].unstash('https://resilient.is/test.json')
}).then(result => {
expect(result).toEqual(true)
return expect(self.LibResilientPlugins[0].fetch('https://resilient.is/test.json')).rejects.toThrow(Error)
})
});
test("it should clear an array of urls successfully", () => {
require("../../plugins/cache.js");
expect.assertions(4);
return self.LibResilientPlugins[0].stash(['https://resilient.is/test.json', 'https://resilient.is/test2.json']).then((result)=>{
expect(result).toEqual([undefined, undefined])
return self.LibResilientPlugins[0].unstash(['https://resilient.is/test.json', 'https://resilient.is/test2.json'])
}).then(result => {
expect(result).toEqual([true, true])
return expect(self.LibResilientPlugins[0].fetch('https://resilient.is/test.json')).rejects.toThrow(Error)
}).then(()=>{
return expect(self.LibResilientPlugins[0].fetch('https://resilient.is/test2.json')).rejects.toThrow(Error)
})
});
});