Files
freeCodeCamp/client/src/components/formHelpers/BlockSaveButton.test.js
Abdelrahman Ashraf 94532f98db refactor(tests): enzyme => react-testing-library (#37712)
* refactor: 💡 rewrite enzyme tests in react-testing-library

* fix: 🐛 remove enzyme imports from frame-runner.js

* chore: 🤖 install and add enzyme imports to frame-runner.js back
2019-11-08 16:50:25 +05:30

27 lines
740 B
JavaScript

/* global expect */
import '@testing-library/jest-dom/extend-expect';
import React from 'react';
import { render } from '@testing-library/react';
import BlockSaveButton from './BlockSaveButton';
test('<BlockSaveButton /> snapshot', () => {
const { container } = render(<BlockSaveButton />);
expect(container).toMatchSnapshot();
});
test('Button text should default to "Save"', () => {
const { getByRole } = render(<BlockSaveButton />);
expect(getByRole('button')).toHaveTextContent('Save');
});
test('Button text should match "children"', () => {
const testText = 'My Text Here';
const { getByRole } = render(<BlockSaveButton>{testText}</BlockSaveButton>);
expect(getByRole('button')).toHaveTextContent(testText);
});