From a13cdcae6177fdf1d6faa68d688233a229c24239 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E5=98=89=E6=B6=B5?= Date: Fri, 31 May 2019 10:13:56 +0800 Subject: [PATCH] [improvement] Switch: add test case --- packages/switch/test/index.spec.js | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/packages/switch/test/index.spec.js b/packages/switch/test/index.spec.js index a05bdc9ff..d822b68f4 100644 --- a/packages/switch/test/index.spec.js +++ b/packages/switch/test/index.spec.js @@ -37,3 +37,26 @@ test('disabled', () => { expect(input).toHaveBeenCalledTimes(0); expect(change).toHaveBeenCalledTimes(0); }); + +test('active-value & inactive-value prop', () => { + const input = jest.fn(); + const change = jest.fn(); + const wrapper = mount(Switch, { + propsData: { + value: '1', + activeValue: '1', + inactiveValue: '2' + }, + context: { + on: { + input, + change + } + } + }); + + wrapper.trigger('click'); + + expect(input).toHaveBeenCalledWith('2'); + expect(change).toHaveBeenCalledWith('2'); +});