Created
September 23, 2020 21:31
-
-
Save lai32290/ad2c6ee3ab9cfb0a5114f1e57708980e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// __tests__/accordion.rtl.js | |
import '@testing-library/jest-dom/extend-expect' | |
import React from 'react' | |
import {render, screen} from '@testing-library/react' | |
import userEvent from '@testing-library/user-event' | |
import Accordion from '../accordion' | |
test('can open accordion items to see the contents', () => { | |
const hats = {title: 'Favorite Hats', contents: 'Fedoras are classy'} | |
const footware = { | |
title: 'Favorite Footware', | |
contents: 'Flipflops are the best', | |
} | |
render(<Accordion items={[hats, footware]} />) | |
expect(screen.getByText(hats.contents)).toBeInTheDocument() | |
expect(screen.queryByText(footware.contents)).not.toBeInTheDocument() | |
userEvent.click(screen.getByText(footware.title)) | |
expect(screen.getByText(footware.contents)).toBeInTheDocument() | |
expect(screen.queryByText(hats.contents)).not.toBeInTheDocument() | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment