Simplify View snapshot testing

This commit is contained in:
Nicolas Gallagher
2017-09-18 19:23:35 -07:00
parent 5cb09b1a9e
commit 12fb588596
2 changed files with 19 additions and 29 deletions

View File

@@ -1,29 +1,16 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`components/View prop "hitSlop" handles partial offsets 1`] = `
<div
class="rn-alignItems-1oszu61 rn-borderTopStyle-1efd50x rn-borderRightStyle-14skgim rn-borderBottomStyle-rull8r rn-borderLeftStyle-mm0ijv rn-borderTopWidth-13yce4e rn-borderRightWidth-fnigne rn-borderBottomWidth-ndvcnb rn-borderLeftWidth-gxnn5r rn-boxSizing-deolkf rn-display-6koalj rn-flexShrink-1qe8dj5 rn-flexBasis-1mlwlqe rn-flexDirection-eqz5dr rn-marginTop-1mnahxq rn-marginRight-61z16t rn-marginBottom-p1pxzi rn-marginLeft-11wrixw rn-minHeight-ifefl9 rn-minWidth-bcqeeo rn-paddingTop-wk8lta rn-paddingRight-9aemit rn-paddingBottom-1mdbw0j rn-paddingLeft-gy4na3 rn-position-bnwqim rn-zIndex-1lgpqti"
>
<span
class="rn-bottom-1p0dtai rn-left-1d2f490 rn-position-u8s1d rn-right-zchlnj rn-zIndex-1wyyakw"
style="top:-10px;"
/>
</div>
Object {
"top": "-10px",
}
`;
exports[`components/View prop "hitSlop" renders a span with negative position offsets 1`] = `
<div
class="rn-alignItems-1oszu61 rn-borderTopStyle-1efd50x rn-borderRightStyle-14skgim rn-borderBottomStyle-rull8r rn-borderLeftStyle-mm0ijv rn-borderTopWidth-13yce4e rn-borderRightWidth-fnigne rn-borderBottomWidth-ndvcnb rn-borderLeftWidth-gxnn5r rn-boxSizing-deolkf rn-display-6koalj rn-flexShrink-1qe8dj5 rn-flexBasis-1mlwlqe rn-flexDirection-eqz5dr rn-marginTop-1mnahxq rn-marginRight-61z16t rn-marginBottom-p1pxzi rn-marginLeft-11wrixw rn-minHeight-ifefl9 rn-minWidth-bcqeeo rn-paddingTop-wk8lta rn-paddingRight-9aemit rn-paddingBottom-1mdbw0j rn-paddingLeft-gy4na3 rn-position-bnwqim rn-zIndex-1lgpqti"
>
<span
class="rn-position-u8s1d rn-zIndex-1wyyakw"
style="bottom:-10px;left:-5px;right:-5px;top:-10px;"
/>
</div>
`;
exports[`components/View prop "pointerEvents" 1`] = `
<div
class="rn-alignItems-1oszu61 rn-borderTopStyle-1efd50x rn-borderRightStyle-14skgim rn-borderBottomStyle-rull8r rn-borderLeftStyle-mm0ijv rn-borderTopWidth-13yce4e rn-borderRightWidth-fnigne rn-borderBottomWidth-ndvcnb rn-borderLeftWidth-gxnn5r rn-boxSizing-deolkf rn-display-6koalj rn-flexShrink-1qe8dj5 rn-flexBasis-1mlwlqe rn-flexDirection-eqz5dr rn-marginTop-1mnahxq rn-marginRight-61z16t rn-marginBottom-p1pxzi rn-marginLeft-11wrixw rn-minHeight-ifefl9 rn-minWidth-bcqeeo rn-paddingTop-wk8lta rn-paddingRight-9aemit rn-paddingBottom-1mdbw0j rn-paddingLeft-gy4na3 rn-pointerEvents-ah5dr5 rn-position-bnwqim"
/>
Object {
"bottom": "-10px",
"left": "-5px",
"right": "-5px",
"top": "-10px",
}
`;

View File

@@ -1,7 +1,7 @@
/* eslint-env jasmine, jest */
import React from 'react';
import { render, shallow } from 'enzyme';
import { shallow } from 'enzyme';
import View from '../';
describe('components/View', () => {
@@ -39,18 +39,21 @@ describe('components/View', () => {
describe('prop "hitSlop"', () => {
it('renders a span with negative position offsets', () => {
const component = render(<View hitSlop={{ top: 10, bottom: 10, right: 5, left: 5 }} />);
expect(component).toMatchSnapshot();
const component = shallow(<View hitSlop={{ top: 10, bottom: 10, right: 5, left: 5 }} />);
const span = component.find('span');
expect(span.length).toBe(1);
expect(span.prop('style')).toMatchSnapshot();
});
it('handles partial offsets', () => {
const component = render(<View hitSlop={{ top: 10 }} />);
expect(component).toMatchSnapshot();
const component = shallow(<View hitSlop={{ top: 10 }} />);
const span = component.find('span');
expect(span.prop('style')).toMatchSnapshot();
});
});
test('prop "pointerEvents"', () => {
const component = render(<View pointerEvents="box-only" />);
expect(component).toMatchSnapshot();
const component = shallow(<View pointerEvents="box-only" />);
expect(component.prop('className').indexOf('pointerEvents') > -1).toBe(true);
});
});