Skip to content

Commit

Permalink
test(reference): adjust test as we only re-render if there are conten…
Browse files Browse the repository at this point in the history
…t types []
  • Loading branch information
chrishelgert committed Jan 15, 2025
1 parent 462bdfc commit a28bf15
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion packages/reference/src/common/useEditorPermissions.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,14 @@ describe('useEditorPermissions', () => {
allContentTypes = [],
customizeMock,
customizeSdk,
waitForUpdate = false,
}: {
entityType: EditorPermissionsProps['entityType'];
params?: EditorPermissionsProps['parameters']['instance'];
allContentTypes?: EditorPermissionsProps['allContentTypes'];
customizeMock?: (fieldApi: FieldAPI) => FieldAPI;
customizeSdk?: (sdk: MockedFieldAppSDK) => void;
waitForUpdate?: boolean;
}) => {
const sdk = makeFieldAppSDK(customizeMock);
customizeSdk?.(sdk);
Expand All @@ -52,7 +54,9 @@ describe('useEditorPermissions', () => {
})
);

await renderResult.waitForNextUpdate();
if (waitForUpdate) {
await renderResult.waitForNextUpdate();
}

return { ...renderResult, sdk };
};
Expand Down Expand Up @@ -129,6 +133,7 @@ describe('useEditorPermissions', () => {
customizeSdk: (sdk) => {
allowContentTypes(sdk, 'create', 'one');
},
waitForUpdate: true,
});

expect(result.current.canCreateEntity).toBe(true);
Expand Down Expand Up @@ -157,6 +162,7 @@ describe('useEditorPermissions', () => {
customizeSdk: (sdk) => {
allowContentTypes(sdk, 'read', 'one');
},
waitForUpdate: true,
});

expect(result.current.canLinkEntity).toBe(true);
Expand Down

0 comments on commit a28bf15

Please sign in to comment.