Skip to content

Instantly share code, notes, and snippets.

@Keyes
Created September 21, 2020 15:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Keyes/1e1d86fefc607c719f23a76d230debeb to your computer and use it in GitHub Desktop.
Save Keyes/1e1d86fefc607c719f23a76d230debeb to your computer and use it in GitHub Desktop.
import { render, screen } from '@testing-library/react';
import React from 'react';
import Button from '.';
const testMessage = 'Test Message';
let container;
describe('basic functionality', () => {
beforeEach(() => {
// eslint-disable-next-line jsx-a11y/anchor-is-valid
container = render(<Button>{testMessage}</Button>).container;
});
test('renders the component', () => {
expect(screen.getByText(testMessage)).toBeInTheDocument();
});
test('has the correct class', () => {
expect(container.querySelector('.twf-button')).toBeInTheDocument();
});
});
describe('advanced functionality', () => {
beforeEach(() => {
// eslint-disable-next-line jsx-a11y/anchor-is-valid
container = render(<Button appearance="outline">{testMessage}</Button>).container;
});
test('has the correct class', () => {
expect(container.querySelector('.twf-button.twf-button__outline')).toBeInTheDocument();
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment