-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
35 additions
and
1 deletion.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import React from 'react'; | ||
import userEvent from '@testing-library/user-event'; | ||
import { render, screen, waitFor } from '@testing-library/react'; | ||
import { mockAnimationsApi } from 'jsdom-testing-mocks'; | ||
import HeartButton from '.'; | ||
|
||
mockAnimationsApi(); | ||
|
||
describe('heartButton', () => { | ||
it('버튼을 클릭하면 하트가 변경되는지 테스트', async () => { | ||
const user = userEvent.setup(); | ||
let isButtonActive = true; | ||
|
||
const stateHandler = () => { | ||
isButtonActive = !isButtonActive; | ||
}; | ||
render( | ||
<HeartButton | ||
isButtonActive={isButtonActive} | ||
stateHandler={stateHandler} | ||
data-testid="heart-button" | ||
/>, | ||
); | ||
|
||
const button = screen.getByTestId('heart-button'); | ||
await user.click(button); | ||
|
||
await waitFor(() => { | ||
const content = screen.getByTestId('fullHeartIcon'); | ||
expect(content).toBeVisible(); | ||
}); | ||
}); | ||
}); |
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
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