/* eslint-disable jsx-a11y/control-has-associated-label */
import React from 'react';
import { act } from 'react-dom/test-utils';
import message from '..';
import { fireEvent, render } from '../../../tests/utils';
import ConfigProvider from '../../config-provider';
import { triggerMotionEnd } from './util';
describe('message.hooks', () => {
beforeEach(() => {
jest.useFakeTimers();
});
afterEach(() => {
jest.useRealTimers();
});
it('should work', () => {
const Context = React.createContext('light');
const Demo = () => {
const [api, holder] = message.useMessage();
return (
);
};
const { container } = render();
fireEvent.click(container.querySelector('button')!);
expect(document.querySelectorAll('.my-test-message-notice')).toHaveLength(1);
expect(document.querySelector('.hook-test-result')!.textContent).toEqual('bamboo');
});
it('should work with success', () => {
const Context = React.createContext('light');
const Demo = () => {
const [api, holder] = message.useMessage();
return (
);
};
const { container } = render();
fireEvent.click(container.querySelector('button')!);
expect(document.querySelectorAll('.my-test-message-notice')).toHaveLength(1);
expect(document.querySelectorAll('.anticon-check-circle')).toHaveLength(1);
expect(document.querySelector('.hook-test-result')!.textContent).toEqual('bamboo');
});
it('should work with onClose', done => {
const Demo = () => {
const [api, holder] = message.useMessage();
return (
<>