From a4d627c80e9747d7dd6ab6f6aeb25ac37a962e85 Mon Sep 17 00:00:00 2001 From: 07akioni <07akioni2@gmail.com> Date: Wed, 28 Jul 2021 01:43:16 +0800 Subject: [PATCH] test(input-number): fix showButton --- src/input-number/src/InputNumber.tsx | 1 + src/input-number/tests/InputNumber.spec.tsx | 14 +++++--------- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/input-number/src/InputNumber.tsx b/src/input-number/src/InputNumber.tsx index f82c117bb..1fb5c417d 100644 --- a/src/input-number/src/InputNumber.tsx +++ b/src/input-number/src/InputNumber.tsx @@ -370,6 +370,7 @@ export default defineComponent({ onMousedown={this.handleMouseDown} > {{ + _: 2, // input number has dynamic slots prefix: this.$slots.prefix, suffix: this.showButton ? () => [ diff --git a/src/input-number/tests/InputNumber.spec.tsx b/src/input-number/tests/InputNumber.spec.tsx index fc8e984ae..52121bef2 100644 --- a/src/input-number/tests/InputNumber.spec.tsx +++ b/src/input-number/tests/InputNumber.spec.tsx @@ -8,16 +8,12 @@ describe('n-input-number', () => { }) it('should work with `show-button` prop', async () => { - const wrapper = mount(NInputNumber, { - props: { - showButton: false - } - }) + // Here is a strange case, we must make input number's slots flag to 2 + // (dynamic) to make it work. + const wrapper = mount(NInputNumber) + expect(wrapper.findComponent(NButton).exists()).toBe(true) + await wrapper.setProps({ showButton: false }) expect(wrapper.findComponent(NButton).exists()).toBe(false) - - // expect(wrapper.findComponent(NButton).exists()).toBe(true) - - // await wrapper.setProps({ showButton: false }) }) it('should work with default value', async () => {