From 07d6988f0d4d1146e62cd6763e1c067ef14485a9 Mon Sep 17 00:00:00 2001 From: afc163 Date: Fri, 23 Mar 2018 19:19:29 +0800 Subject: [PATCH] Add some tests --- .../__snapshots__/index.test.js.snap | 26 +++++++++++ components/cascader/__tests__/index.test.js | 10 +++++ .../input-number/__tests__/index.test.js | 4 ++ .../__snapshots__/index.test.js.snap | 43 +++++++++++++++++++ components/slider/__tests__/index.test.js | 15 +++++++ 5 files changed, 98 insertions(+) create mode 100644 components/input-number/__tests__/index.test.js create mode 100644 components/slider/__tests__/__snapshots__/index.test.js.snap create mode 100644 components/slider/__tests__/index.test.js diff --git a/components/cascader/__tests__/__snapshots__/index.test.js.snap b/components/cascader/__tests__/__snapshots__/index.test.js.snap index 00bc8ff181..eb107e4f2b 100644 --- a/components/cascader/__tests__/__snapshots__/index.test.js.snap +++ b/components/cascader/__tests__/__snapshots__/index.test.js.snap @@ -214,3 +214,29 @@ exports[`Cascader popup correctly with defaultValue 1`] = ` `; + +exports[`Cascader support controlled mode 1`] = ` + + + Zhejiang / Hangzhou / West Lake + + + + + +`; diff --git a/components/cascader/__tests__/index.test.js b/components/cascader/__tests__/index.test.js index 549c30e175..fe37c9ce0c 100644 --- a/components/cascader/__tests__/index.test.js +++ b/components/cascader/__tests__/index.test.js @@ -46,6 +46,16 @@ describe('Cascader', () => { expect(render(wrapper.find('Trigger').instance().getComponent())).toMatchSnapshot(); }); + it('support controlled mode', () => { + const wrapper = mount( + + ); + wrapper.setProps({ + value: ['zhejiang', 'hangzhou', 'xihu'], + }); + expect(wrapper.render()).toMatchSnapshot(); + }); + it('popup correctly with defaultValue', () => { const wrapper = mount( diff --git a/components/input-number/__tests__/index.test.js b/components/input-number/__tests__/index.test.js new file mode 100644 index 0000000000..b47c2658e7 --- /dev/null +++ b/components/input-number/__tests__/index.test.js @@ -0,0 +1,4 @@ +import InputNumber from '..'; +import focusTest from '../../../tests/shared/focusTest'; + +focusTest(InputNumber); diff --git a/components/slider/__tests__/__snapshots__/index.test.js.snap b/components/slider/__tests__/__snapshots__/index.test.js.snap new file mode 100644 index 0000000000..ea2feeaba4 --- /dev/null +++ b/components/slider/__tests__/__snapshots__/index.test.js.snap @@ -0,0 +1,43 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`Slider should show tooltip when hovering slider handler 1`] = ` +
+
+
+
+
+ 30 +
+
+
+
+`; + +exports[`Slider should show tooltip when hovering slider handler 2`] = ` +
+
+
+
+
+ 30 +
+
+
+
+`; diff --git a/components/slider/__tests__/index.test.js b/components/slider/__tests__/index.test.js new file mode 100644 index 0000000000..7fec69ccaf --- /dev/null +++ b/components/slider/__tests__/index.test.js @@ -0,0 +1,15 @@ +import React from 'react'; +import { render, mount } from 'enzyme'; +import Slider from '..'; + +describe('Slider', () => { + it('should show tooltip when hovering slider handler', () => { + const wrapper = mount( + + ); + wrapper.find('.ant-slider-handle').at(0).simulate('mouseEnter'); + expect(render(wrapper.find('Trigger').instance().getComponent())).toMatchSnapshot(); + wrapper.find('.ant-slider-handle').at(0).simulate('mouseLeave'); + expect(render(wrapper.find('Trigger').instance().getComponent())).toMatchSnapshot(); + }); +});