|
|
@ -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(<TextArea value="" readOnly autoSize />); |
|
|
|
const wrapper = mount(<TextArea value="" readOnly autoSize={{ minRows: 2, maxRows: 6 }} wrap="off" />); |
|
|
|
const mockFunc = jest.spyOn(wrapper.instance().resizableTextArea, 'resizeTextarea'); |
|
|
|
wrapper.setProps({ value: '1111\n2222\n3333' }); |
|
|
|
jest.runAllTimers(); |
|
|
@ -144,10 +158,9 @@ describe('TextArea', () => { |
|
|
|
const value = calculateNodeStyling(wrapper, true); |
|
|
|
expect(value).toEqual({ |
|
|
|
borderSize: 2, |
|
|
|
boxSizing: '', |
|
|
|
boxSizing: 'border-box', |
|
|
|
paddingSize: 4, |
|
|
|
sizingStyle: |
|
|
|
'letter-spacing:normal;line-height:normal;padding-top:2px;padding-bottom:2px;font-family:-webkit-small-control;font-weight:;font-size:;font-variant:;text-rendering:auto;text-transform:none;width:;text-indent:0;padding-left:2px;padding-right:2px;border-width:1px;box-sizing:', |
|
|
|
sizingStyle: 'letter-spacing:normal;line-height:normal;padding-top:2px;padding-bottom:2px;font-family:-webkit-small-control;font-weight:;font-size:;font-variant:;text-rendering:auto;text-transform:none;width:;text-indent:0;padding-left:2px;padding-right:2px;border-width:1px;box-sizing:border-box', |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
@ -168,9 +181,9 @@ describe('TextArea', () => { |
|
|
|
it('minRows or maxRows is not null', () => { |
|
|
|
const wrapper = document.createElement('textarea'); |
|
|
|
expect(calculateNodeHeight(wrapper, 1, 1)).toEqual({ |
|
|
|
height: 0, |
|
|
|
height: 2, |
|
|
|
maxHeight: 9007199254740991, |
|
|
|
minHeight: -4, |
|
|
|
minHeight: 2, |
|
|
|
overflowY: undefined, |
|
|
|
}); |
|
|
|
wrapper.style.boxSizing = 'content-box'; |
|
|
|