Skip to content

Commit

Permalink
Fix: Dismiss all toasts in a single container
Browse files Browse the repository at this point in the history
  • Loading branch information
simgar98 committed Feb 22, 2024
1 parent edb231d commit 291d193
Showing 1 changed file with 44 additions and 1 deletion.
45 changes: 44 additions & 1 deletion src/core/toast.cy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,8 @@ describe('with container', () => {
describe('with multi containers', () => {
const Containers = {
First: 'first',
Second: 'second'
Second: 'second',
Third: 'third'
};

beforeEach(() => {
Expand All @@ -354,6 +355,13 @@ describe('with multi containers', () => {
containerId={Containers.Second}
closeOnClick
/>
<ToastContainer
autoClose={false}
position="bottom-right"
limit={10}
containerId={Containers.Third}
closeOnClick
/>
</>
);
});
Expand Down Expand Up @@ -409,6 +417,41 @@ describe('with multi containers', () => {
});
});

it('remove all toasts for a given container', () => {
const toastId = '123';

toast('first container', {
toastId,
containerId: Containers.First
});
toast('third container', {
toastId,
containerId: Containers.Third
});
toast('third container second toast', {
containerId: Containers.Third
});

cy.resolveEntranceAnimation();

cy.findByText('first container').should('exist');
cy.findByText('third container second toast').should('exist');
cy.findByText('third container')
.should('exist')
.then(() => {
toast.dismiss({
containerId: Containers.Third,
});

cy.resolveEntranceAnimation();

cy.findByText('first container').should('exist');
cy.findByText('third container').should('not.exist');
cy.findByText('third container second toast').should('not.exist');
cy.findByText('first container').should('exist');
});
});

it('clear waiting queue for a given container', () => {
toast('msg1-c1', {
containerId: Containers.First
Expand Down

0 comments on commit 291d193

Please sign in to comment.