Files
freeCodeCamp/client/src/components/formHelpers/BlockSaveButton.test.js
2021-06-20 09:14:42 +02:00

24 lines
698 B
JavaScript

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 the correct translation key', () => {
const { getByRole } = render(<BlockSaveButton />);
expect(getByRole('button')).toHaveTextContent('buttons.save');
});
test('Button text should match "children"', () => {
const testText = 'My Text Here';
const { getByRole } = render(<BlockSaveButton>{testText}</BlockSaveButton>);
expect(getByRole('button')).toHaveTextContent(testText);
});