mirror of
https://github.com/ant-design/ant-design.git
synced 2024-12-23 23:18:36 +08:00
502dac12aa
* docs: fix code * feat: lint * feat: prettier * feat: test * feat: review * feat: format html * feat: format html
59 lines
1.4 KiB
TypeScript
59 lines
1.4 KiB
TypeScript
import React from 'react';
|
|
|
|
import message, { actWrapper } from '..';
|
|
import { act, render, waitFakeTimer } from '../../../tests/utils';
|
|
import ConfigProvider from '../../config-provider';
|
|
import { awaitPromise, triggerMotionEnd } from './util';
|
|
|
|
describe('message static warning', () => {
|
|
beforeAll(() => {
|
|
actWrapper(act);
|
|
});
|
|
|
|
beforeEach(() => {
|
|
jest.useFakeTimers();
|
|
});
|
|
|
|
afterEach(async () => {
|
|
// Clean up
|
|
message.destroy();
|
|
await triggerMotionEnd();
|
|
|
|
jest.useRealTimers();
|
|
|
|
await awaitPromise();
|
|
});
|
|
|
|
// Follow test need keep order
|
|
it('no warning', async () => {
|
|
const errSpy = jest.spyOn(console, 'error').mockImplementation(() => {});
|
|
|
|
message.success({
|
|
content: <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={{}} />);
|
|
|
|
message.success({
|
|
content: <div className="light" />,
|
|
duration: 0,
|
|
});
|
|
await waitFakeTimer();
|
|
|
|
expect(document.querySelector('.light')).toBeTruthy();
|
|
|
|
expect(errSpy).toHaveBeenCalledWith(
|
|
"Warning: [antd: message] Static function can not consume context like dynamic theme. Please use 'App' component instead.",
|
|
);
|
|
});
|
|
});
|