Skip to content

Commit

Permalink
chore: add another test case
Browse files Browse the repository at this point in the history
  • Loading branch information
sdrejkarz committed May 15, 2024
1 parent 1c3942d commit 6577199
Showing 1 changed file with 22 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ describe('Notifications: Component', () => {
expect(await screen.findByText('Notifications')).toBeInTheDocument();
});

it('Should call notification event', async () => {
it('Should call notification event for proper type', async () => {
const notificationType = NotificationTypes.TENANT_INVITATION_CREATED;

const apolloMocks = [
Expand All @@ -61,9 +61,29 @@ describe('Notifications: Component', () => {
const events = { [notificationType]: mockEvent };

const { waitForApolloMocks } = render(<Component events={events} />, { apolloMocks });

await waitForApolloMocks();

expect(mockEvent).toHaveBeenCalled();
});

it('Should not call notification event if there is no proper type', async () => {
const notificationType = NotificationTypes.TENANT_INVITATION_CREATED;

const apolloMocks = [
fillCommonQueryWithUser(),
fillNotificationCreatedSubscriptionQuery(
notificationFactory({
type: 'some_random_type_that_doesnt_exist',
})
),
];

const mockEvent = jest.fn();
const events = { [notificationType]: mockEvent };

const { waitForApolloMocks } = render(<Component events={events} />, { apolloMocks });
await waitForApolloMocks();

expect(mockEvent).not.toHaveBeenCalled();
});
});

0 comments on commit 6577199

Please sign in to comment.