Add test case for wave

This commit is contained in:
afc163
2018-11-12 12:38:02 +08:00
committed by 偏右
parent 4ddde533ff
commit 233f1891d1
5 changed files with 52 additions and 0 deletions

View File

@@ -6,6 +6,9 @@ let styleForPesudo: HTMLStyleElement | null;
// Where el is the DOM element you'd like to test for visibility
function isHidden(element: HTMLElement) {
if (process.env.NODE_ENV === 'test') {
return false;
}
return !element || element.offsetParent === null;
}

View File

@@ -189,6 +189,18 @@ exports[`Button renders correctly 1`] = `
</button>
`;
exports[`Button should has click wave effect 1`] = `
<button
ant-click-animating-without-extra-node="true"
class="ant-btn ant-btn-primary"
type="button"
>
<span>
button
</span>
</button>
`;
exports[`Button should support link button 1`] = `
<a
class="ant-btn"

View File

@@ -143,4 +143,13 @@ describe('Button', () => {
);
expect(wrapper2).toMatchSnapshot();
});
it('should has click wave effect', async () => {
const wrapper = mount(
<Button type="primary">button</Button>
);
wrapper.find('.ant-btn').getDOMNode().click();
await new Promise(resolve => setTimeout(resolve, 0));
expect(wrapper.render()).toMatchSnapshot();
});
});

View File

@@ -0,0 +1,19 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Switch should has click wave effect 1`] = `
<button
ant-click-animating="true"
aria-checked="false"
class="ant-switch"
role="switch"
type="button"
>
<span
class="ant-switch-inner"
/>
<div
class="ant-click-animating-node"
style="border-color: buttonface;"
/>
</button>
`;

View File

@@ -1,6 +1,15 @@
import React from 'react';
import Switch from '..';
import { mount } from 'enzyme';
import focusTest from '../../../tests/shared/focusTest';
describe('Switch', () => {
focusTest(Switch);
it('should has click wave effect', async () => {
const wrapper = mount(<Switch />);
wrapper.find('.ant-switch').getDOMNode().click();
await new Promise(resolve => setTimeout(resolve, 0));
expect(wrapper.render()).toMatchSnapshot();
});
});