Fix incorrect types between testing library and vitest

This commit is contained in:
Alejandro Celaya 2023-05-27 12:29:03 +02:00
parent 12a05b422d
commit d14aea708e
77 changed files with 69 additions and 206 deletions

View file

@ -4,6 +4,23 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org). The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org).
## [Unreleased]
### Added
* *Nothing*
### Changed
* [#781](https://github.com/shlinkio/shlink-web-client/issues/781) Migrate tests from jest to vitest.
### Deprecated
* *Nothing*
### Removed
* *Nothing*
### Fixed
* *Nothing*
## [3.10.1] - 2023-04-23 ## [3.10.1] - 2023-04-23
### Added ### Added
* *Nothing* * *Nothing*

View file

@ -1,16 +1,23 @@
import 'vitest-canvas-mock'; import 'vitest-canvas-mock';
import 'chart.js/auto'; import 'chart.js/auto';
import type { TestingLibraryMatchers } from '@testing-library/jest-dom/matchers';
import matchers from '@testing-library/jest-dom/matchers'; import matchers from '@testing-library/jest-dom/matchers';
import { cleanup } from '@testing-library/react'; import { cleanup } from '@testing-library/react';
import { setAutoFreeze } from 'immer';
import ResizeObserver from 'resize-observer-polyfill'; import ResizeObserver from 'resize-observer-polyfill';
import { afterEach, expect } from 'vitest'; import { afterEach, expect } from 'vitest';
// extends Vitest's expect method with methods from react-testing-library // Workaround for TypeScript error: https://github.com/testing-library/jest-dom/issues/439#issuecomment-1536524120
declare module 'vitest' {
interface Assertion<T = any> extends jest.Matchers<void, T>, TestingLibraryMatchers<T, void> {}
}
// Extends Vitest's expect method with methods from react-testing-library
expect.extend(matchers); expect.extend(matchers);
// runs a cleanup after each test case (e.g. clearing jsdom)
afterEach(() => { afterEach(() => {
// Clears all mocks after every test
vi.clearAllMocks();
// runs a cleanup after each test case (e.g. clearing jsdom)
cleanup(); cleanup();
}); });
@ -18,5 +25,3 @@ afterEach(() => {
(global as any).scrollTo = () => {}; (global as any).scrollTo = () => {};
(global as any).prompt = () => {}; (global as any).prompt = () => {};
(global as any).matchMedia = (media: string) => ({ matches: false, media }); (global as any).matchMedia = (media: string) => ({ matches: false, media });
setAutoFreeze(false); // TODO Bypassing a bug on jest

84
package-lock.json generated
View file

@ -55,7 +55,7 @@
"@shlinkio/eslint-config-js-coding-standard": "~2.1.0", "@shlinkio/eslint-config-js-coding-standard": "~2.1.0",
"@shlinkio/stylelint-config-css-coding-standard": "~1.0.1", "@shlinkio/stylelint-config-css-coding-standard": "~1.0.1",
"@testing-library/jest-dom": "^5.16.5", "@testing-library/jest-dom": "^5.16.5",
"@testing-library/react": "^13.4.0", "@testing-library/react": "^14.0.0",
"@testing-library/user-event": "^14.4.3", "@testing-library/user-event": "^14.4.3",
"@total-typescript/shoehorn": "^0.1.0", "@total-typescript/shoehorn": "^0.1.0",
"@types/json2csv": "^5.0.3", "@types/json2csv": "^5.0.3",
@ -74,7 +74,6 @@
"adm-zip": "^0.5.10", "adm-zip": "^0.5.10",
"chalk": "^5.2.0", "chalk": "^5.2.0",
"eslint": "^8.30.0", "eslint": "^8.30.0",
"identity-obj-proxy": "^3.0.0",
"jsdom": "^22.0.0", "jsdom": "^22.0.0",
"resize-observer-polyfill": "^1.5.1", "resize-observer-polyfill": "^1.5.1",
"sass": "^1.57.1", "sass": "^1.57.1",
@ -2695,21 +2694,22 @@
} }
}, },
"node_modules/@testing-library/dom": { "node_modules/@testing-library/dom": {
"version": "8.13.0", "version": "9.3.0",
"resolved": "https://registry.npmjs.org/@testing-library/dom/-/dom-9.3.0.tgz",
"integrity": "sha512-Dffe68pGwI6WlLRYR2I0piIkyole9cSBH5jGQKCGMRpHW5RHCqAUaqc2Kv0tUyd4dU4DLPKhJIjyKOnjv4tuUw==",
"dev": true, "dev": true,
"license": "MIT",
"dependencies": { "dependencies": {
"@babel/code-frame": "^7.10.4", "@babel/code-frame": "^7.10.4",
"@babel/runtime": "^7.12.5", "@babel/runtime": "^7.12.5",
"@types/aria-query": "^4.2.0", "@types/aria-query": "^5.0.1",
"aria-query": "^5.0.0", "aria-query": "^5.0.0",
"chalk": "^4.1.0", "chalk": "^4.1.0",
"dom-accessibility-api": "^0.5.9", "dom-accessibility-api": "^0.5.9",
"lz-string": "^1.4.4", "lz-string": "^1.5.0",
"pretty-format": "^27.0.2" "pretty-format": "^27.0.2"
}, },
"engines": { "engines": {
"node": ">=12" "node": ">=14"
} }
}, },
"node_modules/@testing-library/dom/node_modules/ansi-styles": { "node_modules/@testing-library/dom/node_modules/ansi-styles": {
@ -2865,16 +2865,17 @@
} }
}, },
"node_modules/@testing-library/react": { "node_modules/@testing-library/react": {
"version": "13.4.0", "version": "14.0.0",
"resolved": "https://registry.npmjs.org/@testing-library/react/-/react-14.0.0.tgz",
"integrity": "sha512-S04gSNJbYE30TlIMLTzv6QCTzt9AqIF5y6s6SzVFILNcNvbV/jU96GeiTPillGQo+Ny64M/5PV7klNYYgv5Dfg==",
"dev": true, "dev": true,
"license": "MIT",
"dependencies": { "dependencies": {
"@babel/runtime": "^7.12.5", "@babel/runtime": "^7.12.5",
"@testing-library/dom": "^8.5.0", "@testing-library/dom": "^9.0.0",
"@types/react-dom": "^18.0.0" "@types/react-dom": "^18.0.0"
}, },
"engines": { "engines": {
"node": ">=12" "node": ">=14"
}, },
"peerDependencies": { "peerDependencies": {
"react": "^18.0.0", "react": "^18.0.0",
@ -2908,9 +2909,10 @@
"dev": true "dev": true
}, },
"node_modules/@types/aria-query": { "node_modules/@types/aria-query": {
"version": "4.2.2", "version": "5.0.1",
"dev": true, "resolved": "https://registry.npmjs.org/@types/aria-query/-/aria-query-5.0.1.tgz",
"license": "MIT" "integrity": "sha512-XTIieEY+gvJ39ChLcB4If5zHtPxt3Syj5rgZR+e1ctpmK8NjPf0zFqsz4JpLJT0xla9GFDKjy8Cpu331nrmE1Q==",
"dev": true
}, },
"node_modules/@types/babel__core": { "node_modules/@types/babel__core": {
"version": "7.1.20", "version": "7.1.20",
@ -5984,11 +5986,6 @@
"node": ">=6" "node": ">=6"
} }
}, },
"node_modules/harmony-reflect": {
"version": "1.6.1",
"dev": true,
"license": "(Apache-2.0 OR MPL-1.1)"
},
"node_modules/has": { "node_modules/has": {
"version": "1.0.3", "version": "1.0.3",
"license": "MIT", "license": "MIT",
@ -6162,17 +6159,6 @@
"version": "7.1.1", "version": "7.1.1",
"license": "ISC" "license": "ISC"
}, },
"node_modules/identity-obj-proxy": {
"version": "3.0.0",
"dev": true,
"license": "MIT",
"dependencies": {
"harmony-reflect": "^1.4.6"
},
"engines": {
"node": ">=4"
}
},
"node_modules/ignore": { "node_modules/ignore": {
"version": "5.2.4", "version": "5.2.4",
"dev": true, "dev": true,
@ -7327,9 +7313,10 @@
} }
}, },
"node_modules/lz-string": { "node_modules/lz-string": {
"version": "1.4.4", "version": "1.5.0",
"resolved": "https://registry.npmjs.org/lz-string/-/lz-string-1.5.0.tgz",
"integrity": "sha512-h5bgJWpxJNswbU7qCrV0tIKQCaS3blPDrqKWx+QxzuzL1zGUzij9XCWLrSLsJPu5t+eWA/ycetzYAO5IOMcWAQ==",
"dev": true, "dev": true,
"license": "WTFPL",
"bin": { "bin": {
"lz-string": "bin/bin.js" "lz-string": "bin/bin.js"
} }
@ -12283,16 +12270,18 @@
} }
}, },
"@testing-library/dom": { "@testing-library/dom": {
"version": "8.13.0", "version": "9.3.0",
"resolved": "https://registry.npmjs.org/@testing-library/dom/-/dom-9.3.0.tgz",
"integrity": "sha512-Dffe68pGwI6WlLRYR2I0piIkyole9cSBH5jGQKCGMRpHW5RHCqAUaqc2Kv0tUyd4dU4DLPKhJIjyKOnjv4tuUw==",
"dev": true, "dev": true,
"requires": { "requires": {
"@babel/code-frame": "^7.10.4", "@babel/code-frame": "^7.10.4",
"@babel/runtime": "^7.12.5", "@babel/runtime": "^7.12.5",
"@types/aria-query": "^4.2.0", "@types/aria-query": "^5.0.1",
"aria-query": "^5.0.0", "aria-query": "^5.0.0",
"chalk": "^4.1.0", "chalk": "^4.1.0",
"dom-accessibility-api": "^0.5.9", "dom-accessibility-api": "^0.5.9",
"lz-string": "^1.4.4", "lz-string": "^1.5.0",
"pretty-format": "^27.0.2" "pretty-format": "^27.0.2"
}, },
"dependencies": { "dependencies": {
@ -12390,11 +12379,13 @@
} }
}, },
"@testing-library/react": { "@testing-library/react": {
"version": "13.4.0", "version": "14.0.0",
"resolved": "https://registry.npmjs.org/@testing-library/react/-/react-14.0.0.tgz",
"integrity": "sha512-S04gSNJbYE30TlIMLTzv6QCTzt9AqIF5y6s6SzVFILNcNvbV/jU96GeiTPillGQo+Ny64M/5PV7klNYYgv5Dfg==",
"dev": true, "dev": true,
"requires": { "requires": {
"@babel/runtime": "^7.12.5", "@babel/runtime": "^7.12.5",
"@testing-library/dom": "^8.5.0", "@testing-library/dom": "^9.0.0",
"@types/react-dom": "^18.0.0" "@types/react-dom": "^18.0.0"
} }
}, },
@ -12414,7 +12405,9 @@
"dev": true "dev": true
}, },
"@types/aria-query": { "@types/aria-query": {
"version": "4.2.2", "version": "5.0.1",
"resolved": "https://registry.npmjs.org/@types/aria-query/-/aria-query-5.0.1.tgz",
"integrity": "sha512-XTIieEY+gvJ39ChLcB4If5zHtPxt3Syj5rgZR+e1ctpmK8NjPf0zFqsz4JpLJT0xla9GFDKjy8Cpu331nrmE1Q==",
"dev": true "dev": true
}, },
"@types/babel__core": { "@types/babel__core": {
@ -14486,10 +14479,6 @@
"version": "2.1.0", "version": "2.1.0",
"dev": true "dev": true
}, },
"harmony-reflect": {
"version": "1.6.1",
"dev": true
},
"has": { "has": {
"version": "1.0.3", "version": "1.0.3",
"requires": { "requires": {
@ -14594,13 +14583,6 @@
"idb": { "idb": {
"version": "7.1.1" "version": "7.1.1"
}, },
"identity-obj-proxy": {
"version": "3.0.0",
"dev": true,
"requires": {
"harmony-reflect": "^1.4.6"
}
},
"ignore": { "ignore": {
"version": "5.2.4", "version": "5.2.4",
"dev": true "dev": true
@ -15321,7 +15303,9 @@
} }
}, },
"lz-string": { "lz-string": {
"version": "1.4.4", "version": "1.5.0",
"resolved": "https://registry.npmjs.org/lz-string/-/lz-string-1.5.0.tgz",
"integrity": "sha512-h5bgJWpxJNswbU7qCrV0tIKQCaS3blPDrqKWx+QxzuzL1zGUzij9XCWLrSLsJPu5t+eWA/ycetzYAO5IOMcWAQ==",
"dev": true "dev": true
}, },
"magic-string": { "magic-string": {

View file

@ -72,7 +72,7 @@
"@shlinkio/eslint-config-js-coding-standard": "~2.1.0", "@shlinkio/eslint-config-js-coding-standard": "~2.1.0",
"@shlinkio/stylelint-config-css-coding-standard": "~1.0.1", "@shlinkio/stylelint-config-css-coding-standard": "~1.0.1",
"@testing-library/jest-dom": "^5.16.5", "@testing-library/jest-dom": "^5.16.5",
"@testing-library/react": "^13.4.0", "@testing-library/react": "^14.0.0",
"@testing-library/user-event": "^14.4.3", "@testing-library/user-event": "^14.4.3",
"@total-typescript/shoehorn": "^0.1.0", "@total-typescript/shoehorn": "^0.1.0",
"@types/json2csv": "^5.0.3", "@types/json2csv": "^5.0.3",
@ -91,7 +91,6 @@
"adm-zip": "^0.5.10", "adm-zip": "^0.5.10",
"chalk": "^5.2.0", "chalk": "^5.2.0",
"eslint": "^8.30.0", "eslint": "^8.30.0",
"identity-obj-proxy": "^3.0.0",
"jsdom": "^22.0.0", "jsdom": "^22.0.0",
"resize-observer-polyfill": "^1.5.1", "resize-observer-polyfill": "^1.5.1",
"sass": "^1.57.1", "sass": "^1.57.1",

View file

@ -17,8 +17,6 @@ describe('ShlinkApiClient', () => {
['abc123', 'example.com'], ['abc123', 'example.com'],
]; ];
beforeEach(vi.clearAllMocks);
describe('listShortUrls', () => { describe('listShortUrls', () => {
const expectedList = ['foo', 'bar']; const expectedList = ['foo', 'bar'];

View file

@ -32,8 +32,6 @@ describe('<App />', () => {
); );
}; };
afterEach(vi.clearAllMocks);
it('renders children components', () => { it('renders children components', () => {
setUp(); setUp();

View file

@ -7,8 +7,6 @@ describe('<AppUpdateBanner />', () => {
const forceUpdate = vi.fn(); const forceUpdate = vi.fn();
const setUp = () => renderWithEvents(<AppUpdateBanner isOpen toggle={toggle} forceUpdate={forceUpdate} />); const setUp = () => renderWithEvents(<AppUpdateBanner isOpen toggle={toggle} forceUpdate={forceUpdate} />);
afterEach(vi.clearAllMocks);
it('renders initial state', () => { it('renders initial state', () => {
setUp(); setUp();

View file

@ -18,7 +18,6 @@ describe('<ErrorHandler />', () => {
beforeEach(() => { beforeEach(() => {
vi.spyOn(console, 'error').mockImplementation(() => {}); // Silence react errors vi.spyOn(console, 'error').mockImplementation(() => {}); // Silence react errors
}); });
afterEach(vi.resetAllMocks);
it('renders children when no error has occurred', () => { it('renders children when no error has occurred', () => {
render(<ErrorHandler children={<span>Foo</span>} />); render(<ErrorHandler children={<span>Foo</span>} />);

View file

@ -44,8 +44,6 @@ describe('<MenuLayout />', () => {
(useParams as any).mockReturnValue({ serverId: 'abc123' }); (useParams as any).mockReturnValue({ serverId: 'abc123' });
}); });
afterEach(vi.clearAllMocks);
it('shows loading indicator while loading server', () => { it('shows loading indicator while loading server', () => {
setUp(null); setUp(null);

View file

@ -4,8 +4,6 @@ describe('HttpClient', () => {
const fetch = vi.fn(); const fetch = vi.fn();
const httpClient = new HttpClient(fetch); const httpClient = new HttpClient(fetch);
beforeEach(vi.clearAllMocks);
describe('fetchJson', () => { describe('fetchJson', () => {
it('throws json on success', async () => { it('throws json on success', async () => {
const theError = { error: true, foo: 'bar' }; const theError = { error: true, foo: 'bar' };

View file

@ -7,7 +7,6 @@ describe('ReportExporter', () => {
const jsonToCsv = vi.fn(); const jsonToCsv = vi.fn();
let exporter: ReportExporter; let exporter: ReportExporter;
beforeEach(vi.clearAllMocks);
beforeEach(() => { beforeEach(() => {
(global as any).Blob = class Blob {}; (global as any).Blob = class Blob {};
(global as any).URL = { createObjectURL: () => '' }; (global as any).URL = { createObjectURL: () => '' };

View file

@ -16,8 +16,6 @@ describe('<DomainSelector />', () => {
<DomainSelector value={value} domainsList={domainsList} listDomains={vi.fn()} onChange={vi.fn()} />, <DomainSelector value={value} domainsList={domainsList} listDomains={vi.fn()} onChange={vi.fn()} />,
); );
afterEach(vi.clearAllMocks);
it.each([ it.each([
['', 'Domain', 'domains-dropdown__toggle-btn'], ['', 'Domain', 'domains-dropdown__toggle-btn'],
['my-domain.com', 'Domain: my-domain.com', 'domains-dropdown__toggle-btn--active'], ['my-domain.com', 'Domain: my-domain.com', 'domains-dropdown__toggle-btn--active'],

View file

@ -20,8 +20,6 @@ describe('<ManageDomains />', () => {
/>, />,
); );
afterEach(vi.clearAllMocks);
it('shows loading message while domains are loading', () => { it('shows loading message while domains are loading', () => {
setUp(fromPartial({ loading: true, filteredDomains: [] })); setUp(fromPartial({ loading: true, filteredDomains: [] }));

View file

@ -19,8 +19,6 @@ describe('<DomainDropdown />', () => {
</MemoryRouter>, </MemoryRouter>,
); );
afterEach(vi.clearAllMocks);
it('renders expected menu items', () => { it('renders expected menu items', () => {
setUp(); setUp();

View file

@ -10,8 +10,6 @@ describe('<DomainStatusIcon />', () => {
<DomainStatusIcon status={status} matchMedia={matchMedia} />, <DomainStatusIcon status={status} matchMedia={matchMedia} />,
); );
beforeEach(vi.clearAllMocks);
it.each([ it.each([
['validating' as DomainStatus], ['validating' as DomainStatus],
['invalid' as DomainStatus], ['invalid' as DomainStatus],

View file

@ -17,8 +17,6 @@ describe('<EditDomainRedirectsModal />', () => {
<EditDomainRedirectsModal domain={domain} isOpen toggle={toggle} editDomainRedirects={editDomainRedirects} />, <EditDomainRedirectsModal domain={domain} isOpen toggle={toggle} editDomainRedirects={editDomainRedirects} />,
); );
afterEach(vi.clearAllMocks);
it('renders domain in header', () => { it('renders domain in header', () => {
setUp(); setUp();
expect(screen.getByRole('heading')).toHaveTextContent('Edit redirects for foo.com'); expect(screen.getByRole('heading')).toHaveTextContent('Edit redirects for foo.com');

View file

@ -4,8 +4,6 @@ import type { ShlinkDomainRedirects } from '../../../src/api/types';
import { editDomainRedirects } from '../../../src/domains/reducers/domainRedirects'; import { editDomainRedirects } from '../../../src/domains/reducers/domainRedirects';
describe('domainRedirectsReducer', () => { describe('domainRedirectsReducer', () => {
beforeEach(vi.clearAllMocks);
describe('editDomainRedirects', () => { describe('editDomainRedirects', () => {
const domain = 'example.com'; const domain = 'example.com';
const redirects = fromPartial<ShlinkDomainRedirects>({}); const redirects = fromPartial<ShlinkDomainRedirects>({});

View file

@ -30,8 +30,6 @@ describe('domainsListReducer', () => {
editDomainRedirectsThunk, editDomainRedirectsThunk,
); );
beforeEach(vi.clearAllMocks);
describe('reducer', () => { describe('reducer', () => {
it('returns loading on LIST_DOMAINS_START', () => { it('returns loading on LIST_DOMAINS_START', () => {
expect(reducer(undefined, listDomainsAction.pending(''))).toEqual( expect(reducer(undefined, listDomainsAction.pending(''))).toEqual(

View file

@ -7,8 +7,6 @@ import type { MercureInfo } from '../../../src/mercure/reducers/mercureInfo';
vi.mock('event-source-polyfill'); vi.mock('event-source-polyfill');
describe('helpers', () => { describe('helpers', () => {
afterEach(vi.resetAllMocks);
describe('bindToMercureTopic', () => { describe('bindToMercureTopic', () => {
const onMessage = vi.fn(); const onMessage = vi.fn();
const onTokenExpired = vi.fn(); const onTokenExpired = vi.fn();

View file

@ -12,8 +12,6 @@ describe('mercureInfoReducer', () => {
const buildShlinkApiClient = () => fromPartial<ShlinkApiClient>({ mercureInfo: getMercureInfo }); const buildShlinkApiClient = () => fromPartial<ShlinkApiClient>({ mercureInfo: getMercureInfo });
const { loadMercureInfo, reducer } = mercureInfoReducerCreator(buildShlinkApiClient); const { loadMercureInfo, reducer } = mercureInfoReducerCreator(buildShlinkApiClient);
beforeEach(vi.resetAllMocks);
describe('reducer', () => { describe('reducer', () => {
it('returns loading on GET_MERCURE_INFO_START', () => { it('returns loading on GET_MERCURE_INFO_START', () => {
expect(reducer(undefined, loadMercureInfo.pending(''))).toEqual({ expect(reducer(undefined, loadMercureInfo.pending(''))).toEqual({

View file

@ -28,8 +28,6 @@ describe('<CreateServer />', () => {
return renderWithEvents(<CreateServer createServers={createServersMock} servers={servers} />); return renderWithEvents(<CreateServer createServers={createServersMock} servers={servers} />);
}; };
beforeEach(vi.clearAllMocks);
it('shows success message when imported is true', () => { it('shows success message when imported is true', () => {
setUp(true); setUp(true);

View file

@ -30,8 +30,6 @@ describe('<DeleteServerModal />', () => {
); );
}; };
afterEach(vi.clearAllMocks);
it('renders a modal window', () => { it('renders a modal window', () => {
setUp(); setUp();

View file

@ -31,8 +31,6 @@ describe('<EditServer />', () => {
(useNavigate as any).mockReturnValue(navigate); (useNavigate as any).mockReturnValue(navigate);
}); });
afterEach(vi.clearAllMocks);
it('renders nothing if selected server is not reachable', () => { it('renders nothing if selected server is not reachable', () => {
setUp(fromPartial<SelectedServer>({})); setUp(fromPartial<SelectedServer>({}));

View file

@ -23,8 +23,6 @@ describe('<ManageServers />', () => {
<MemoryRouter><ManageServers servers={servers} /></MemoryRouter>, <MemoryRouter><ManageServers servers={servers} /></MemoryRouter>,
); );
afterEach(vi.clearAllMocks);
it('shows search field which allows searching servers, affecting te amount of rendered rows', async () => { it('shows search field which allows searching servers, affecting te amount of rendered rows', async () => {
const { user } = setUp({ const { user } = setUp({
foo: createServerMock('foo'), foo: createServerMock('foo'),

View file

@ -19,8 +19,6 @@ describe('<ManageServersRowDropdown />', () => {
); );
}; };
afterEach(vi.clearAllMocks);
it('renders expected amount of dropdown items', async () => { it('renders expected amount of dropdown items', async () => {
const { user } = setUp(); const { user } = setUp();

View file

@ -12,8 +12,6 @@ describe('<DuplicatedServersModal />', () => {
); );
const mockServer = (data: Partial<ServerData> = {}) => fromPartial<ServerData>(data); const mockServer = (data: Partial<ServerData> = {}) => fromPartial<ServerData>(data);
beforeEach(vi.clearAllMocks);
it.each([ it.each([
[[], 0], [[], 0],
[[mockServer()], 2], [[mockServer()], 2],

View file

@ -24,8 +24,6 @@ describe('<ImportServersBtn />', () => {
/>, />,
); );
afterEach(vi.clearAllMocks);
it('shows tooltip on button hover', async () => { it('shows tooltip on button hover', async () => {
const { user } = setUp(); const { user } = setUp();

View file

@ -5,8 +5,6 @@ describe('<ServerForm />', () => {
const onSubmit = vi.fn(); const onSubmit = vi.fn();
const setUp = () => render(<ServerForm onSubmit={onSubmit}>Something</ServerForm>); const setUp = () => render(<ServerForm onSubmit={onSubmit}>Something</ServerForm>);
afterEach(vi.resetAllMocks);
it('renders components', () => { it('renders components', () => {
setUp(); setUp();

View file

@ -3,8 +3,6 @@ import type { HttpClient } from '../../../src/common/services/HttpClient';
import { fetchServers } from '../../../src/servers/reducers/remoteServers'; import { fetchServers } from '../../../src/servers/reducers/remoteServers';
describe('remoteServersReducer', () => { describe('remoteServersReducer', () => {
afterEach(vi.clearAllMocks);
describe('fetchServers', () => { describe('fetchServers', () => {
const dispatch = vi.fn(); const dispatch = vi.fn();
const fetchJson = vi.fn(); const fetchJson = vi.fn();

View file

@ -19,8 +19,6 @@ describe('selectedServerReducer', () => {
const selectServer = selectServerCreator(buildApiClient); const selectServer = selectServerCreator(buildApiClient);
const { reducer } = selectedServerReducerCreator(selectServer); const { reducer } = selectedServerReducerCreator(selectServer);
afterEach(vi.clearAllMocks);
describe('reducer', () => { describe('reducer', () => {
it('returns default when action is RESET_SELECTED_SERVER', () => it('returns default when action is RESET_SELECTED_SERVER', () =>
expect(reducer(null, resetSelectedServer())).toBeNull()); expect(reducer(null, resetSelectedServer())).toBeNull());

View file

@ -15,8 +15,6 @@ describe('serversReducer', () => {
def456: fromPartial({ id: 'def456' }), def456: fromPartial({ id: 'def456' }),
}; };
afterEach(vi.clearAllMocks);
describe('reducer', () => { describe('reducer', () => {
it('returns edited server when action is EDIT_SERVER', () => it('returns edited server when action is EDIT_SERVER', () =>
expect(serversReducer(list, editServer('abc123', { name: 'foo' }))).toEqual({ expect(serversReducer(list, editServer('abc123', { name: 'foo' }))).toEqual({

View file

@ -23,8 +23,6 @@ describe('ServersExporter', () => {
}); });
const createCsvjsonMock = (throwError = false) => (throwError ? erroneousToCsv : vi.fn(() => '')); const createCsvjsonMock = (throwError = false) => (throwError ? erroneousToCsv : vi.fn(() => ''));
beforeEach(vi.clearAllMocks);
describe('exportServers', () => { describe('exportServers', () => {
let originalConsole: Console; let originalConsole: Console;
const error = vi.fn(); const error = vi.fn();

View file

@ -14,8 +14,6 @@ describe('ServersImporter', () => {
}); });
const importer = new ServersImporter(csvjsonMock, () => fileReaderMock); const importer = new ServersImporter(csvjsonMock, () => fileReaderMock);
beforeEach(vi.clearAllMocks);
describe('importServersFromFile', () => { describe('importServersFromFile', () => {
it('rejects with error if no file was provided', async () => { it('rejects with error if no file was provided', async () => {
await expect(importer.importServersFromFile()).rejects.toEqual( await expect(importer.importServersFromFile()).rejects.toEqual(

View file

@ -17,8 +17,6 @@ describe('<RealTimeUpdatesSettings />', () => {
/>, />,
); );
afterEach(vi.clearAllMocks);
it('renders enabled real time updates as expected', () => { it('renders enabled real time updates as expected', () => {
setUp({ enabled: true }); setUp({ enabled: true });

View file

@ -13,8 +13,6 @@ describe('<ShortUrlCreationSettings />', () => {
/>, />,
); );
afterEach(vi.clearAllMocks);
it.each([ it.each([
[{ validateUrls: true }, true], [{ validateUrls: true }, true],
[{ validateUrls: false }, false], [{ validateUrls: false }, false],

View file

@ -11,8 +11,6 @@ describe('<ShortUrlsListSettings />', () => {
<ShortUrlsListSettings settings={fromPartial({ shortUrlsList })} setShortUrlsListSettings={setSettings} />, <ShortUrlsListSettings settings={fromPartial({ shortUrlsList })} setShortUrlsListSettings={setSettings} />,
); );
afterEach(vi.clearAllMocks);
it.each([ it.each([
[undefined, 'Order by: Created at - DESC'], [undefined, 'Order by: Created at - DESC'],
[{}, 'Order by: Created at - DESC'], [{}, 'Order by: Created at - DESC'],

View file

@ -11,8 +11,6 @@ describe('<TagsSettings />', () => {
<TagsSettings settings={fromPartial({ tags })} setTagsSettings={setTagsSettings} />, <TagsSettings settings={fromPartial({ tags })} setTagsSettings={setTagsSettings} />,
); );
afterEach(vi.clearAllMocks);
it('renders expected amount of groups', () => { it('renders expected amount of groups', () => {
setUp(); setUp();

View file

@ -11,8 +11,6 @@ describe('<UserInterfaceSettings />', () => {
<UserInterfaceSettings settings={fromPartial({ ui })} setUiSettings={setUiSettings} />, <UserInterfaceSettings settings={fromPartial({ ui })} setUiSettings={setUiSettings} />,
); );
afterEach(vi.clearAllMocks);
it.each([ it.each([
[{ theme: 'dark' as Theme }, true], [{ theme: 'dark' as Theme }, true],
[{ theme: 'light' as Theme }, false], [{ theme: 'light' as Theme }, false],

View file

@ -10,8 +10,6 @@ describe('<VisitsSettings />', () => {
<VisitsSettings settings={fromPartial(settings)} setVisitsSettings={setVisitsSettings} />, <VisitsSettings settings={fromPartial(settings)} setVisitsSettings={setVisitsSettings} />,
); );
afterEach(vi.clearAllMocks);
it('renders expected components', () => { it('renders expected components', () => {
setUp(); setUp();

View file

@ -23,8 +23,6 @@ describe('<ShortUrlForm />', () => {
/>, />,
); );
afterEach(vi.clearAllMocks);
it.each([ it.each([
[ [
async (user: UserEvent) => { async (user: UserEvent) => {

View file

@ -36,8 +36,6 @@ describe('<ShortUrlsFilteringBar />', () => {
); );
}; };
afterEach(vi.clearAllMocks);
it('renders expected children components', () => { it('renders expected children components', () => {
setUp(); setUp();

View file

@ -51,8 +51,6 @@ describe('<ShortUrlsList />', () => {
(useNavigate as any).mockReturnValue(navigate); (useNavigate as any).mockReturnValue(navigate);
}); });
afterEach(vi.clearAllMocks);
it('wraps expected components', () => { it('wraps expected components', () => {
setUp(); setUp();

View file

@ -15,8 +15,6 @@ describe('<ShortUrlsTable />', () => {
<ShortUrlsTable shortUrlsList={shortUrlsList} selectedServer={server} orderByColumn={() => orderByColumn} />, <ShortUrlsTable shortUrlsList={shortUrlsList} selectedServer={server} orderByColumn={() => orderByColumn} />,
); );
afterEach(vi.resetAllMocks);
it('should render inner table by default', () => { it('should render inner table by default', () => {
setUp(); setUp();
expect(screen.getByRole('table')).toBeInTheDocument(); expect(screen.getByRole('table')).toBeInTheDocument();

View file

@ -13,8 +13,6 @@ describe('<CreateShortUrlResult />', () => {
<CreateShortUrlResult resetCreateShortUrl={() => {}} creation={creation} />, <CreateShortUrlResult resetCreateShortUrl={() => {}} creation={creation} />,
); );
afterEach(vi.clearAllMocks);
it('renders an error when error is true', () => { it('renders an error when error is true', () => {
setUp({ error: true, saved: false, saving: false }); setUp({ error: true, saved: false, saving: false });
expect(screen.getByText('An error occurred while creating the URL :(')).toBeInTheDocument(); expect(screen.getByText('An error occurred while creating the URL :(')).toBeInTheDocument();

View file

@ -31,8 +31,6 @@ describe('<DeleteShortUrlModal />', () => {
/>, />,
); );
afterEach(vi.clearAllMocks);
it('shows generic error when non-threshold error occurs', () => { it('shows generic error when non-threshold error occurs', () => {
setUp({ setUp({
loading: false, loading: false,

View file

@ -19,8 +19,6 @@ describe('<ExportShortUrlsBtn />', () => {
</MemoryRouter>, </MemoryRouter>,
); );
afterEach(vi.clearAllMocks);
it.each([ it.each([
[undefined, '0'], [undefined, '0'],
[1, '1'], [1, '1'],

View file

@ -17,8 +17,6 @@ describe('<QrCodeModal />', () => {
/>, />,
); );
afterEach(vi.clearAllMocks);
it('shows an external link to the URL in the header', () => { it('shows an external link to the URL in the header', () => {
setUp(); setUp();
const externalLink = screen.getByRole('heading').querySelector('a'); const externalLink = screen.getByRole('heading').querySelector('a');

View file

@ -10,8 +10,6 @@ describe('<QrErrorCorrectionDropdown />', () => {
<QrErrorCorrectionDropdown errorCorrection={initialErrorCorrection} setErrorCorrection={setErrorCorrection} />, <QrErrorCorrectionDropdown errorCorrection={initialErrorCorrection} setErrorCorrection={setErrorCorrection} />,
); );
afterEach(vi.clearAllMocks);
it('renders initial state', async () => { it('renders initial state', async () => {
const { user } = setUp(); const { user } = setUp();
const btn = screen.getByRole('button'); const btn = screen.getByRole('button');

View file

@ -8,8 +8,6 @@ describe('<QrFormatDropdown />', () => {
const setFormat = vi.fn(); const setFormat = vi.fn();
const setUp = () => renderWithEvents(<QrFormatDropdown format={initialFormat} setFormat={setFormat} />); const setUp = () => renderWithEvents(<QrFormatDropdown format={initialFormat} setFormat={setFormat} />);
afterEach(vi.clearAllMocks);
it('renders initial state', async () => { it('renders initial state', async () => {
const { user } = setUp(); const { user } = setUp();
const btn = screen.getByRole('button'); const btn = screen.getByRole('button');

View file

@ -14,8 +14,6 @@ describe('shortUrlCreationReducer', () => {
const createShortUrl = createShortUrlCreator(buildShlinkApiClient); const createShortUrl = createShortUrlCreator(buildShlinkApiClient);
const { reducer, resetCreateShortUrl } = shortUrlCreationReducerCreator(createShortUrl); const { reducer, resetCreateShortUrl } = shortUrlCreationReducerCreator(createShortUrl);
afterEach(vi.resetAllMocks);
describe('reducer', () => { describe('reducer', () => {
it('returns loading on CREATE_SHORT_URL_START', () => { it('returns loading on CREATE_SHORT_URL_START', () => {
expect(reducer(undefined, createShortUrl.pending('', fromPartial({})))).toEqual({ expect(reducer(undefined, createShortUrl.pending('', fromPartial({})))).toEqual({

View file

@ -12,8 +12,6 @@ describe('shortUrlDeletionReducer', () => {
const deleteShortUrl = deleteShortUrlCreator(buildShlinkApiClient); const deleteShortUrl = deleteShortUrlCreator(buildShlinkApiClient);
const { reducer, resetDeleteShortUrl } = shortUrlDeletionReducerCreator(deleteShortUrl); const { reducer, resetDeleteShortUrl } = shortUrlDeletionReducerCreator(deleteShortUrl);
beforeEach(vi.clearAllMocks);
describe('reducer', () => { describe('reducer', () => {
it('returns loading on DELETE_SHORT_URL_START', () => it('returns loading on DELETE_SHORT_URL_START', () =>
expect(reducer(undefined, deleteShortUrl.pending('', { shortCode: '' }))).toEqual({ expect(reducer(undefined, deleteShortUrl.pending('', { shortCode: '' }))).toEqual({

View file

@ -10,8 +10,6 @@ describe('shortUrlDetailReducer', () => {
const buildShlinkApiClient = () => fromPartial<ShlinkApiClient>({ getShortUrl: getShortUrlCall }); const buildShlinkApiClient = () => fromPartial<ShlinkApiClient>({ getShortUrl: getShortUrlCall });
const { reducer, getShortUrlDetail } = shortUrlDetailReducerCreator(buildShlinkApiClient); const { reducer, getShortUrlDetail } = shortUrlDetailReducerCreator(buildShlinkApiClient);
beforeEach(vi.clearAllMocks);
describe('reducer', () => { describe('reducer', () => {
it('returns loading on GET_SHORT_URL_DETAIL_START', () => { it('returns loading on GET_SHORT_URL_DETAIL_START', () => {
const { loading } = reducer({ loading: false, error: false }, getShortUrlDetail.pending('', { shortCode: '' })); const { loading } = reducer({ loading: false, error: false }, getShortUrlDetail.pending('', { shortCode: '' }));

View file

@ -16,8 +16,6 @@ describe('shortUrlEditionReducer', () => {
const editShortUrl = editShortUrlCreator(buildShlinkApiClient); const editShortUrl = editShortUrlCreator(buildShlinkApiClient);
const { reducer } = shortUrlEditionReducerCreator(editShortUrl); const { reducer } = shortUrlEditionReducerCreator(editShortUrl);
afterEach(vi.clearAllMocks);
describe('reducer', () => { describe('reducer', () => {
it('returns loading on EDIT_SHORT_URL_START', () => { it('returns loading on EDIT_SHORT_URL_START', () => {
expect(reducer(undefined, editShortUrl.pending('', fromPartial({})))).toEqual({ expect(reducer(undefined, editShortUrl.pending('', fromPartial({})))).toEqual({
@ -51,8 +49,6 @@ describe('shortUrlEditionReducer', () => {
selectedServer, selectedServer,
}); });
afterEach(vi.clearAllMocks);
it.each([[undefined], [null], ['example.com']])('dispatches short URL on success', async (domain) => { it.each([[undefined], [null], ['example.com']])('dispatches short URL on success', async (domain) => {
await editShortUrl({ shortCode, domain, data: { longUrl } })(dispatch, createGetState(), {}); await editShortUrl({ shortCode, domain, data: { longUrl } })(dispatch, createGetState(), {});

View file

@ -21,8 +21,6 @@ describe('shortUrlsListReducer', () => {
const createShortUrl = createShortUrlCreator(buildShlinkApiClient); const createShortUrl = createShortUrlCreator(buildShlinkApiClient);
const { reducer } = shortUrlsListReducerCreator(listShortUrls, editShortUrl, createShortUrl); const { reducer } = shortUrlsListReducerCreator(listShortUrls, editShortUrl, createShortUrl);
afterEach(vi.clearAllMocks);
describe('reducer', () => { describe('reducer', () => {
it('returns loading on LIST_SHORT_URLS_START', () => it('returns loading on LIST_SHORT_URLS_START', () =>
expect(reducer(undefined, listShortUrls.pending(''))).toEqual({ expect(reducer(undefined, listShortUrls.pending(''))).toEqual({

View file

@ -21,8 +21,6 @@ describe('<TagsList />', () => {
/>, />,
); );
afterEach(vi.clearAllMocks);
it('shows a loading message when tags are being loaded', () => { it('shows a loading message when tags are being loaded', () => {
setUp({ loading: true }); setUp({ loading: true });

View file

@ -26,7 +26,9 @@ describe('<TagsTable />', () => {
); );
}; };
afterEach(vi.clearAllMocks); afterEach(() => {
vi.clearAllMocks();
});
it('renders empty result if there are no tags', () => { it('renders empty result if there are no tags', () => {
setUp(); setUp();

View file

@ -18,8 +18,6 @@ describe('<DeleteTagConfirmModal />', () => {
/>, />,
); );
afterEach(vi.resetAllMocks);
it('asks confirmation for provided tag to be deleted', () => { it('asks confirmation for provided tag to be deleted', () => {
setUp({ error: false, deleted: false, deleting: false }); setUp({ error: false, deleted: false, deleting: false });

View file

@ -15,8 +15,6 @@ describe('<EditTagModal />', () => {
); );
}; };
afterEach(vi.clearAllMocks);
it('allows modal to be toggled with different mechanisms', async () => { it('allows modal to be toggled with different mechanisms', async () => {
const { user } = setUp(); const { user } = setUp();

View file

@ -31,8 +31,6 @@ describe('<Tag />', () => {
</Tag>, </Tag>,
); );
afterEach(vi.clearAllMocks);
it.each([ it.each([
[true], [true],
[false], [false],

View file

@ -20,8 +20,6 @@ describe('<TagsSelector />', () => {
/>, />,
); );
afterEach(vi.clearAllMocks);
it('has an input for tags', () => { it('has an input for tags', () => {
setUp(); setUp();
expect(screen.getByPlaceholderText('Add tags to the URL')).toBeInTheDocument(); expect(screen.getByPlaceholderText('Add tags to the URL')).toBeInTheDocument();

View file

@ -8,8 +8,6 @@ describe('tagDeleteReducer', () => {
const buildShlinkApiClient = () => fromPartial<ShlinkApiClient>({ deleteTags: deleteTagsCall }); const buildShlinkApiClient = () => fromPartial<ShlinkApiClient>({ deleteTags: deleteTagsCall });
const { reducer, deleteTag } = tagDeleteReducerCreator(buildShlinkApiClient); const { reducer, deleteTag } = tagDeleteReducerCreator(buildShlinkApiClient);
beforeEach(vi.clearAllMocks);
describe('reducer', () => { describe('reducer', () => {
it('returns loading on DELETE_TAG_START', () => { it('returns loading on DELETE_TAG_START', () => {
expect(reducer(undefined, deleteTag.pending('', ''))).toEqual({ expect(reducer(undefined, deleteTag.pending('', ''))).toEqual({

View file

@ -53,8 +53,6 @@ describe('tagEditReducer', () => {
const dispatch = vi.fn(); const dispatch = vi.fn();
const getState = () => fromPartial<ShlinkState>({}); const getState = () => fromPartial<ShlinkState>({});
afterEach(vi.clearAllMocks);
it('calls API on success', async () => { it('calls API on success', async () => {
editTagCall.mockResolvedValue(undefined); editTagCall.mockResolvedValue(undefined);

View file

@ -21,8 +21,6 @@ describe('tagsListReducer', () => {
const createShortUrl = createShortUrlCreator(buildShlinkApiClient); const createShortUrl = createShortUrlCreator(buildShlinkApiClient);
const { reducer } = tagsListReducerCreator(listTags, createShortUrl); const { reducer } = tagsListReducerCreator(listTags, createShortUrl);
afterEach(vi.clearAllMocks);
describe('reducer', () => { describe('reducer', () => {
it('returns loading on LIST_TAGS_START', () => { it('returns loading on LIST_TAGS_START', () => {
expect(reducer(undefined, listTags.pending(''))).toEqual(expect.objectContaining({ expect(reducer(undefined, listTags.pending(''))).toEqual(expect.objectContaining({

View file

@ -5,8 +5,6 @@ describe('<CopyToClipboardIcon />', () => {
const onCopy = vi.fn(); const onCopy = vi.fn();
const setUp = (text = 'foo') => renderWithEvents(<CopyToClipboardIcon text={text} onCopy={onCopy} />); const setUp = (text = 'foo') => renderWithEvents(<CopyToClipboardIcon text={text} onCopy={onCopy} />);
afterEach(vi.clearAllMocks);
it('wraps expected components', () => { it('wraps expected components', () => {
const { container } = setUp(); const { container } = setUp();
expect(container).toMatchSnapshot(); expect(container).toMatchSnapshot();

View file

@ -13,8 +13,6 @@ describe('<PaginationDropdown />', () => {
return result; return result;
}; };
afterEach(vi.clearAllMocks);
it('renders expected amount of items', async () => { it('renders expected amount of items', async () => {
await setUp(); await setUp();
expect(screen.getAllByRole('menuitem')).toHaveLength(5); expect(screen.getAllByRole('menuitem')).toHaveLength(5);

View file

@ -20,8 +20,6 @@ describe('<DateIntervalDropdownItems />', () => {
return { user, ...renderResult }; return { user, ...renderResult };
}; };
afterEach(vi.clearAllMocks);
it('renders expected amount of items', async () => { it('renders expected amount of items', async () => {
await setUp(); await setUp();

View file

@ -9,8 +9,6 @@ describe('<DateRangeRow />', () => {
<DateRangeRow onEndDateChange={onEndDateChange} onStartDateChange={onStartDateChange} />, <DateRangeRow onEndDateChange={onEndDateChange} onStartDateChange={onStartDateChange} />,
); );
afterEach(vi.clearAllMocks);
it('renders two date inputs', () => { it('renders two date inputs', () => {
setUp(); setUp();
expect(screen.getAllByRole('textbox')).toHaveLength(2); expect(screen.getAllByRole('textbox')).toHaveLength(2);

View file

@ -22,8 +22,6 @@ describe('<DateRangeSelector />', () => {
return result; return result;
}; };
afterEach(vi.clearAllMocks);
it('renders proper amount of items', async () => { it('renders proper amount of items', async () => {
const { container } = await setUp(); const { container } = await setUp();

View file

@ -28,8 +28,6 @@ describe('<VisitsTable />', () => {
], ],
}); });
afterEach(vi.resetAllMocks);
it('renders expected amount of columns', () => { it('renders expected amount of columns', () => {
setUp([], []); setUp([], []);
expect(screen.getAllByRole('columnheader')).toHaveLength(8); expect(screen.getAllByRole('columnheader')).toHaveLength(8);

View file

@ -13,8 +13,6 @@ describe('<VisitsFilterDropdown />', () => {
/>, />,
); );
beforeEach(vi.clearAllMocks);
it('has expected text', () => { it('has expected text', () => {
setUp(); setUp();
expect(screen.getByRole('button', { name: 'Filters' })).toBeInTheDocument(); expect(screen.getByRole('button', { name: 'Filters' })).toBeInTheDocument();

View file

@ -26,8 +26,6 @@ describe('domainVisitsReducer', () => {
const getDomainVisits = getDomainVisitsCreator(buildApiClientMock); const getDomainVisits = getDomainVisitsCreator(buildApiClientMock);
const { reducer, cancelGetVisits: cancelGetDomainVisits } = domainVisitsReducerCreator(getDomainVisits); const { reducer, cancelGetVisits: cancelGetDomainVisits } = domainVisitsReducerCreator(getDomainVisits);
beforeEach(vi.clearAllMocks);
describe('reducer', () => { describe('reducer', () => {
const buildState = (data: Partial<DomainVisits>) => fromPartial<DomainVisits>(data); const buildState = (data: Partial<DomainVisits>) => fromPartial<DomainVisits>(data);

View file

@ -22,8 +22,6 @@ describe('nonOrphanVisitsReducer', () => {
const getNonOrphanVisits = getNonOrphanVisitsCreator(buildShlinkApiClient); const getNonOrphanVisits = getNonOrphanVisitsCreator(buildShlinkApiClient);
const { reducer, cancelGetVisits: cancelGetNonOrphanVisits } = nonOrphanVisitsReducerCreator(getNonOrphanVisits); const { reducer, cancelGetVisits: cancelGetNonOrphanVisits } = nonOrphanVisitsReducerCreator(getNonOrphanVisits);
beforeEach(vi.clearAllMocks);
describe('reducer', () => { describe('reducer', () => {
const buildState = (data: Partial<VisitsInfo>) => fromPartial<VisitsInfo>(data); const buildState = (data: Partial<VisitsInfo>) => fromPartial<VisitsInfo>(data);
@ -124,8 +122,6 @@ describe('nonOrphanVisitsReducer', () => {
orphanVisits: { cancelLoad: false }, orphanVisits: { cancelLoad: false },
}); });
beforeEach(vi.resetAllMocks);
it.each([ it.each([
[undefined], [undefined],
[{}], [{}],

View file

@ -22,8 +22,6 @@ describe('orphanVisitsReducer', () => {
const getOrphanVisits = getOrphanVisitsCreator(buildShlinkApiClientMock); const getOrphanVisits = getOrphanVisitsCreator(buildShlinkApiClientMock);
const { reducer, cancelGetVisits: cancelGetOrphanVisits } = orphanVisitsReducerCreator(getOrphanVisits); const { reducer, cancelGetVisits: cancelGetOrphanVisits } = orphanVisitsReducerCreator(getOrphanVisits);
beforeEach(vi.clearAllMocks);
describe('reducer', () => { describe('reducer', () => {
const buildState = (data: Partial<VisitsInfo>) => fromPartial<VisitsInfo>(data); const buildState = (data: Partial<VisitsInfo>) => fromPartial<VisitsInfo>(data);

View file

@ -23,8 +23,6 @@ describe('shortUrlVisitsReducer', () => {
const getShortUrlVisits = getShortUrlVisitsCreator(buildApiClientMock); const getShortUrlVisits = getShortUrlVisitsCreator(buildApiClientMock);
const { reducer, cancelGetVisits: cancelGetShortUrlVisits } = shortUrlVisitsReducerCreator(getShortUrlVisits); const { reducer, cancelGetVisits: cancelGetShortUrlVisits } = shortUrlVisitsReducerCreator(getShortUrlVisits);
beforeEach(vi.clearAllMocks);
describe('reducer', () => { describe('reducer', () => {
const buildState = (data: Partial<ShortUrlVisits>) => fromPartial<ShortUrlVisits>(data); const buildState = (data: Partial<ShortUrlVisits>) => fromPartial<ShortUrlVisits>(data);

View file

@ -23,8 +23,6 @@ describe('tagVisitsReducer', () => {
const getTagVisits = getTagVisitsCreator(buildShlinkApiClientMock); const getTagVisits = getTagVisitsCreator(buildShlinkApiClientMock);
const { reducer, cancelGetVisits: cancelGetTagVisits } = tagVisitsReducerCreator(getTagVisits); const { reducer, cancelGetVisits: cancelGetTagVisits } = tagVisitsReducerCreator(getTagVisits);
beforeEach(vi.clearAllMocks);
describe('reducer', () => { describe('reducer', () => {
const buildState = (data: Partial<TagVisits>) => fromPartial<TagVisits>(data); const buildState = (data: Partial<TagVisits>) => fromPartial<TagVisits>(data);

View file

@ -19,8 +19,6 @@ describe('visitsOverviewReducer', () => {
const loadVisitsOverview = loadVisitsOverviewCreator(buildApiClientMock); const loadVisitsOverview = loadVisitsOverviewCreator(buildApiClientMock);
const { reducer } = visitsOverviewReducerCreator(loadVisitsOverview); const { reducer } = visitsOverviewReducerCreator(loadVisitsOverview);
beforeEach(vi.clearAllMocks);
describe('reducer', () => { describe('reducer', () => {
const state = (payload: Partial<VisitsOverview> = {}) => fromPartial<VisitsOverview>(payload); const state = (payload: Partial<VisitsOverview> = {}) => fromPartial<VisitsOverview>(payload);

View file

@ -41,10 +41,10 @@ export default defineConfig({
], ],
// Required code coverage. Lower than this will make the check fail // Required code coverage. Lower than this will make the check fail
statements: 90, statements: 95,
branches: 80, branches: 90,
functions: 85, functions: 90,
lines: 90, lines: 95,
}, },
deps: { deps: {
inline: ['vitest-canvas-mock'], inline: ['vitest-canvas-mock'],