Skip to content

Commit

Permalink
fix(rate): 修改pxTransform测试方式
Browse files Browse the repository at this point in the history
  • Loading branch information
jimczj committed Nov 20, 2018
1 parent 2c71d15 commit f3063dd
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
17 changes: 10 additions & 7 deletions src/components/rate/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,19 @@ export default class AtRate extends AtComponent {
onChange: PropTypes.func
}

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

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

render () {
const {
isTest,
customStyle,
className,
value,
Expand All @@ -53,9 +59,6 @@ export default class AtRate extends AtComponent {
margin
} = this.props

if (isTest) {
Taro.initPxTransform({ designWidth: 750 })
}
const iconStyle = {
marginRight: Taro.pxTransform(margin)
}
Expand Down Expand Up @@ -83,7 +86,7 @@ export default class AtRate extends AtComponent {
className={cls}
key={i}
style={iconStyle}
onClick={this.handleClick.bind(this, i)}
onClick={this.handleClick.bind(this, i + 1)}
>
<AtIcon value='star-2' size={size} />
<View className='at-rate__left'>
Expand Down
12 changes: 6 additions & 6 deletions src/components/rate/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,32 +10,32 @@ describe('AtRate Snap', () => {
})

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

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

it('render AtRate -- props size', () => {
const componet = renderToString(<AtRate isTest size='10' />)
const componet = renderToString(<AtRate size='10' />)
expect(componet).toMatchSnapshot()
})

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

it('render AtRate -- props max', () => {
const componet = renderToString(<AtRate isTest max='10' />)
const componet = renderToString(<AtRate max='10' />)
expect(componet).toMatchSnapshot()
})

it('render AtRate -- props margin', () => {
const componet = renderToString(<AtRate isTest margin='10' />)
const componet = renderToString(<AtRate margin='10' />)
expect(componet).toMatchSnapshot()
})
})

0 comments on commit f3063dd

Please sign in to comment.