mirror of
https://gitee.com/ant-design/ant-design.git
synced 2024-12-05 05:28:20 +08:00
7322aa6f5f
This reverts commit 6759887c44
.
58 lines
1.4 KiB
TypeScript
58 lines
1.4 KiB
TypeScript
import React from 'react';
|
|
import notification, { actWrapper } from '..';
|
|
import { act, render, waitFakeTimer } from '../../../tests/utils';
|
|
import ConfigProvider from '../../config-provider';
|
|
import { awaitPromise, triggerMotionEnd } from './util';
|
|
|
|
describe('notification static warning', () => {
|
|
beforeAll(() => {
|
|
actWrapper(act);
|
|
});
|
|
|
|
beforeEach(() => {
|
|
jest.useFakeTimers();
|
|
});
|
|
|
|
afterEach(async () => {
|
|
// Clean up
|
|
notification.destroy();
|
|
await triggerMotionEnd();
|
|
|
|
jest.useRealTimers();
|
|
|
|
await awaitPromise();
|
|
});
|
|
|
|
// Follow test need keep order
|
|
it('no warning', async () => {
|
|
const errSpy = jest.spyOn(console, 'error').mockImplementation(() => {});
|
|
|
|
notification.open({
|
|
message: <div className="bamboo" />,
|
|
duration: 0,
|
|
});
|
|
await waitFakeTimer();
|
|
|
|
expect(document.querySelector('.bamboo')).toBeTruthy();
|
|
|
|
expect(errSpy).not.toHaveBeenCalled();
|
|
});
|
|
|
|
it('warning if use theme', async () => {
|
|
const errSpy = jest.spyOn(console, 'error').mockImplementation(() => {});
|
|
render(<ConfigProvider theme={{}} />);
|
|
|
|
notification.open({
|
|
message: <div className="light" />,
|
|
duration: 0,
|
|
});
|
|
await waitFakeTimer();
|
|
|
|
expect(document.querySelector('.light')).toBeTruthy();
|
|
|
|
expect(errSpy).toHaveBeenCalledWith(
|
|
"Warning: [antd: notification] Static function can not consume context like dynamic theme. Please use 'App' component instead.",
|
|
);
|
|
});
|
|
});
|