Enabled @typescript-eslint/no-unsafe-call eslint rule again

This commit is contained in:
Alejandro Celaya
2021-02-28 17:43:41 +01:00
parent 86544f4b24
commit 1fe76500e8
7 changed files with 18 additions and 13 deletions

View File

@@ -1,4 +1,4 @@
import { EventSourcePolyfill as EventSource } from 'event-source-polyfill';
import { EventSourcePolyfill } from 'event-source-polyfill';
import { Mock } from 'ts-mockery';
import { identity } from 'ramda';
import { bindToMercureTopic } from '../../../src/mercure/helpers';
@@ -22,7 +22,7 @@ describe('helpers', () => {
])('does not bind an EventSource when loading, error or no hub URL', (mercureInfo) => {
bindToMercureTopic(mercureInfo, [ '' ], identity, identity);
expect(EventSource).not.toHaveBeenCalled();
expect(EventSourcePolyfill).not.toHaveBeenCalled();
expect(onMessage).not.toHaveBeenCalled();
expect(onTokenExpired).not.toHaveBeenCalled();
});
@@ -42,16 +42,16 @@ describe('helpers', () => {
token,
}, [ topic ], onMessage, onTokenExpired);
expect(EventSource).toHaveBeenCalledWith(hubUrl, {
expect(EventSourcePolyfill).toHaveBeenCalledWith(hubUrl, {
headers: {
Authorization: `Bearer ${token}`,
},
});
const [ es ] = EventSource.mock.instances;
const [ es ] = (EventSourcePolyfill as any).mock.instances as EventSourcePolyfill[];
es.onmessage({ data: '{"foo": "bar"}' });
es.onerror({ status: 401 });
es.onmessage?.({ data: '{"foo": "bar"}' });
es.onerror?.({ status: 401 });
expect(onMessage).toHaveBeenCalledWith({ foo: 'bar' });
expect(onTokenExpired).toHaveBeenCalled();