From 233f1891d1c64bb60ad2fe43d932df175e376e34 Mon Sep 17 00:00:00 2001 From: afc163 Date: Mon, 12 Nov 2018 12:38:02 +0800 Subject: [PATCH] :white_check_mark: Add test case for wave --- components/_util/wave.tsx | 3 +++ .../__snapshots__/index.test.js.snap | 12 ++++++++++++ components/button/__tests__/index.test.js | 9 +++++++++ .../__snapshots__/index.test.js.snap | 19 +++++++++++++++++++ components/switch/__tests__/index.test.js | 9 +++++++++ 5 files changed, 52 insertions(+) create mode 100644 components/switch/__tests__/__snapshots__/index.test.js.snap diff --git a/components/_util/wave.tsx b/components/_util/wave.tsx index cf979cdd07..38df668d30 100644 --- a/components/_util/wave.tsx +++ b/components/_util/wave.tsx @@ -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; } diff --git a/components/button/__tests__/__snapshots__/index.test.js.snap b/components/button/__tests__/__snapshots__/index.test.js.snap index ba9d91417c..e15dcccbec 100644 --- a/components/button/__tests__/__snapshots__/index.test.js.snap +++ b/components/button/__tests__/__snapshots__/index.test.js.snap @@ -189,6 +189,18 @@ exports[`Button renders correctly 1`] = ` `; +exports[`Button should has click wave effect 1`] = ` + +`; + exports[`Button should support link button 1`] = ` { ); expect(wrapper2).toMatchSnapshot(); }); + + it('should has click wave effect', async () => { + const wrapper = mount( + + ); + wrapper.find('.ant-btn').getDOMNode().click(); + await new Promise(resolve => setTimeout(resolve, 0)); + expect(wrapper.render()).toMatchSnapshot(); + }); }); diff --git a/components/switch/__tests__/__snapshots__/index.test.js.snap b/components/switch/__tests__/__snapshots__/index.test.js.snap new file mode 100644 index 0000000000..13ea6e9bb9 --- /dev/null +++ b/components/switch/__tests__/__snapshots__/index.test.js.snap @@ -0,0 +1,19 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`Switch should has click wave effect 1`] = ` + +`; diff --git a/components/switch/__tests__/index.test.js b/components/switch/__tests__/index.test.js index a91d799015..89b07233e2 100644 --- a/components/switch/__tests__/index.test.js +++ b/components/switch/__tests__/index.test.js @@ -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(); + wrapper.find('.ant-switch').getDOMNode().click(); + await new Promise(resolve => setTimeout(resolve, 0)); + expect(wrapper.render()).toMatchSnapshot(); + }); });