/* eslint-disable jsx-a11y/control-has-associated-label */
import React from 'react';
import { mount } from 'enzyme';
import message, { getInstance } from '..';
import ConfigProvider from '../../config-provider';
describe('message.hooks', () => {
beforeAll(() => {
jest.useFakeTimers();
});
afterAll(() => {
jest.useRealTimers();
});
afterEach(() => {
message.destroy();
});
it('should work', () => {
const Context = React.createContext('light');
const Demo = () => {
const [api, holder] = message.useMessage();
return (
);
};
const wrapper = mount();
wrapper.find('button').simulate('click');
expect(document.querySelectorAll('.my-test-message-notice').length).toBe(1);
expect(document.querySelector('.hook-test-result').innerHTML).toEqual('bamboo');
});
it('should work with success', () => {
const Context = React.createContext('light');
const Demo = () => {
const [api, holder] = message.useMessage();
return (
);
};
const wrapper = mount();
wrapper.find('button').simulate('click');
expect(document.querySelectorAll('.my-test-message-notice').length).toBe(1);
expect(document.querySelectorAll('.anticon-check-circle').length).toBe(1);
expect(document.querySelector('.hook-test-result').innerHTML).toEqual('bamboo');
});
it('should work with onClose', done => {
// if not use real timer, done won't be called
jest.useRealTimers();
const Demo = () => {
const [api, holder] = message.useMessage();
return (
<>