remove bad cookie test (#4176)

This commit is contained in:
Jack Kavanagh 2021-11-09 09:52:49 +01:00 committed by GitHub
parent cbe7192587
commit cdd41c3746
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -24,6 +24,7 @@ describe('jarFromCookies()', () => {
});
it('handles malformed JSON', () => {
jest.spyOn(console, 'log').mockImplementationOnce(() => {});
// @ts-expect-error this test is verifying that an invalid input is handled appropriately
const jar = jarFromCookies('not a jar');
expect(jar.constructor.name).toBe('CookieJar');
@ -59,12 +60,11 @@ describe('cookiesFromJar()', () => {
it('handles bad jar', async () => {
const jar = CookieJar.fromJSON({ cookies: [] });
jest.spyOn(console, 'warn').mockImplementationOnce(() => {});
// MemoryStore never actually throws errors, so lets mock the function to force it to this time.
// @ts-expect-error intentionally invalid value
jar.store.getAllCookies = cb => cb(new Error('Dummy Error'));
const cookies = await cookiesFromJar(jar);
// Cookies failed to parse
expect(cookies.length).toBe(0);
});