Skip to content

Commit

Permalink
tests: add closeButton tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tutkli committed Apr 16, 2024
1 parent f216e8d commit eefd385
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions libs/ngx-sonner/src/tests/toaster.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -263,14 +263,25 @@ describe('Toaster', () => {
expect(closeButton).not.toBeNull();
});

it('should not show close button if the toast is not dismissible', async () => {
it('should not show close button if the toast has closeButton false', async () => {
const { user, trigger, container } = await setup({
callback: toast => toast('Hello world', { dismissible: false }),
callback: toast => toast('Hello world', { closeButton: false }),
closeButton: true,
});

await user.click(trigger);
const closeButton = container.querySelector('[data-close-button]');
expect(closeButton).toBeNull();
});

it('should show close button if the toast has closeButton true', async () => {
const { user, trigger, container } = await setup({
callback: toast => toast('Hello world', { closeButton: true }),
closeButton: false,
});

await user.click(trigger);
const closeButton = container.querySelector('[data-close-button]');
expect(closeButton).not.toBeNull();
});
});

0 comments on commit eefd385

Please sign in to comment.