kopia lustrzana https://gitlab.com/rysiekpl/libresilient
fetch plugin test: testing what happens on 400+ status codes (and rising coverage to 100%; ref. #8)
rodzic
9e13d8980a
commit
da86c0eba1
|
@ -62,4 +62,26 @@ describe("plugin: fetch", () => {
|
|||
expect(response.headers.has('X-LibResilient-Etag')).toEqual(true)
|
||||
expect(response.headers.get('X-LibResilient-ETag')).toEqual('TestingETagHeader')
|
||||
});
|
||||
|
||||
test("it should throw an error when HTTP status is >= 400", async () => {
|
||||
|
||||
global.fetch.mockImplementation((url, init) => {
|
||||
const response = new Response(
|
||||
new Blob(
|
||||
["Not Found"],
|
||||
{type: "text/plain"}
|
||||
),
|
||||
{
|
||||
status: 404,
|
||||
statusText: "Not Found",
|
||||
url: url
|
||||
});
|
||||
return Promise.resolve(response);
|
||||
});
|
||||
|
||||
require("../../plugins/fetch.js");
|
||||
|
||||
expect.assertions(1)
|
||||
expect(self.LibResilientPlugins[0].fetch('https://resilient.is/test.json')).rejects.toThrow(Error)
|
||||
});
|
||||
});
|
||||
|
|
Ładowanie…
Reference in New Issue