Use 'enzyme' for 'View' tests

This commit is contained in:
Nicolas Gallagher
2016-07-05 11:03:37 -07:00
parent d69406b4b1
commit 8fb8645723

View File

@@ -1,34 +1,33 @@
/* eslint-env mocha */
import * as utils from '../../../modules/specHelpers'
import assert from 'assert'
import React from 'react'
import { shallow } from 'enzyme'
import View from '../'
suite('components/View', () => {
test('prop "children"', () => {
const children = 'children'
const result = utils.shallowRender(<View>{children}</View>)
assert.equal(result.props.children, children)
const view = shallow(<View>{children}</View>)
assert.equal(view.prop('children'), children)
})
test('prop "pointerEvents"', () => {
const result = utils.shallowRender(<View pointerEvents='box-only' />)
assert.equal(result.props.className, '__style_pebo')
const view = shallow(<View pointerEvents='box-only' />)
assert.equal(view.prop('className'), '__style_pebo')
})
test('prop "style"', () => {
const noFlex = utils.shallowRender(<View />)
assert.equal(noFlex.props.style.flexShrink, 0)
const view = shallow(<View />)
assert.equal(view.prop('style').flexShrink, 0)
const flex = utils.shallowRender(<View style={{ flex: 1 }} />)
assert.equal(flex.props.style.flexShrink, 1)
const flexView = shallow(<View style={{ flex: 1 }} />)
assert.equal(flexView.prop('style').flexShrink, 1)
const flexShrink = utils.shallowRender(<View style={{ flexShrink: 1 }} />)
assert.equal(flexShrink.props.style.flexShrink, 1)
const flexShrinkView = shallow(<View style={{ flexShrink: 1 }} />)
assert.equal(flexShrinkView.prop('style').flexShrink, 1)
const flexAndShrink = utils.shallowRender(<View style={{ flex: 1, flexShrink: 2 }} />)
assert.equal(flexAndShrink.props.style.flexShrink, 2)
const flexAndShrinkView = shallow(<View style={{ flex: 1, flexShrink: 2 }} />)
assert.equal(flexAndShrinkView.prop('style').flexShrink, 2)
})
})