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

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

View File

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

View File

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

View File

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

View File

@@ -13,8 +13,6 @@ describe('<CreateShortUrlResult />', () => {
<CreateShortUrlResult resetCreateShortUrl={() => {}} creation={creation} />,
);
afterEach(vi.clearAllMocks);
it('renders an error when error is true', () => {
setUp({ error: true, saved: false, saving: false });
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', () => {
setUp({
loading: false,

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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