Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * @jest-environment jsdom
- */
- import React from 'react';
- import { cleanup, fireEvent, render } from '@testing-library/react';
- import CheckboxWithLabel from '../../js/fake_components/CheckboxWithLabel';
- // Note: running cleanup afterEach is done automatically for you in @testing-library/react@9.0.0 or higher
- // unmount and cleanup DOM after the test is finished.
- afterEach(cleanup);
- it('CheckboxWithLabel changes the text after click', () => {
- const { queryByLabelText, getByLabelText } = render(
- <CheckboxWithLabel labelOn="On" labelOff="Off" />
- );
- expect(queryByLabelText(/off/i)).toBeTruthy();
- fireEvent.click(getByLabelText(/off/i));
- expect(queryByLabelText(/on/i)).toBeTruthy();
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement