hms181231
2 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with
2 additions and
3 deletions
-
components/message/__tests__/config.test.ts
|
@ -1,6 +1,6 @@ |
|
|
import { act } from 'react-dom/test-utils'; |
|
|
import { act } from 'react-dom/test-utils'; |
|
|
import message, { getInstance } from '..'; |
|
|
import message, { getInstance } from '..'; |
|
|
import { sleep } from '../../../tests/utils'; |
|
|
import { waitFakeTimer } from '../../../tests/utils'; |
|
|
import ConfigProvider from '../../config-provider'; |
|
|
import ConfigProvider from '../../config-provider'; |
|
|
|
|
|
|
|
|
describe('message.config', () => { |
|
|
describe('message.config', () => { |
|
@ -87,7 +87,6 @@ describe('message.config', () => { |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
it('should be able to config duration', async () => { |
|
|
it('should be able to config duration', async () => { |
|
|
jest.useRealTimers(); |
|
|
|
|
|
message.config({ |
|
|
message.config({ |
|
|
duration: 0.5, |
|
|
duration: 0.5, |
|
|
}); |
|
|
}); |
|
@ -97,7 +96,7 @@ describe('message.config', () => { |
|
|
}); |
|
|
}); |
|
|
expect(getInstance()?.component.state.notices).toHaveLength(1); |
|
|
expect(getInstance()?.component.state.notices).toHaveLength(1); |
|
|
|
|
|
|
|
|
await sleep(1000); |
|
|
await waitFakeTimer(); |
|
|
expect(getInstance()?.component.state.notices).toHaveLength(0); |
|
|
expect(getInstance()?.component.state.notices).toHaveLength(0); |
|
|
message.config({ |
|
|
message.config({ |
|
|
duration: 3, |
|
|
duration: 3, |
|
|