Merge pull request #16986 from strapi/fix/use-enterprise-tests

test: remove erroneous act calls
This commit is contained in:
Gustav Hansen 2023-06-12 16:02:18 +02:00 committed by GitHub
commit 9d554ec9aa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,4 +1,4 @@
import { act, renderHook } from '@testing-library/react';
import { renderHook, waitFor } from '@testing-library/react';
import { useEnterprise } from '../useEnterprise';
@ -29,11 +29,9 @@ describe('useEnterprise (EE)', () => {
test('Returns default data on first render and EE data on second', async () => {
const { result } = setup(CE_DATA_FIXTURE, async () => EE_DATA_FIXTURE);
await act(async () => {
expect(result.current).toBe(null);
});
expect(result.current).toBe(null);
expect(result.current).toBe(EE_DATA_FIXTURE);
await waitFor(() => expect(result.current).toBe(EE_DATA_FIXTURE));
});
test('Combines CE and EE data', async () => {
@ -43,30 +41,26 @@ describe('useEnterprise (EE)', () => {
},
});
await act(async () => {
expect(result.current).toBe(null);
});
expect(result.current).toBe(null);
expect(result.current).toStrictEqual([...CE_DATA_FIXTURE, ...EE_DATA_FIXTURE]);
await waitFor(() =>
expect(result.current).toStrictEqual([...CE_DATA_FIXTURE, ...EE_DATA_FIXTURE])
);
});
test('Returns EE data without custom combine', async () => {
const { result } = setup(CE_DATA_FIXTURE, async () => EE_DATA_FIXTURE);
await act(async () => {});
await act(async () => {
expect(result.current).toStrictEqual(EE_DATA_FIXTURE);
});
await waitFor(() => expect(result.current).toStrictEqual(EE_DATA_FIXTURE));
});
test('Returns a custom defaultValue on first render', async () => {
test('Returns a custom defaultValue on first render followed by the EE data', async () => {
const { result } = setup(CE_DATA_FIXTURE, async () => EE_DATA_FIXTURE, {
defaultValue: false,
});
await act(async () => {
expect(result.current).toBe(false);
});
expect(result.current).toBe(false);
await waitFor(() => expect(result.current).toStrictEqual(EE_DATA_FIXTURE));
});
});