import React from 'react'; import { mountWithContexts } from '../enzymeHelpers'; import NotificationListItem from '../../src/components/NotificationsList/NotificationListItem'; describe('', () => { let wrapper; const toggleNotification = jest.fn(); afterEach(() => { if (wrapper) { wrapper.unmount(); wrapper = null; } }); test('initially renders succesfully', () => { wrapper = mountWithContexts( ); expect(wrapper.length).toBe(1); }); test('handles success click when toggle is on', () => { wrapper = mountWithContexts( ); wrapper.find('Switch').first().find('input').simulate('change'); expect(toggleNotification).toHaveBeenCalledWith(9000, true, 'success'); }); test('handles success click when toggle is off', () => { wrapper = mountWithContexts( ); wrapper.find('Switch').first().find('input').simulate('change'); expect(toggleNotification).toHaveBeenCalledWith(9000, false, 'success'); }); test('handles error click when toggle is on', () => { wrapper = mountWithContexts( ); wrapper.find('Switch').at(1).find('input').simulate('change'); expect(toggleNotification).toHaveBeenCalledWith(9000, true, 'error'); }); test('handles error click when toggle is off', () => { wrapper = mountWithContexts( ); wrapper.find('Switch').at(1).find('input').simulate('change'); expect(toggleNotification).toHaveBeenCalledWith(9000, false, 'error'); }); });