kopia lustrzana https://gitlab.com/rysiekpl/libresilient
fetch plugin test: testing the headers
rodzic
4b1019edcb
commit
8069213852
|
@ -12,7 +12,9 @@ global.fetch.mockImplementation((url, init) => {
|
|||
{
|
||||
status: 200,
|
||||
statusText: "OK",
|
||||
headers: [],
|
||||
headers: {
|
||||
'ETag': 'TestingETagHeader'
|
||||
},
|
||||
url: url
|
||||
});
|
||||
return Promise.resolve(response);
|
||||
|
@ -46,4 +48,18 @@ describe("plugin: fetch", () => {
|
|||
expect(await response.json()).toEqual({test: "success"})
|
||||
expect(response.url).toEqual('https://resilient.is/test.json')
|
||||
});
|
||||
|
||||
test("it should set the LibResilient headers", async () => {
|
||||
require("../../plugins/fetch.js");
|
||||
|
||||
const response = await self.LibResilientPlugins[0].fetch('https://resilient.is/test.json');
|
||||
|
||||
expect(fetch).toHaveBeenCalled();
|
||||
expect(await response.json()).toEqual({test: "success"})
|
||||
expect(response.url).toEqual('https://resilient.is/test.json')
|
||||
expect(response.headers.has('X-LibResilient-Method')).toEqual(true)
|
||||
expect(response.headers.get('X-LibResilient-Method')).toEqual('fetch')
|
||||
expect(response.headers.has('X-LibResilient-Etag')).toEqual(true)
|
||||
expect(response.headers.get('X-LibResilient-ETag')).toEqual('TestingETagHeader')
|
||||
});
|
||||
});
|
||||
|
|
Ładowanie…
Reference in New Issue