Skip to content

Commit

Permalink
fix(divider): 修复pxTransform 问题
Browse files Browse the repository at this point in the history
  • Loading branch information
jimczj committed Nov 20, 2018
1 parent 4f3287e commit bb6623a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 15 deletions.
13 changes: 7 additions & 6 deletions src/components/divider/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import './index.scss'

export default class AtDivider extends AtComponent {
static defaultProps = {
isTest: false,
content: '',
height: 112,
fontColor: '#6190E8',
Expand Down Expand Up @@ -38,9 +37,15 @@ export default class AtDivider extends AtComponent {
lineColor: PropTypes.string
}

constructor () {
super(...arguments)
if (process.env.NODE_ENV === 'test') {
Taro.initPxTransform({ designWidth: 750 })
}
}

render () {
const {
isTest,
className,
customStyle,
content,
Expand All @@ -50,10 +55,6 @@ export default class AtDivider extends AtComponent {
lineColor
} = this.props

if (isTest) {
Taro.initPxTransform({ designWidth: 750 })
}

const rootStyle = {
height: `${Taro.pxTransform(height)}`
}
Expand Down
18 changes: 9 additions & 9 deletions src/components/divider/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,47 +5,47 @@ import AtDivider from '../../../.temp/components/divider/index'

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

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

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

it('render AtDivider -- props content', () => {
const component = renderToString(<AtDivider isTest content='content' />)
const component = renderToString(<AtDivider content='content' />)
expect(component).toMatchSnapshot()
})

it('render AtDivider -- props height', () => {
const component = renderToString(<AtDivider isTest height='120' />)
const component = renderToString(<AtDivider height='120' />)
expect(component).toMatchSnapshot()
})

it('render AtDivider -- props fontColor', () => {
const component = renderToString(<AtDivider isTest fontColor='#fff' />)
const component = renderToString(<AtDivider fontColor='#fff' />)
expect(component).toMatchSnapshot()
})

it('render AtDivider -- props fontSize', () => {
const component = renderToString(<AtDivider isTest fontSize='56' />)
const component = renderToString(<AtDivider fontSize='56' />)
expect(component).toMatchSnapshot()
})

it('render AtDivider -- props lineColor', () => {
const component = renderToString(<AtDivider isTest lineColor='#fff' />)
const component = renderToString(<AtDivider lineColor='#fff' />)
expect(component).toMatchSnapshot()
})

it('render AtDivider -- props childen', () => {
const component = renderToString(<AtDivider isTest>test</AtDivider>)
const component = renderToString(<AtDivider>test</AtDivider>)
expect(component).toMatchSnapshot()
})
})

0 comments on commit bb6623a

Please sign in to comment.