mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2025-01-03 14:57:22 +03:00
Fix remaining type errors in tests
This commit is contained in:
parent
d14aea708e
commit
2a86a0e540
6 changed files with 8 additions and 12 deletions
|
@ -18,9 +18,8 @@
|
||||||
"build": "npm run types && vite build && node scripts/replace-version.mjs",
|
"build": "npm run types && vite build && node scripts/replace-version.mjs",
|
||||||
"build:dist": "npm run build && node scripts/create-dist-file.mjs",
|
"build:dist": "npm run build && node scripts/create-dist-file.mjs",
|
||||||
"test": "vitest run --run",
|
"test": "vitest run --run",
|
||||||
"test:coverage": "npm run test -- --coverage",
|
"test:watch": "vitest run --watch",
|
||||||
"test:ci": "npm run test:coverage -- --coverageReporters=clover --ci",
|
"test:ci": "npm run test -- --coverage",
|
||||||
"test:pretty": "npm run test:coverage -- --coverageReporters=html",
|
|
||||||
"test:verbose": "npm run test -- --verbose"
|
"test:verbose": "npm run test -- --verbose"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|
|
@ -5,7 +5,11 @@ import type { ReactElement } from 'react';
|
||||||
export const setUpCanvas = (element: ReactElement) => {
|
export const setUpCanvas = (element: ReactElement) => {
|
||||||
const result = render(element);
|
const result = render(element);
|
||||||
const { container } = result;
|
const { container } = result;
|
||||||
const getEvents = () => container.querySelector('canvas')?.getContext('2d')?.__getEvents(); // eslint-disable-line no-underscore-dangle
|
const getEvents = () => {
|
||||||
|
const context = container.querySelector('canvas')?.getContext('2d');
|
||||||
|
// @ts-expect-error __getEvents is set by vitest-canvas-mock
|
||||||
|
return context?.__getEvents(); // eslint-disable-line no-underscore-dangle
|
||||||
|
};
|
||||||
|
|
||||||
return { ...result, events: getEvents(), getEvents };
|
return { ...result, events: getEvents(), getEvents };
|
||||||
};
|
};
|
||||||
|
|
|
@ -9,7 +9,6 @@ describe('ImageDownloader', () => {
|
||||||
let imageDownloader: ImageDownloader;
|
let imageDownloader: ImageDownloader;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
vi.clearAllMocks();
|
|
||||||
(global as any).URL = { createObjectURL: () => '' };
|
(global as any).URL = { createObjectURL: () => '' };
|
||||||
|
|
||||||
imageDownloader = new ImageDownloader(httpClient, windowMock);
|
imageDownloader = new ImageDownloader(httpClient, windowMock);
|
||||||
|
|
|
@ -26,10 +26,6 @@ describe('<TagsTable />', () => {
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
afterEach(() => {
|
|
||||||
vi.clearAllMocks();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('renders empty result if there are no tags', () => {
|
it('renders empty result if there are no tags', () => {
|
||||||
setUp();
|
setUp();
|
||||||
|
|
||||||
|
|
|
@ -7,11 +7,10 @@ describe('ColorGenerator', () => {
|
||||||
let colorGenerator: ColorGenerator;
|
let colorGenerator: ColorGenerator;
|
||||||
const storageMock = fromPartial<LocalStorage>({
|
const storageMock = fromPartial<LocalStorage>({
|
||||||
set: vi.fn(),
|
set: vi.fn(),
|
||||||
get: vi.fn(),
|
get: vi.fn().mockImplementation(() => undefined),
|
||||||
});
|
});
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
vi.clearAllMocks();
|
|
||||||
colorGenerator = new ColorGenerator(storageMock);
|
colorGenerator = new ColorGenerator(storageMock);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,6 @@ describe('LocalStorage', () => {
|
||||||
let storage: LocalStorage;
|
let storage: LocalStorage;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
vi.clearAllMocks();
|
|
||||||
storage = new LocalStorage(localStorageMock);
|
storage = new LocalStorage(localStorageMock);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue