Skip to content

Commit

Permalink
fix(react-notifications): add async to skipped unit tests (#4856)
Browse files Browse the repository at this point in the history
  • Loading branch information
calebpollman authored Jan 9, 2024
1 parent 7b06660 commit f51b224
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 21 deletions.
20 changes: 4 additions & 16 deletions packages/react-notifications/jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,14 @@ const config: Config = {
// do not collect from top level styles file
'!<rootDir>/src/styles.ts',
],
// coverageThreshold: {
// global: {
// branches: 80,
// functions: 80,
// lines: 80,
// statements: 80,
// },
// },
coverageThreshold: {
global: {
branches: 67.18,
functions: 52.08,
lines: 58.19,
statements: 58.46,
branches: 95,
functions: 93,
lines: 95,
statements: 95,
},
},
// @todo-migration update test API usage and remove temp thresholds
testPathIgnorePatterns: [
'<rootDir>/src/components/InAppMessaging/MessageLayout/__tests__/MessageLayout.test.tsx',
],
moduleNameMapper: { '^uuid$': '<rootDir>/../../node_modules/uuid' },
modulePathIgnorePatterns: ['<rootDir>/dist/'],
preset: 'ts-jest',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,11 +124,11 @@ describe('MessageLayout component', () => {
expect(textContainer).toHaveClass(`${TEXT_CONTAINER_CLASS}--horizontal`);
});

it('should trigger onClose function', () => {
it('should trigger onClose function', async () => {
render(<MessageLayout {...TEST_PROPS} />);

const closeButton = screen.getByRole('button');
userEvent.click(closeButton);
await userEvent.click(closeButton);
expect(mockOnClose).toHaveBeenCalled();
});

Expand Down Expand Up @@ -172,7 +172,7 @@ describe('MessageLayout component', () => {
);
});

it('should trigger the button onAction functions', () => {
it('should trigger the button onAction functions', async () => {
render(
<MessageLayout
{...TEST_PROPS}
Expand All @@ -181,10 +181,11 @@ describe('MessageLayout component', () => {
/>
);

userEvent.click(screen.getByText(PRIMARY_BUTTON));
await userEvent.click(screen.getByText(PRIMARY_BUTTON));
expect(mockPrimaryButtonOnAction).toHaveBeenCalled();
expect(mockSecondaryButtonOnAction).not.toHaveBeenCalled();
userEvent.click(screen.getByText(SECONDARY_BUTTON));

await userEvent.click(screen.getByText(SECONDARY_BUTTON));
expect(mockSecondaryButtonOnAction).toHaveBeenCalled();
});

Expand Down

0 comments on commit f51b224

Please sign in to comment.