Skip to content

Commit

Permalink
Test for delete
Browse files Browse the repository at this point in the history
  • Loading branch information
Seqi committed Apr 29, 2022
1 parent 41086dd commit ffd3d78
Showing 1 changed file with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { render, screen } from '@testing-library/react'
import userEvent from '@testing-library/user-event'
import { LoadoutCard } from './LoadoutCard'
import { buildLoadout, buildLoadoutWeapon } from 'test/builders'

Expand All @@ -13,6 +14,23 @@ describe('Loadout card', () => {
expect(screen.getByRole('heading')).toHaveTextContent(loadout.getTitle())
})

it('should be able to be deleted', async () => {
const loadout = buildLoadout()
const onClick = jest.fn()
const onDelete = jest.fn()

render(<LoadoutCard item={loadout} onClick={onClick} onDelete={onDelete} />)

const deleteButton = screen.getByRole('button', { name: 'delete' })
expect(deleteButton).toBeInTheDocument()

screen.debug(deleteButton)

await userEvent.click(deleteButton)

expect(onDelete).toHaveBeenCalled()
})

it('should show message if no weapons', () => {
const loadout = buildLoadout()
const onClick = jest.fn()
Expand Down

0 comments on commit ffd3d78

Please sign in to comment.