Skip to content

Commit

Permalink
test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
kifrud committed Dec 9, 2023
1 parent 94fabfc commit 8fdfe02
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/core/toast.cy.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react';
import { ToastContainer } from '../components';
import { toast } from './toast';
import { Default } from '../utils';

beforeEach(() => {
cy.viewport('macbook-15');
Expand Down Expand Up @@ -84,6 +85,23 @@ describe('with container', () => {
});
});

it('remove toast by button', () => {
toast.onChange(cy.stub().as('onChange'));

toast('msg', { data: 'xxxx' });

cy.resolveEntranceAnimation();

cy.findByText('msg').should('exist');

cy.get(`.${Default.CSS_NAMESPACE}__close-button`).click();

cy.get('@onChange').should('have.been.calledWithMatch', {
status: 'removed by button'
});
cy.findByText('msg').should('not.exist');
});

it('unsubscribe from change event', () => {
const unsub = toast.onChange(cy.stub().as('onChange'));
unsub();
Expand Down

0 comments on commit 8fdfe02

Please sign in to comment.