diff --git a/ui/src/app/metadata/domain/provider/component/ProviderList.test.js b/ui/src/app/metadata/domain/provider/component/ProviderList.test.js index 768519d36..c45628109 100644 --- a/ui/src/app/metadata/domain/provider/component/ProviderList.test.js +++ b/ui/src/app/metadata/domain/provider/component/ProviderList.test.js @@ -1,6 +1,5 @@ import React from 'react'; import { render, screen } from '@testing-library/react'; -import { fc } from 'jest-fast-check'; import { ProviderList } from './ProviderList'; diff --git a/ui/src/app/notifications/component/NotificationItem.test.js b/ui/src/app/notifications/component/NotificationItem.test.js new file mode 100644 index 000000000..cd87d7521 --- /dev/null +++ b/ui/src/app/notifications/component/NotificationItem.test.js @@ -0,0 +1,37 @@ +import React from 'react'; +import { render, screen } from '@testing-library/react'; + +import { NotificationItem } from './NotificationItem'; +import { NotificationContext, Notifications } from '../hoc/Notifications'; + +jest.mock('../../i18n/hooks', () => ({ + useTranslation: (value) => value +})); + +describe('Notifcation Item', () => { + let context; + beforeEach(() => { + jest.useFakeTimers(); + + context = React.useContext(NotificationContext); + }) + + it('should change color based on type', () => { + render(, {wrapper: Notifications }); + const el = screen.getByText('foo'); + expect(el).toBeInTheDocument(); + expect(el).toHaveClass('alert-danger') + }); + + it('should dispatch an event if provided a timeout', () => { + + jest.spyOn(context, 'dispatch'); + + render(, { wrapper: Notifications }); + const el = screen.getByText('foo'); + + jest.runAllTimers(); + + expect(context.dispatch).toHaveBeenCalled(); + }); +})