From 9eee9f5dcda547cdbe4e51a92d6939a6fbe32abd Mon Sep 17 00:00:00 2001 From: afc163 Date: Fri, 7 Jul 2017 20:38:52 +0800 Subject: [PATCH] Add test case for Checkbox --- components/checkbox/__tests__/index.test.js | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/components/checkbox/__tests__/index.test.js b/components/checkbox/__tests__/index.test.js index 46bfcbbec4..55c89394e1 100644 --- a/components/checkbox/__tests__/index.test.js +++ b/components/checkbox/__tests__/index.test.js @@ -1,5 +1,5 @@ import React from 'react'; -import { shallow } from 'enzyme'; +import { shallow, mount } from 'enzyme'; import Checkbox from '..'; describe('Checkbox', () => { @@ -20,4 +20,19 @@ describe('Checkbox', () => { wrapper.simulate('mouseleave'); expect(onMouseLeave).toHaveBeenCalled(); }); + + it('CheckGroup should work', () => { + const onChange = jest.fn(); + const wrapper = mount( + + ); + wrapper.find('.ant-checkbox-input').at(0).simulate('change'); + expect(onChange).toBeCalledWith(['Apple']); + wrapper.find('.ant-checkbox-input').at(1).simulate('change'); + expect(onChange).toBeCalledWith(['Apple', 'Pear']); + wrapper.find('.ant-checkbox-input').at(2).simulate('change'); + expect(onChange).toBeCalledWith(['Apple', 'Pear', 'Orange']); + wrapper.find('.ant-checkbox-input').at(1).simulate('change'); + expect(onChange).toBeCalledWith(['Apple', 'Orange']); + }); });