From 49b7a0ccd20eedb16e5338be6ca3cf052a9cfffc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=81=8F=E5=8F=B3?= Date: Thu, 13 Feb 2020 17:32:07 +0800 Subject: [PATCH] test: Increase Slider and Input test coverage (#21364) * :white_check_mark: Add test case to Slider * increae cov and make hidden textarea works with screen readers --- components/input/__tests__/index.test.js | 25 +++++++++++++++++------ components/input/calculateNodeHeight.tsx | 2 ++ components/slider/__tests__/index.test.js | 10 +++++++++ tests/shared/focusTest.js | 11 +++++----- 4 files changed, 36 insertions(+), 12 deletions(-) diff --git a/components/input/__tests__/index.test.js b/components/input/__tests__/index.test.js index 6c56b1f5ee..fa7a3bd8db 100644 --- a/components/input/__tests__/index.test.js +++ b/components/input/__tests__/index.test.js @@ -88,16 +88,30 @@ describe('Input', () => { focusTest(TextArea); describe('TextArea', () => { + const originalGetComputedStyle = window.getComputedStyle; beforeAll(() => { + Object.defineProperty(window, 'getComputedStyle', { + value: (node) => ({ + getPropertyValue: (prop) => { + if (prop === 'box-sizing') { + return originalGetComputedStyle(node)[prop] || 'border-box'; + } + return originalGetComputedStyle(node)[prop]; + }, + }), + }); jest.useFakeTimers(); }); afterAll(() => { + Object.defineProperty(window, 'getComputedStyle', { + value: originalGetComputedStyle, + }); jest.useRealTimers(); }); it('should auto calculate height according to content length', () => { - const wrapper = mount(