mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2024-12-23 01:20:24 +03:00
Enabled @typescript-eslint/unbound-method eslint rule again
This commit is contained in:
parent
c8f8416c06
commit
86544f4b24
4 changed files with 18 additions and 22 deletions
|
@ -16,7 +16,7 @@
|
||||||
},
|
},
|
||||||
"rules": {
|
"rules": {
|
||||||
"@typescript-eslint/no-unsafe-assignment": "off",
|
"@typescript-eslint/no-unsafe-assignment": "off",
|
||||||
"@typescript-eslint/unbound-method": "off",
|
|
||||||
"@typescript-eslint/no-unsafe-member-access": "off",
|
"@typescript-eslint/no-unsafe-member-access": "off",
|
||||||
"@typescript-eslint/no-unsafe-call": "off",
|
"@typescript-eslint/no-unsafe-call": "off",
|
||||||
"@typescript-eslint/no-unsafe-return": "off",
|
"@typescript-eslint/no-unsafe-return": "off",
|
||||||
|
|
|
@ -10,6 +10,6 @@ export interface GroupedNewVisits {
|
||||||
|
|
||||||
export const groupNewVisitsByType = pipe(
|
export const groupNewVisitsByType = pipe(
|
||||||
groupBy((newVisit: CreateVisit) => isOrphanVisit(newVisit.visit) ? 'orphanVisits' : 'regularVisits'),
|
groupBy((newVisit: CreateVisit) => isOrphanVisit(newVisit.visit) ? 'orphanVisits' : 'regularVisits'),
|
||||||
// @ts-ignore-error Type declaration on groupBy is not correct. It can return undefined props
|
// @ts-expect-error Type declaration on groupBy is not correct. It can return undefined props
|
||||||
(result): GroupedNewVisits => ({ orphanVisits: [], regularVisits: [], ...result }),
|
(result): GroupedNewVisits => ({ orphanVisits: [], regularVisits: [], ...result }),
|
||||||
);
|
);
|
||||||
|
|
|
@ -9,16 +9,15 @@ describe('ServersExporter', () => {
|
||||||
click: jest.fn(),
|
click: jest.fn(),
|
||||||
style: {},
|
style: {},
|
||||||
});
|
});
|
||||||
|
const appendChild = jest.fn();
|
||||||
|
const removeChild = jest.fn();
|
||||||
const createWindowMock = (isIe10 = true) => Mock.of<Window>({
|
const createWindowMock = (isIe10 = true) => Mock.of<Window>({
|
||||||
navigator: {
|
navigator: {
|
||||||
msSaveBlob: isIe10 ? jest.fn() : undefined,
|
msSaveBlob: isIe10 ? jest.fn() : undefined,
|
||||||
},
|
},
|
||||||
document: {
|
document: {
|
||||||
createElement: jest.fn(() => createLinkMock()),
|
createElement: jest.fn(() => createLinkMock()),
|
||||||
body: {
|
body: { appendChild, removeChild },
|
||||||
appendChild: jest.fn(),
|
|
||||||
removeChild: jest.fn(),
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
const storageMock = Mock.of<LocalStorage>({
|
const storageMock = Mock.of<LocalStorage>({
|
||||||
|
@ -33,15 +32,14 @@ describe('ServersExporter', () => {
|
||||||
},
|
},
|
||||||
})),
|
})),
|
||||||
});
|
});
|
||||||
const createCsvjsonMock = (throwError = false) => Mock.of<CsvJson>({
|
const erroneousToCsv = jest.fn(() => {
|
||||||
toCSV: jest.fn(() => {
|
|
||||||
if (throwError) {
|
|
||||||
throw new Error('');
|
throw new Error('');
|
||||||
}
|
|
||||||
|
|
||||||
return '';
|
|
||||||
}),
|
|
||||||
});
|
});
|
||||||
|
const createCsvjsonMock = (throwError = false) => Mock.of<CsvJson>({
|
||||||
|
toCSV: throwError ? erroneousToCsv : jest.fn(() => ''),
|
||||||
|
});
|
||||||
|
|
||||||
|
beforeEach(jest.clearAllMocks);
|
||||||
|
|
||||||
describe('exportServers', () => {
|
describe('exportServers', () => {
|
||||||
let originalConsole: Console;
|
let originalConsole: Console;
|
||||||
|
@ -61,12 +59,11 @@ describe('ServersExporter', () => {
|
||||||
it('logs an error if something fails', () => {
|
it('logs an error if something fails', () => {
|
||||||
const csvjsonMock = createCsvjsonMock(true);
|
const csvjsonMock = createCsvjsonMock(true);
|
||||||
const exporter = new ServersExporter(storageMock, createWindowMock(), csvjsonMock);
|
const exporter = new ServersExporter(storageMock, createWindowMock(), csvjsonMock);
|
||||||
const { toCSV } = csvjsonMock;
|
|
||||||
|
|
||||||
exporter.exportServers();
|
exporter.exportServers();
|
||||||
|
|
||||||
expect(error).toHaveBeenCalledTimes(1);
|
expect(error).toHaveBeenCalledTimes(1);
|
||||||
expect(toCSV).toHaveBeenCalledTimes(1);
|
expect(erroneousToCsv).toHaveBeenCalledTimes(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('makes use of msSaveBlob API when available', () => {
|
it('makes use of msSaveBlob API when available', () => {
|
||||||
|
@ -84,8 +81,7 @@ describe('ServersExporter', () => {
|
||||||
it('makes use of download link API when available', () => {
|
it('makes use of download link API when available', () => {
|
||||||
const windowMock = createWindowMock(false);
|
const windowMock = createWindowMock(false);
|
||||||
const exporter = new ServersExporter(storageMock, windowMock, createCsvjsonMock());
|
const exporter = new ServersExporter(storageMock, windowMock, createCsvjsonMock());
|
||||||
const { document: { createElement, body } } = windowMock;
|
const { document: { createElement } } = windowMock;
|
||||||
const { appendChild, removeChild } = body;
|
|
||||||
|
|
||||||
exporter.exportServers();
|
exporter.exportServers();
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@ describe('<DefaultChart />', () => {
|
||||||
|
|
||||||
const { labels, datasets } = doughnut.prop('data') as any;
|
const { labels, datasets } = doughnut.prop('data') as any;
|
||||||
const [{ title, data, backgroundColor, borderColor }] = datasets;
|
const [{ title, data, backgroundColor, borderColor }] = datasets;
|
||||||
const { legend, legendCallback, scales } = doughnut.prop('options') ?? {};
|
const { legend, scales, ...options } = doughnut.prop('options') ?? {};
|
||||||
|
|
||||||
expect(title).toEqual('The chart');
|
expect(title).toEqual('The chart');
|
||||||
expect(labels).toEqual(keys(stats));
|
expect(labels).toEqual(keys(stats));
|
||||||
|
@ -46,7 +46,7 @@ describe('<DefaultChart />', () => {
|
||||||
]);
|
]);
|
||||||
expect(borderColor).toEqual('white');
|
expect(borderColor).toEqual('white');
|
||||||
expect(legend).toEqual({ display: false });
|
expect(legend).toEqual({ display: false });
|
||||||
expect(typeof legendCallback).toEqual('function');
|
expect(typeof options.legendCallback).toEqual('function');
|
||||||
expect(scales).toBeUndefined();
|
expect(scales).toBeUndefined();
|
||||||
expect(cols).toHaveLength(2);
|
expect(cols).toHaveLength(2);
|
||||||
});
|
});
|
||||||
|
@ -61,12 +61,12 @@ describe('<DefaultChart />', () => {
|
||||||
expect(horizontal).toHaveLength(1);
|
expect(horizontal).toHaveLength(1);
|
||||||
|
|
||||||
const { datasets: [{ backgroundColor, borderColor }] } = horizontal.prop('data') as any;
|
const { datasets: [{ backgroundColor, borderColor }] } = horizontal.prop('data') as any;
|
||||||
const { legend, legendCallback, scales } = horizontal.prop('options') ?? {};
|
const { legend, scales, ...options } = horizontal.prop('options') ?? {};
|
||||||
|
|
||||||
expect(backgroundColor).toEqual(MAIN_COLOR_ALPHA);
|
expect(backgroundColor).toEqual(MAIN_COLOR_ALPHA);
|
||||||
expect(borderColor).toEqual(MAIN_COLOR);
|
expect(borderColor).toEqual(MAIN_COLOR);
|
||||||
expect(legend).toEqual({ display: false });
|
expect(legend).toEqual({ display: false });
|
||||||
expect(legendCallback).toEqual(false);
|
expect(typeof options.legendCallback).toEqual('boolean');
|
||||||
expect(scales).toEqual({
|
expect(scales).toEqual({
|
||||||
xAxes: [
|
xAxes: [
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue