Skip to content
Permalink
Browse files

Enzyme and snapshot tests for our Title component

  • Loading branch information...
Qaiser Abbas Qaiser Abbas
Qaiser Abbas authored and Qaiser Abbas committed May 12, 2018
1 parent 007ec23 commit 8280243d7c9cab6b69b2b2ed530756fe8a4bdcca
Showing with 101 additions and 1 deletion.
  1. +3 −0 .eslintrc.js
  2. +4 −0 jestSetup.js
  3. +5 −1 package.json
  4. +18 −0 src/components/__tests__/Title.js
  5. +71 −0 src/components/__tests__/__snapshots__/Title.js.snap
@@ -1,4 +1,7 @@
module.exports = {
env: {
jest: true,
},
parser: 'babel-eslint',
extends: ['airbnb', 'plugin:prettier/recommended'],
plugins: ['prettier'],
@@ -0,0 +1,4 @@
import { configure } from 'enzyme'
import Adapter from 'enzyme-adapter-react-16'

configure({ adapter: new Adapter() })
@@ -27,12 +27,16 @@
"eslint-check": "eslint --print-config .eslintrc.js | eslint-config-prettier-check"
},
"jest": {
"preset": "jest-expo"
"preset": "jest-expo",
"setupTestFrameworkScriptFile": "<rootDir>/jestSetup.js"
},
"dependencies": {
"enzyme": "^3.3.0",
"enzyme-adapter-react-16": "^1.1.1",
"expo": "^27.0.1",
"prop-types": "^15.6.1",
"react": "16.3.1",
"react-dom": "16",
"react-native": "~0.55.2",
"react-navigation": "^2.0.1"
}
@@ -0,0 +1,18 @@
import React from 'react'
import { shallow } from 'enzyme'
import Title from '../Title'

it('renders correctly', () => {
const wrapper = shallow(<Title text="Sample Text" />)
expect(wrapper).toMatchSnapshot()

expect(wrapper.prop('accessible')).toBe(true)
expect(wrapper.prop('style')).toEqual({
backgroundColor: '#434343',
color: '#fff',
fontSize: 20,
marginTop: 20,
padding: 20,
textAlign: 'center',
})
})
@@ -0,0 +1,71 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`renders correctly 1`] = `
ShallowWrapper {
"length": 1,
Symbol(enzyme.__root__): [Circular],
Symbol(enzyme.__unrendered__): <Unknown
text="Sample Text"
/>,
Symbol(enzyme.__renderer__): Object {
"batchedUpdates": [Function],
"getNode": [Function],
"render": [Function],
"simulateEvent": [Function],
"unmount": [Function],
},
Symbol(enzyme.__node__): Object {
"instance": null,
"key": undefined,
"nodeType": "class",
"props": Object {
"accessible": true,
"allowFontScaling": true,
"children": "Sample Text",
"ellipsizeMode": "tail",
"style": Object {
"backgroundColor": "#434343",
"color": "#fff",
"fontSize": 20,
"marginTop": 20,
"padding": 20,
"textAlign": "center",
},
},
"ref": null,
"rendered": "Sample Text",
"type": [Function],
},
Symbol(enzyme.__nodes__): Array [
Object {
"instance": null,
"key": undefined,
"nodeType": "class",
"props": Object {
"accessible": true,
"allowFontScaling": true,
"children": "Sample Text",
"ellipsizeMode": "tail",
"style": Object {
"backgroundColor": "#434343",
"color": "#fff",
"fontSize": 20,
"marginTop": 20,
"padding": 20,
"textAlign": "center",
},
},
"ref": null,
"rendered": "Sample Text",
"type": [Function],
},
],
Symbol(enzyme.__options__): Object {
"adapter": ReactSixteenAdapter {
"options": Object {
"enableComponentDidUpdateOnSetState": true,
},
},
},
}
`;

0 comments on commit 8280243

Please sign in to comment.
You can’t perform that action at this time.