chore: 修复一些单测容易报错的问题 (#6263)

This commit is contained in:
sansiro 2023-02-27 16:27:53 +08:00 committed by GitHub
parent 2647fff196
commit 65ef4a1f26
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 26 additions and 14 deletions

View File

@ -150,4 +150,4 @@ test('EventAction:inputRange', async () => {
});
expect(container).toMatchSnapshot();
});
}, 10000);

View File

@ -83,6 +83,7 @@ test('Renderer:chained-select', async () => {
})
)
);
await wait(500);
await waitFor(() => {
expect(fetcher).toBeCalledTimes(3);

View File

@ -21,12 +21,19 @@ import {
waitFor,
screen,
within,
getByText
getByText,
cleanup
} from '@testing-library/react';
import '../../../src';
import {render as amisRender} from '../../../src';
import {render as amisRender, clearStoresCache} from '../../../src';
import {makeEnv, wait} from '../../helper';
afterEach(() => {
cleanup();
clearStoresCache();
jest.useRealTimers();
});
const setup = async (items: any[] = [], env: any = {}) => {
const onSubmit = jest.fn();
const utils = render(

View File

@ -168,7 +168,7 @@ test('Renderer:inputArray with removable & addable & addButtonText', async () =>
});
expect(container).toMatchSnapshot('false');
});
}, 10000);
test('Renderer:inputArray with minLength & maxLength', async () => {
const {container} = await setup([

View File

@ -123,7 +123,7 @@ test('Renderer:inputCity', async () => {
});
await wait(200);
expect(container).toMatchSnapshot();
});
}, 10000);
// 2. searchable
test('Renderer:inputCity with searchable', async () => {

View File

@ -122,4 +122,4 @@ test('Renderer:inputMonth with dynamic minDate & maxDate', async () => {
expect(end.querySelector('.rdtMonth:not(.rdtDisabled)')!).toHaveTextContent(
'8月'
);
});
}, 10000);

View File

@ -143,7 +143,7 @@ test('Renderer: input-table with default value column', async () => {
]
});
});
});
}, 10000);
test('Renderer:input table add', async () => {
const {container, findByText} = render(

View File

@ -13,6 +13,7 @@ import {clearStoresCache} from '../../../src';
afterEach(() => {
cleanup();
clearStoresCache();
jest.useRealTimers();
});
const setupInputTag = async (inputTagOptions: any = {}) => {
@ -168,7 +169,7 @@ describe('Renderer:InputTag', () => {
expect(Banana).toBeNull();
expect(container).toMatchSnapshot();
}, 6000);
}, 10000);
test('InputTag input with maxTagLength 5', async () => {
const {container, input, queryByText} = await setupInputTag({
@ -194,5 +195,5 @@ describe('Renderer:InputTag', () => {
expect(Banana).toBeNull();
expect(container).toMatchSnapshot();
});
}, 10000);
});

View File

@ -94,7 +94,7 @@ test('Renderer:listSelect with multiple & clearable', async () => {
});
expect(container).toMatchSnapshot();
});
}, 10000);
test('Renderer:listSelect with image option & listClassName', async () => {
const {container, getByText} = render(

View File

@ -118,7 +118,7 @@ test('Renderer:range with multiple & clearable & delimiter', async () => {
).toBe('7--13');
expect(container).toMatchSnapshot();
});
}, 10000);
test('Renderer:range with showSteps', async () => {
const {container} = render(

View File

@ -144,7 +144,7 @@ test('Renderer:tabsTransfer', async () => {
expect(onSubmit.mock.calls[0][0]).toEqual({
a: 'zhugeliang,yunzhongjun2'
});
});
}, 10000);
test('Renderer:tabsTransfer with deferApi', async () => {
const fetcher = jest.fn().mockImplementation(() =>
@ -269,4 +269,4 @@ test('Renderer:tabsTransfer with deferApi', async () => {
expect(notify).toBeCalledTimes(1);
expect(container).toMatchSnapshot();
});
}, 10000);

View File

@ -189,4 +189,4 @@ test('Renderer:TabsTransferPicker', async () => {
await wait(1000);
expect(baseElement).toMatchSnapshot();
});
}, 10000);

View File

@ -878,6 +878,7 @@ test('Renderer:Page handleAction actionType=drawer mergeData', async () => {
expect(container).toMatchSnapshot();
fireEvent.click(getByText(/确认/));
await wait(300);
await waitFor(() => {
expect(container.querySelector('[role="dialog"]')).not.toBeInTheDocument();
});
@ -1004,6 +1005,7 @@ test('Renderer:Page handleAction actionType=ajax & feedback', async () => {
expect(container).toMatchSnapshot();
fireEvent.click(getByText(/确认/));
await wait(300);
await waitFor(() => {
expect(container.querySelector('[role="dialog"]')).not.toBeInTheDocument();
});
@ -1218,6 +1220,7 @@ test('Renderer:Page initApi reload by Dialog action', async () => {
expect(container).toMatchSnapshot();
fireEvent.click(getByText(/确认/));
await wait(500);
await waitFor(() => {
expect(container.querySelector('[role="dialog"]')).not.toBeInTheDocument();
expect(getByText('The variable value is 2')).toBeInTheDocument();