import React from 'react'; import { render, cleanup } from '@testing-library/react'; import '@testing-library/jest-dom/extend-expect'; import { Button } from './index'; afterEach(cleanup); test('should take a snapshot', () => { const { asFragment } = render( ); expect(getByTestId('button-id')).toBeInTheDocument(); expect(getByTestId('button-id-text')).toHaveTextContent( "Wowwee It's a button" ); }); }); describe('tests the Button variants', () => { test('tests the round variant', () => { const { getByTestId } = render( ); expect(getByTestId('button-id')).toBeInTheDocument(); expect(getByTestId('button-id')).toHaveStyle({ height: '2rem', width: '4rem', }); expect(getByTestId('button-id-text').tagName).toBe('SMALL'); }); test('tests large size', () => { const { getByTestId } = render( ); expect(getByTestId('button-id')).toBeInTheDocument(); expect(getByTestId('button-id')).toHaveStyle({ height: '4rem', width: '8rem', }); expect(getByTestId('button-id-text').tagName).toBe('P'); }); }); describe('tests the background prop', () => { test('tests light background', () => { const { getByTestId } = render( ); expect(getByTestId('button-id')).toBeInTheDocument(); expect(getByTestId('button-id')).toHaveStyle({ background: '#fff', color: '#00000f', }); }); test('tests dark background', () => { const { getByTestId } = render( ); expect(getByTestId('button-id')).toBeInTheDocument(); expect(getByTestId('button-id')).toHaveStyle({ background: '#000', color: '#fffffa', }); }); });