diff --git a/src/packages/Alert/test.tsx b/src/packages/Alert/test.tsx new file mode 100644 index 0000000..c317483 --- /dev/null +++ b/src/packages/Alert/test.tsx @@ -0,0 +1,42 @@ +import React from 'react' +import { render, screen } from '../../utils/testUtils' + +import Alert from '.' + +describe('', () => { + it('should render alert with the given header', () => { + const headerText = 'Header' + render( + +
This is an alert
+
+ ) + + expect(screen.getByText(headerText)).toBeInTheDocument() + }) + + it('should render alert with the given children', () => { + const childText = 'This is an alert' + render( + +
{childText}
+
+ ) + + expect(screen.getByText(childText)).toBeInTheDocument() + }) + + it('should call onClose function when close is clicked', () => { + const onCloseMockFn = jest.fn() + render( + +
This is an alert
+
+ ) + + const closeIcon = screen.getByText('X') + closeIcon!.click() + + expect(onCloseMockFn).toBeCalled() + }) +}) diff --git a/src/packages/index.ts b/src/packages/index.ts index b8013bf..cfb9ccc 100644 --- a/src/packages/index.ts +++ b/src/packages/index.ts @@ -28,4 +28,3 @@ export { default as Skeleton } from './Skeleton' export { default as Switch } from './Switch' export { default as Table } from './Table' export { default as Pagination } from './Pagination' -