Skip to content

Commit

Permalink
fix(textarea): 修复 pxTransform 测试问题
Browse files Browse the repository at this point in the history
  • Loading branch information
jimczj committed Nov 20, 2018
1 parent eafdcb0 commit 6c15ed7
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 22 deletions.
31 changes: 17 additions & 14 deletions src/components/textarea/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,29 +69,35 @@ export default class AtTextarea extends AtComponent {
onConfirm: PropTypes.func
}

handleInput (e) {
this.props.onChange(e, ...arguments)
constructor () {
super(...arguments)
if (process.env.NODE_ENV === 'test') {
Taro.initPxTransform({ designWidth: 750 })
}
}

handleInput () {
this.props.onChange(...arguments)
}

handleFocus (e) {
this.props.onFocus(e, ...arguments)
handleFocus () {
this.props.onFocus(...arguments)
}

handleBlur (e) {
this.props.onBlur(e, ...arguments)
handleBlur () {
this.props.onBlur(...arguments)
}

handleConfirm (e) {
this.props.onConfirm(e, ...arguments)
handleConfirm () {
this.props.onConfirm(...arguments)
}

handleLinechange (e) {
this.props.onLinechange(e, ...arguments)
handleLinechange () {
this.props.onLinechange(...arguments)
}

render () {
const {
isTest,
customStyle,
className,
value,
Expand All @@ -112,9 +118,6 @@ export default class AtTextarea extends AtComponent {
height
} = this.props

if (isTest) {
Taro.initPxTransform({ designWidth: 750 })
}
let actualMaxlength = maxlength
if (!textOverflowForbidden) {
actualMaxlength += 500
Expand Down
16 changes: 8 additions & 8 deletions src/components/textarea/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,42 +5,42 @@ import AtTextarea from '../../../.temp/components/textarea/index'

describe('AtTextarea Snap', () => {
it('render initial AtTextarea', () => {
const componet = renderToString(<AtTextarea isTest />)
const componet = renderToString(<AtTextarea />)
expect(componet).toMatchSnapshot()
})

it('render AtTextarea -- props customStyle', () => {
const componet = renderToString(<AtTextarea isTest customStyle='color:red;' />)
const componet = renderToString(<AtTextarea customStyle='color:red;' />)
expect(componet).toMatchSnapshot()
})

it('render AtTextarea -- props className', () => {
const componet = renderToString(<AtTextarea isTest className='test' />)
const componet = renderToString(<AtTextarea className='test' />)
expect(componet).toMatchSnapshot()
})

it('render AtTextarea -- props value', () => {
const componet = renderToString(<AtTextarea isTest value='test' />)
const componet = renderToString(<AtTextarea value='test' />)
expect(componet).toMatchSnapshot()
})

it('render AtTextarea -- props maxlength', () => {
const componet = renderToString(<AtTextarea isTest maxlength='300' />)
const componet = renderToString(<AtTextarea maxlength='300' />)
expect(componet).toMatchSnapshot()
})

it('render AtTextarea -- props maxlength', () => {
const componet = renderToString(<AtTextarea isTest placeholder='test' />)
const componet = renderToString(<AtTextarea placeholder='test' />)
expect(componet).toMatchSnapshot()
})

it('render AtTextarea -- props maxlength', () => {
const componet = renderToString(<AtTextarea isTest count={3000} />)
const componet = renderToString(<AtTextarea count={3000} />)
expect(componet).toMatchSnapshot()
})

it('render AtTextarea -- props maxlength', () => {
const componet = renderToString(<AtTextarea isTest height={3000} />)
const componet = renderToString(<AtTextarea height={3000} />)
expect(componet).toMatchSnapshot()
})
})

0 comments on commit 6c15ed7

Please sign in to comment.