diff --git a/package.json b/package.json index 8a66d38a8a..b92d56b464 100644 --- a/package.json +++ b/package.json @@ -36,12 +36,12 @@ "devDependencies": { "babel": "^6.23.0", "babel-core": "^6.23.1", - "babel-loader": "^6.3.2", - "webpack": "^2.2.1", "babel-eslint": "^7.1.1", "babel-jest": "^19.0.0", + "babel-loader": "^6.3.2", "babel-preset-react-native": "^1.9.1", "enzyme": "^2.7.1", + "enzyme-to-json": "^1.5.0", "eslint": "^3.17.1", "eslint-plugin-react": "^6.10.0", "eslint-plugin-react-native": "^2.3.1", @@ -50,7 +50,8 @@ "react-addons-test-utils": "^15.4.2", "react-dom": "^15.4.2", "react-native": "^0.41.2", - "react-native-vector-icons": "^4.0.0" + "react-native-vector-icons": "^4.0.0", + "webpack": "^2.2.1" }, "jest": { "preset": "react-native", diff --git a/src/avatar/__tests__/Avatar.js b/src/avatar/__tests__/Avatar.js index 47642c58df..288d6a0005 100644 --- a/src/avatar/__tests__/Avatar.js +++ b/src/avatar/__tests__/Avatar.js @@ -1,5 +1,6 @@ import React from 'react'; import {shallow} from 'enzyme'; +import toJson from 'enzyme-to-json'; import Avatar from '../Avatar'; describe('Badge Component', () => { @@ -7,7 +8,7 @@ describe('Badge Component', () => { const component = shallow(); expect(component.length).toBe(1); - expect(component).toMatchSnapshot(); + expect(toJson(component)).toMatchSnapshot(); }); it('should render small avatar', () => { @@ -20,7 +21,7 @@ describe('Badge Component', () => { />); expect(component.length).toBe(1); - expect(component).toMatchSnapshot(); + expect(toJson(component)).toMatchSnapshot(); }); it('should render medium avatar', () => { @@ -32,7 +33,7 @@ describe('Badge Component', () => { />); expect(component.length).toBe(1); - expect(component).toMatchSnapshot(); + expect(toJson(component)).toMatchSnapshot(); }); it('should render large avatar', () => { @@ -44,7 +45,7 @@ describe('Badge Component', () => { />); expect(component.length).toBe(1); - expect(component).toMatchSnapshot(); + expect(toJson(component)).toMatchSnapshot(); }); it('should render xlarge avatar', () => { @@ -56,7 +57,7 @@ describe('Badge Component', () => { />); expect(component.length).toBe(1); - expect(component).toMatchSnapshot(); + expect(toJson(component)).toMatchSnapshot(); }); it('should render avatar without width', () => { @@ -68,7 +69,7 @@ describe('Badge Component', () => { />); expect(component.length).toBe(1); - expect(component).toMatchSnapshot(); + expect(toJson(component)).toMatchSnapshot(); }); it('should render avatar without height', () => { @@ -79,6 +80,6 @@ describe('Badge Component', () => { />); expect(component.length).toBe(1); - expect(component).toMatchSnapshot(); + expect(toJson(component)).toMatchSnapshot(); }); }); diff --git a/src/avatar/__tests__/__snapshots__/Avatar.js.snap b/src/avatar/__tests__/__snapshots__/Avatar.js.snap index a2f42d3b54..101fca6491 100644 --- a/src/avatar/__tests__/__snapshots__/Avatar.js.snap +++ b/src/avatar/__tests__/__snapshots__/Avatar.js.snap @@ -1,2146 +1,394 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`Badge Component should render avatar without height 1`] = ` -ShallowWrapper { - "complexSelector": ComplexSelector { - "buildPredicate": [Function], - "childrenOfNode": [Function], - "findWhereUnwrapped": [Function], - }, - "length": 1, - "node": + - - - avatar title - - -, - "nodes": Array [ - + - - - avatar title - - -, - ], - "options": Object {}, - "renderer": ReactShallowRenderer { - "_instance": ShallowComponentWrapper { - "_calledComponentWillUnmount": false, - "_compositeType": 2, - "_context": Object {}, - "_currentElement": , - "_debugID": 13, - "_hostContainerInfo": null, - "_hostParent": null, - "_instance": StatelessComponent { - "_reactInternalInstance": [Circular], - "context": Object {}, - "props": Object { - "title": "avatar title", - "titleStyle": Object { - "color": "red", + Array [ + Object { + "backgroundColor": "rgba(0,0,0,0)", + "color": "#ffffff", + "fontSize": 40, + "textAlign": "center", }, - "width": 80, - }, - "refs": Object {}, - "state": null, - "updater": Object { - "enqueueCallback": [Function], - "enqueueCallbackInternal": [Function], - "enqueueElementInternal": [Function], - "enqueueForceUpdate": [Function], - "enqueueReplaceState": [Function], - "enqueueSetState": [Function], - "isMounted": [Function], - "validateCallback": [Function], - }, - }, - "_mountOrder": 7, - "_pendingCallbacks": null, - "_pendingElement": null, - "_pendingForceUpdate": false, - "_pendingReplaceState": false, - "_pendingStateQueue": null, - "_renderedComponent": NoopInternalComponent { - "_currentElement": - - - avatar title - - -, - "_debugID": 14, - "_renderedOutput": - - - avatar title - - -, - }, - "_renderedNodeType": 1, - "_rootNodeID": 0, - "_topLevelWrapper": null, - "_updateBatchNumber": null, - "_warnedAboutRefsInRender": false, - }, - "getRenderOutput": [Function], - "render": [Function], - }, - "root": [Circular], - "unrendered": , -} + }, + ] + } + > + avatar title + + + `; exports[`Badge Component should render avatar without width 1`] = ` -ShallowWrapper { - "complexSelector": ComplexSelector { - "buildPredicate": [Function], - "childrenOfNode": [Function], - "findWhereUnwrapped": [Function], - }, - "length": 1, - "node": + - + - - -, - "nodes": Array [ - - - - -, - ], - "options": Object {}, - "renderer": ReactShallowRenderer { - "_instance": ShallowComponentWrapper { - "_calledComponentWillUnmount": false, - "_compositeType": 2, - "_context": Object {}, - "_currentElement": , - "_debugID": 11, - "_hostContainerInfo": null, - "_hostParent": null, - "_instance": StatelessComponent { - "_reactInternalInstance": [Circular], - "context": Object {}, - "props": Object { - "activeOpacity": 0.7, - "avatarStyle": Object { - "backgroundColor": "peru", - }, - "height": 90, - "source": Object { - "uri": "https://s3.amazonaws.com/uifaces/faces/twitter/ladylexy/128.jpg", + style={ + Array [ + Object { + "height": 90, + "width": 90, }, - }, - "refs": Object {}, - "state": null, - "updater": Object { - "enqueueCallback": [Function], - "enqueueCallbackInternal": [Function], - "enqueueElementInternal": [Function], - "enqueueForceUpdate": [Function], - "enqueueReplaceState": [Function], - "enqueueSetState": [Function], - "isMounted": [Function], - "validateCallback": [Function], - }, - }, - "_mountOrder": 6, - "_pendingCallbacks": null, - "_pendingElement": null, - "_pendingForceUpdate": false, - "_pendingReplaceState": false, - "_pendingStateQueue": null, - "_renderedComponent": NoopInternalComponent { - "_currentElement": - - - -, - "_debugID": 12, - "_renderedOutput": - - - -, - }, - "_renderedNodeType": 1, - "_rootNodeID": 0, - "_topLevelWrapper": null, - "_updateBatchNumber": null, - "_warnedAboutRefsInRender": false, - }, - "getRenderOutput": [Function], - "render": [Function], - }, - "root": [Circular], - "unrendered": , -} + }, + ] + } + /> + + `; exports[`Badge Component should render large avatar 1`] = ` -ShallowWrapper { - "complexSelector": ComplexSelector { - "buildPredicate": [Function], - "childrenOfNode": [Function], - "findWhereUnwrapped": [Function], - }, - "length": 1, - "node": - - - -, - "nodes": Array [ - - - - -, - ], - "options": Object {}, - "renderer": ReactShallowRenderer { - "_instance": ShallowComponentWrapper { - "_calledComponentWillUnmount": false, - "_compositeType": 2, - "_context": Object {}, - "_currentElement": , - "_debugID": 7, - "_hostContainerInfo": null, - "_hostParent": null, - "_instance": StatelessComponent { - "_reactInternalInstance": [Circular], - "context": Object {}, - "props": Object { - "activeOpacity": 0.7, - "icon": Object { - "color": "blue", - "name": "name", - "size": 22, - "type": "type", - }, - "large": true, - "rounded": true, - }, - "refs": Object {}, - "state": null, - "updater": Object { - "enqueueCallback": [Function], - "enqueueCallbackInternal": [Function], - "enqueueElementInternal": [Function], - "enqueueForceUpdate": [Function], - "enqueueReplaceState": [Function], - "enqueueSetState": [Function], - "isMounted": [Function], - "validateCallback": [Function], - }, + - - - -, - "_debugID": 8, - "_renderedOutput": - - - -, - }, - "_renderedNodeType": 1, - "_rootNodeID": 0, - "_topLevelWrapper": null, - "_updateBatchNumber": null, - "_warnedAboutRefsInRender": false, - }, - "getRenderOutput": [Function], - "render": [Function], - }, - "root": [Circular], - "unrendered": , -} + > + + + `; exports[`Badge Component should render medium avatar 1`] = ` -ShallowWrapper { - "complexSelector": ComplexSelector { - "buildPredicate": [Function], - "childrenOfNode": [Function], - "findWhereUnwrapped": [Function], - }, - "length": 1, - "node": + - + - - -, - "nodes": Array [ - - - - -, - ], - "options": Object {}, - "renderer": ReactShallowRenderer { - "_instance": ShallowComponentWrapper { - "_calledComponentWillUnmount": false, - "_compositeType": 2, - "_context": Object {}, - "_currentElement": , - "_debugID": 5, - "_hostContainerInfo": null, - "_hostParent": null, - "_instance": StatelessComponent { - "_reactInternalInstance": [Circular], - "context": Object {}, - "props": Object { - "activeOpacity": 0.7, - "medium": true, - "rounded": true, - "source": Object { - "uri": "https://s3.amazonaws.com/uifaces/faces/twitter/ladylexy/128.jpg", + style={ + Array [ + Object { + "height": 50, + "width": 50, }, - }, - "refs": Object {}, - "state": null, - "updater": Object { - "enqueueCallback": [Function], - "enqueueCallbackInternal": [Function], - "enqueueElementInternal": [Function], - "enqueueForceUpdate": [Function], - "enqueueReplaceState": [Function], - "enqueueSetState": [Function], - "isMounted": [Function], - "validateCallback": [Function], - }, - }, - "_mountOrder": 3, - "_pendingCallbacks": null, - "_pendingElement": null, - "_pendingForceUpdate": false, - "_pendingReplaceState": false, - "_pendingStateQueue": null, - "_renderedComponent": NoopInternalComponent { - "_currentElement": - - - -, - "_debugID": 6, - "_renderedOutput": - - - -, - }, - "_renderedNodeType": 1, - "_rootNodeID": 0, - "_topLevelWrapper": null, - "_updateBatchNumber": null, - "_warnedAboutRefsInRender": false, - }, - "getRenderOutput": [Function], - "render": [Function], - }, - "root": [Circular], - "unrendered": , -} + Object { + "borderRadius": 25, + }, + undefined, + ] + } + /> + + `; exports[`Badge Component should render small avatar 1`] = ` -ShallowWrapper { - "complexSelector": ComplexSelector { - "buildPredicate": [Function], - "childrenOfNode": [Function], - "findWhereUnwrapped": [Function], - }, - "length": 1, - "node": + - + - - -, - "nodes": Array [ - - - - -, - ], - "options": Object {}, - "renderer": ReactShallowRenderer { - "_instance": ShallowComponentWrapper { - "_calledComponentWillUnmount": false, - "_compositeType": 2, - "_context": Object {}, - "_currentElement": , - "_debugID": 3, - "_hostContainerInfo": null, - "_hostParent": null, - "_instance": StatelessComponent { - "_reactInternalInstance": [Circular], - "context": Object {}, - "props": Object { - "activeOpacity": 0.7, - "avatarStyle": Object { - "backgroundColor": "peru", + style={ + Array [ + Object { + "height": 34, + "width": 34, }, - "rounded": true, - "small": true, - "source": Object { - "uri": "https://s3.amazonaws.com/uifaces/faces/twitter/ladylexy/128.jpg", + Object { + "borderRadius": 17, }, - }, - "refs": Object {}, - "state": null, - "updater": Object { - "enqueueCallback": [Function], - "enqueueCallbackInternal": [Function], - "enqueueElementInternal": [Function], - "enqueueForceUpdate": [Function], - "enqueueReplaceState": [Function], - "enqueueSetState": [Function], - "isMounted": [Function], - "validateCallback": [Function], - }, - }, - "_mountOrder": 2, - "_pendingCallbacks": null, - "_pendingElement": null, - "_pendingForceUpdate": false, - "_pendingReplaceState": false, - "_pendingStateQueue": null, - "_renderedComponent": NoopInternalComponent { - "_currentElement": - - - -, - "_debugID": 4, - "_renderedOutput": - - - -, - }, - "_renderedNodeType": 1, - "_rootNodeID": 0, - "_topLevelWrapper": null, - "_updateBatchNumber": null, - "_warnedAboutRefsInRender": false, - }, - "getRenderOutput": [Function], - "render": [Function], - }, - "root": [Circular], - "unrendered": , -} + }, + ] + } + /> + + `; exports[`Badge Component should render without issues 1`] = ` -ShallowWrapper { - "complexSelector": ComplexSelector { - "buildPredicate": [Function], - "childrenOfNode": [Function], - "findWhereUnwrapped": [Function], - }, - "length": 1, - "node": - -, - "nodes": Array [ - - -, - ], - "options": Object {}, - "renderer": ReactShallowRenderer { - "_instance": ShallowComponentWrapper { - "_calledComponentWillUnmount": false, - "_compositeType": 2, - "_context": Object {}, - "_currentElement": , - "_debugID": 1, - "_hostContainerInfo": null, - "_hostParent": null, - "_instance": StatelessComponent { - "_reactInternalInstance": [Circular], - "context": Object {}, - "props": Object {}, - "refs": Object {}, - "state": null, - "updater": Object { - "enqueueCallback": [Function], - "enqueueCallbackInternal": [Function], - "enqueueElementInternal": [Function], - "enqueueForceUpdate": [Function], - "enqueueReplaceState": [Function], - "enqueueSetState": [Function], - "isMounted": [Function], - "validateCallback": [Function], - }, + - -, - "_debugID": 2, - "_renderedOutput": - -, - }, - "_renderedNodeType": 1, - "_rootNodeID": 0, - "_topLevelWrapper": null, - "_updateBatchNumber": null, - "_warnedAboutRefsInRender": false, - }, - "getRenderOutput": [Function], - "render": [Function], - }, - "root": [Circular], - "unrendered": , -} + + `; exports[`Badge Component should render xlarge avatar 1`] = ` -ShallowWrapper { - "complexSelector": ComplexSelector { - "buildPredicate": [Function], - "childrenOfNode": [Function], - "findWhereUnwrapped": [Function], - }, - "length": 1, - "node": + - - - avatar title - - -, - "nodes": Array [ - + - - - avatar title - - -, - ], - "options": Object {}, - "renderer": ReactShallowRenderer { - "_instance": ShallowComponentWrapper { - "_calledComponentWillUnmount": false, - "_compositeType": 2, - "_context": Object {}, - "_currentElement": , - "_debugID": 9, - "_hostContainerInfo": null, - "_hostParent": null, - "_instance": StatelessComponent { - "_reactInternalInstance": [Circular], - "context": Object {}, - "props": Object { - "activeOpacity": 0.7, - "rounded": true, - "title": "avatar title", - "xlarge": true, - }, - "refs": Object {}, - "state": null, - "updater": Object { - "enqueueCallback": [Function], - "enqueueCallbackInternal": [Function], - "enqueueElementInternal": [Function], - "enqueueForceUpdate": [Function], - "enqueueReplaceState": [Function], - "enqueueSetState": [Function], - "isMounted": [Function], - "validateCallback": [Function], - }, - }, - "_mountOrder": 5, - "_pendingCallbacks": null, - "_pendingElement": null, - "_pendingForceUpdate": false, - "_pendingReplaceState": false, - "_pendingStateQueue": null, - "_renderedComponent": NoopInternalComponent { - "_currentElement": - - - avatar title - - -, - "_debugID": 10, - "_renderedOutput": - - - avatar title - - -, - }, - "_renderedNodeType": 1, - "_rootNodeID": 0, - "_topLevelWrapper": null, - "_updateBatchNumber": null, - "_warnedAboutRefsInRender": false, - }, - "getRenderOutput": [Function], - "render": [Function], - }, - "root": [Circular], - "unrendered": , -} + > + avatar title + + + `; diff --git a/src/badge/__tests__/__snapshots__/badge.js.snap b/src/badge/__tests__/__snapshots__/badge.js.snap index ec603ba3f3..6d03d95089 100644 --- a/src/badge/__tests__/__snapshots__/badge.js.snap +++ b/src/badge/__tests__/__snapshots__/badge.js.snap @@ -1,310 +1,45 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`Badge Component should render badge.element if included 1`] = ` -ShallowWrapper { - "complexSelector": ComplexSelector { - "buildPredicate": [Function], - "childrenOfNode": [Function], - "findWhereUnwrapped": [Function], - }, - "length": 1, - "node": , - "nodes": Array [ - , - ], - "options": Object {}, - "renderer": ReactShallowRenderer { - "_instance": ShallowComponentWrapper { - "_calledComponentWillUnmount": false, - "_compositeType": 2, - "_context": Object {}, - "_currentElement": , - } - } -/>, - "_debugID": 4, - "_hostContainerInfo": null, - "_hostParent": null, - "_instance": StatelessComponent { - "_reactInternalInstance": [Circular], - "context": Object {}, - "props": Object { - "badge": Object { - "element": , - }, - }, - "refs": Object {}, - "state": null, - "updater": Object { - "enqueueCallback": [Function], - "enqueueCallbackInternal": [Function], - "enqueueElementInternal": [Function], - "enqueueForceUpdate": [Function], - "enqueueReplaceState": [Function], - "enqueueSetState": [Function], - "isMounted": [Function], - "validateCallback": [Function], - }, - }, - "_mountOrder": 3, - "_pendingCallbacks": null, - "_pendingElement": null, - "_pendingForceUpdate": false, - "_pendingReplaceState": false, - "_pendingStateQueue": null, - "_renderedComponent": NoopInternalComponent { - "_currentElement": , - "_debugID": 5, - "_renderedOutput": , - }, - "_renderedNodeType": 1, - "_rootNodeID": 0, - "_topLevelWrapper": null, - "_updateBatchNumber": null, - "_warnedAboutRefsInRender": false, - }, - "getRenderOutput": [Function], - "render": [Function], - }, - "root": [Circular], - "unrendered": , - } - } -/>, -} + `; exports[`Badge Component should render without issues 1`] = ` -ShallowWrapper { - "complexSelector": ComplexSelector { - "buildPredicate": [Function], - "childrenOfNode": [Function], - "findWhereUnwrapped": [Function], - }, - "length": 1, - "node": - -, - "nodes": Array [ - - -, - ], - "options": Object {}, - "renderer": ReactShallowRenderer { - "_instance": ShallowComponentWrapper { - "_calledComponentWillUnmount": false, - "_compositeType": 2, - "_context": Object {}, - "_currentElement": , - "_debugID": 1, - "_hostContainerInfo": null, - "_hostParent": null, - "_instance": StatelessComponent { - "_reactInternalInstance": [Circular], - "context": Object {}, - "props": Object { - "badge": Object {}, - }, - "refs": Object {}, - "state": null, - "updater": Object { - "enqueueCallback": [Function], - "enqueueCallbackInternal": [Function], - "enqueueElementInternal": [Function], - "enqueueForceUpdate": [Function], - "enqueueReplaceState": [Function], - "enqueueSetState": [Function], - "isMounted": [Function], - "validateCallback": [Function], - }, + - -, - "_debugID": 2, - "_renderedOutput": - -, - }, - "_renderedNodeType": 1, - "_rootNodeID": 0, - "_topLevelWrapper": null, - "_updateBatchNumber": null, - "_warnedAboutRefsInRender": false, - }, - "getRenderOutput": [Function], - "render": [Function], - }, - "root": [Circular], - "unrendered": , -} + + `; diff --git a/src/badge/__tests__/badge.js b/src/badge/__tests__/badge.js index 9dca0cfaf4..4993179731 100644 --- a/src/badge/__tests__/badge.js +++ b/src/badge/__tests__/badge.js @@ -1,6 +1,7 @@ import React from 'react'; import { Text } from 'react-native'; import {shallow} from 'enzyme'; +import toJson from 'enzyme-to-json'; import Badge from '../badge'; describe('Badge Component', () => { @@ -8,7 +9,7 @@ describe('Badge Component', () => { const component = shallow(); expect(component.length).toBe(1); - expect(component).toMatchSnapshot(); + expect(toJson(component)).toMatchSnapshot(); }); it('should throw Error is badge is not sent', () => { @@ -22,7 +23,7 @@ describe('Badge Component', () => { const component = shallow(); expect(component.length).toBe(1); - expect(component).toMatchSnapshot(); + expect(toJson(component)).toMatchSnapshot(); expect(component.props().title).toBe('foo'); }); }); diff --git a/src/buttons/__tests__/Button.js b/src/buttons/__tests__/Button.js index 27964aaaad..5e909ed4c8 100644 --- a/src/buttons/__tests__/Button.js +++ b/src/buttons/__tests__/Button.js @@ -1,5 +1,6 @@ import React from 'react'; import {shallow} from 'enzyme'; +import toJson from 'enzyme-to-json'; import Button from '../Button'; import colors from '../../config/colors'; @@ -8,7 +9,7 @@ describe('Button Component', () => { const component = shallow(