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

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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