-
Notifications
You must be signed in to change notification settings - Fork 0
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
1 parent
a57ee8b
commit e7dcff9
Showing
5 changed files
with
47 additions
and
6 deletions.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import React from 'react'; | ||
import { render, fireEvent, cleanup } from '@testing-library/react'; | ||
import '@testing-library/jest-dom/extend-expect'; | ||
import Alert from './Alert'; | ||
|
||
afterEach(cleanup); | ||
|
||
test('关闭动画结束后触发的回调函数', () => { | ||
// 测试首次渲染和 effect | ||
const { getByTestId } = render(<Alert />); | ||
|
||
const label = getByTestId('label'); | ||
const button = getByTestId('button'); | ||
|
||
// expect(label).toHaveTextContent('You clicked 0 times'); | ||
// expect(document.title).toBe('You clicked 0 times'); | ||
|
||
// 测试第二次渲染和 effect | ||
fireEvent.click(button); | ||
// expect(label).toHaveTextContent('You clicked 1 times'); | ||
expect(document.body).toBeNull(); | ||
}); |
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
默认状态下的背景色及边框颜色取主色调
primary
,而非info。此外props.theme.palette[props.type || 'info'][50]建议使用空合并,即:props.theme.palette[props.type ??'primary'][50]。其中空合并为typescript新语法,可参考可选链式调用和空合并