diff --git a/docs/e2e/basic/demos/Text/TextArea.tsx b/docs/e2e/basic/demos/Text/TextArea.tsx new file mode 100644 index 00000000..cc940b59 --- /dev/null +++ b/docs/e2e/basic/demos/Text/TextArea.tsx @@ -0,0 +1,20 @@ +import React from 'react'; +import { useElements, TestLayout } from '@docs-utils'; +import { Input } from 'antd'; + +const {TextArea} = Input + +/** + * + */ +export default () => { + const { elements, ref } = useElements(); + + return ( + +
+ +
+
@@ -41,6 +45,14 @@ describe('parseInputTextToText', () => { expect(input).toBeUndefined(); }); + it('textarea 不返回', () => { + const node = document.getElementById('pure-textarea') as HTMLTextAreaElement; + console.log(node) + const input = parseInputTextToText(node); + + expect(input).toBeUndefined(); + }); + it('input-placeholder 解析成文本', () => { const node = document.getElementById( 'input-placeholder', @@ -51,6 +63,18 @@ describe('parseInputTextToText', () => { expect(json._class).toBe('text'); expect(json.attributedString.string).toBe('测试输入框'); }); + + it('textarea-placeholder 解析成文本', () => { + const node = document.getElementById( + 'textarea-placeholder', + ) as HTMLInputElement; + const input = parseInputTextToText(node) as Text; + expect(input.textStyle.color.red).toBe(255); + const json = input.toSketchJSON(); + expect(json._class).toBe('text'); + expect(json.attributedString.string).toBe('测试输入框'); + }); + it('input-value 解析成文本', () => { const node = document.getElementById('input-value') as HTMLInputElement; const input = parseInputTextToText(node) as Text; @@ -60,6 +84,14 @@ describe('parseInputTextToText', () => { expect(input.x).toBeLessThanOrEqual(2); }); + it('textarea-value 解析成文本', () => { + const node = document.getElementById('textarea-value') as HTMLTextAreaElement; + const input = parseInputTextToText(node) as Text; + const json = input.toSketchJSON(); + expect(json._class).toBe('text'); + expect(json.attributedString.string).toBe('这是值'); + }); + it('input-center 解析成文本', () => { const node = document.getElementById('input-center') as HTMLInputElement; const input = parseInputTextToText(node) as Text;