test: fix test warning regarding async suspension rendering
This commit is contained in:
parent
06acbab4d9
commit
8c9723cb0f
@ -1,7 +1,7 @@
|
||||
import { InfoOutlineIcon } from '@chakra-ui/icons';
|
||||
import { Tooltip, VStack, Text, Flex } from '@chakra-ui/react';
|
||||
import { workerClientBus } from './decrypt-worker/client.ts';
|
||||
import { DECRYPTION_WORKER_ACTION_NAME } from './decrypt-worker/constants';
|
||||
import { workerClientBus } from '~/decrypt-worker/client';
|
||||
import { DECRYPTION_WORKER_ACTION_NAME } from '~/decrypt-worker/constants';
|
||||
|
||||
import usePromise from 'react-promise-suspense';
|
||||
|
||||
@ -11,8 +11,9 @@ const getSDKVersion = async (): Promise<string> => {
|
||||
|
||||
export function SDKVersion() {
|
||||
const sdkVersion = usePromise(getSDKVersion, []);
|
||||
|
||||
return (
|
||||
<Flex as="span" pl="1" alignItems="center">
|
||||
<Flex as="span" pl="1" alignItems="center" data-testid="sdk-version">
|
||||
<Tooltip
|
||||
hasArrow
|
||||
placement="top"
|
||||
|
@ -1,9 +1,20 @@
|
||||
import { renderWithProviders, screen, waitFor } from '~/test-utils/test-helper';
|
||||
import App from '~/App';
|
||||
import { renderWithProviders, screen } from '~/test-utils/test-helper';
|
||||
|
||||
test('should be able to render App', () => {
|
||||
vi.mock('../decrypt-worker/client', () => {
|
||||
return {
|
||||
workerClientBus: {
|
||||
request: vi.fn().mockResolvedValue('dummy'),
|
||||
},
|
||||
};
|
||||
});
|
||||
|
||||
test('should be able to render App', async () => {
|
||||
renderWithProviders(<App />);
|
||||
|
||||
// Should eventually load sdk version
|
||||
await waitFor(() => screen.getByTestId('sdk-version'));
|
||||
|
||||
// Quick sanity check of known strings.
|
||||
expect(screen.getByText(/仅在浏览器内对文件进行解锁/i)).toBeInTheDocument();
|
||||
expect(screen.getByText(/UnlockMusic 团队/i)).toBeInTheDocument();
|
||||
|
Loading…
Reference in New Issue
Block a user