test: Back of test coverage (#24418)

* test: Back of test coverage

* move rtl test out
This commit is contained in:
二货机器人 2020-05-24 00:12:29 +08:00 committed by GitHub
parent 03e6b33681
commit faa75d592c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 19 additions and 18 deletions

View File

@ -0,0 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Collapse rtl render component should be rendered correctly in RTL direction 1`] = `
<div
class="ant-collapse ant-collapse-icon-position-right ant-collapse-rtl"
/>
`;

View File

@ -49,12 +49,6 @@ exports[`Collapse could override default openAnimation 1`] = `
</div> </div>
`; `;
exports[`Collapse rtl render component should be rendered correctly in RTL direction 1`] = `
<div
class="ant-collapse ant-collapse-icon-position-right ant-collapse-rtl"
/>
`;
exports[`Collapse should render extra node of panel 1`] = ` exports[`Collapse should render extra node of panel 1`] = `
<div <div
class="ant-collapse ant-collapse-icon-position-left" class="ant-collapse ant-collapse-icon-position-left"

View File

@ -0,0 +1,8 @@
import mountTest from '../../../tests/shared/mountTest';
import rtlTest from '../../../tests/shared/rtlTest';
import Collapse from '..';
describe('Collapse', () => {
mountTest(Collapse);
rtlTest(Collapse);
});

View File

@ -1,7 +1,5 @@
import React from 'react'; import React from 'react';
import { mount } from 'enzyme'; import { mount } from 'enzyme';
import mountTest from '../../../tests/shared/mountTest';
import rtlTest from '../../../tests/shared/rtlTest';
import { sleep } from '../../../tests/utils'; import { sleep } from '../../../tests/utils';
describe('Collapse', () => { describe('Collapse', () => {
@ -18,8 +16,6 @@ describe('Collapse', () => {
// eslint-disable-next-line global-require // eslint-disable-next-line global-require
const Collapse = require('..').default; const Collapse = require('..').default;
mountTest(Collapse);
rtlTest(Collapse);
it('should support remove expandIcon', () => { it('should support remove expandIcon', () => {
const wrapper = mount( const wrapper = mount(
@ -65,11 +61,10 @@ describe('Collapse', () => {
</Collapse>, </Collapse>,
); );
expect(wrapper.find('.ant-collapse-item').hasClass('ant-collapse-item-active')).toBe(false); expect(wrapper.find('.ant-collapse-item').hasClass('ant-collapse-item-active')).toBe(false);
wrapper wrapper.find('.ant-collapse-header').at(0).simulate('click');
.find('.ant-collapse-header') wrapper.update();
.at(0)
.simulate('click');
await sleep(400); await sleep(400);
wrapper.update();
expect(wrapper.find('.ant-collapse-item').hasClass('ant-collapse-item-active')).toBe(true); expect(wrapper.find('.ant-collapse-item').hasClass('ant-collapse-item-active')).toBe(true);
}); });
@ -81,10 +76,7 @@ describe('Collapse', () => {
</Collapse.Panel> </Collapse.Panel>
</Collapse>, </Collapse>,
); );
wrapper wrapper.find('.ant-collapse-header').at(0).simulate('click');
.find('.ant-collapse-header')
.at(0)
.simulate('click');
expect(wrapper.render()).toMatchSnapshot(); expect(wrapper.render()).toMatchSnapshot();
}); });
}); });