diff --git a/src/components/Text/__tests__/__snapshots__/index-test.js.snap b/src/components/Text/__tests__/__snapshots__/index-test.js.snap index 7f2184f2..caa81236 100644 --- a/src/components/Text/__tests__/__snapshots__/index-test.js.snap +++ b/src/components/Text/__tests__/__snapshots__/index-test.js.snap @@ -1,14 +1,5 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`components/Text prop "children" 1`] = ` -
- children -
-`; - exports[`components/Text prop "onPress" 1`] = `
{ + describe('rendered element', () => { + test('is a "div" by default', () => { + const component = shallow(); + expect(component.type()).toBe('div'); + }); + + test('is a "span" when inside ', () => { + const component = render(} />); + expect(component.find('span').length).toEqual(1); + }); + + test('includes dir="auto" prop', () => { + const component = shallow(); + expect(component.prop('dir')).toBe('auto'); + }); + + test('allows "dir" to be overridden', () => { + const component = shallow(); + expect(component.prop('dir')).toBe('rtl'); + }); + }); + test('prop "children"', () => { - const component = render(children); - expect(component).toMatchSnapshot(); + const children = ; + const component = shallow(); + expect(component.contains(children)).toEqual(true); }); test('prop "numberOfLines"'); diff --git a/src/components/Text/index.js b/src/components/Text/index.js index 1010b7be..e31e965f 100644 --- a/src/components/Text/index.js +++ b/src/components/Text/index.js @@ -54,6 +54,8 @@ class Text extends Component { ...otherProps } = this.props; + const { isInAParentText } = this.context; + if (onPress) { otherProps.accessible = true; otherProps.onClick = onPress; @@ -71,7 +73,9 @@ class Text extends Component { onPress && styles.pressable ]; - return createDOMElement('div', otherProps); + const component = isInAParentText ? 'span' : 'div'; + + return createDOMElement(component, otherProps); } _createEnterHandler(fn) { diff --git a/src/components/View/__tests__/__snapshots__/index-test.js.snap b/src/components/View/__tests__/__snapshots__/index-test.js.snap index 639bb5be..c4632a42 100644 --- a/src/components/View/__tests__/__snapshots__/index-test.js.snap +++ b/src/components/View/__tests__/__snapshots__/index-test.js.snap @@ -1,16 +1,5 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`components/View prop "children" 1`] = ` -
-
-
-`; - exports[`components/View prop "hitSlop" handles partial offsets 1`] = `
`; - -exports[`components/View rendered element is a "div" by default 1`] = ` -
-`; - -exports[`components/View rendered element is a "span" when inside 1`] = ` - -`; diff --git a/src/components/View/__tests__/index-test.js b/src/components/View/__tests__/index-test.js index 418ec219..fcd91003 100644 --- a/src/components/View/__tests__/index-test.js +++ b/src/components/View/__tests__/index-test.js @@ -1,26 +1,26 @@ /* eslint-env jasmine, jest */ import React from 'react'; -import { render } from 'enzyme'; +import { render, shallow } from 'enzyme'; import View from '../'; describe('components/View', () => { describe('rendered element', () => { test('is a "div" by default', () => { - const component = render(); - expect(component).toMatchSnapshot(); + const component = shallow(); + expect(component.type()).toBe('div'); }); test('is a "span" when inside ', () => { const component = render(); - expect(component).toMatchSnapshot(); + expect(component.find('span').length).toEqual(1); }); }); test('prop "children"', () => { const children = ; - const component = render({children}); - expect(component).toMatchSnapshot(); + const component = shallow({children}); + expect(component.contains(children)).toEqual(true); }); describe('prop "hitSlop"', () => {