Skip to content

Commit

Permalink
feat: add React 16 support
Browse files Browse the repository at this point in the history
  • Loading branch information
gregberge committed Oct 10, 2017
1 parent c8e9ae0 commit 712cbf3
Show file tree
Hide file tree
Showing 5 changed files with 821 additions and 474 deletions.
44 changes: 25 additions & 19 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@
"license": "MIT",
"jest": {
"rootDir": "src",
"coverageDirectory": "./coverage/"
"coverageDirectory": "./coverage/",
"setupFiles": [
"raf/polyfill",
"<rootDir>/../testSetup.js"
]
},
"scripts": {
"build": "rm -rf lib/ && NODE_ENV=production babel src -d lib && cp package.json lib/ && cp README.md lib/",
Expand All @@ -28,32 +32,34 @@
"test": "eslint . && jest --runInBand --coverage && codecov"
},
"peerDependencies": {
"react": "^15.0.0"
"react": "^15.0.0 || ^16.0.0"
},
"devDependencies": {
"babel-cli": "^6.24.1",
"babel-eslint": "^7.2.3",
"babel-plugin-dynamic-import-node": "^1.0.2",
"babel-cli": "^6.26.0",
"babel-eslint": "^8.0.1",
"babel-plugin-dynamic-import-node": "^1.1.0",
"babel-plugin-transform-class-properties": "^6.24.1",
"babel-plugin-transform-object-rest-spread": "^6.23.0",
"babel-plugin-transform-object-rest-spread": "^6.26.0",
"babel-preset-env": "^1.6.0",
"babel-preset-react": "^6.24.1",
"codecov": "^2.3.0",
"conventional-github-releaser": "^1.1.12",
"conventional-recommended-bump": "^1.0.1",
"enzyme": "^2.9.1",
"eslint": "^4.4.1",
"eslint-config-airbnb": "^15.1.0",
"eslint-config-prettier": "^2.3.0",
"conventional-recommended-bump": "^1.0.2",
"enzyme": "^3.1.0",
"enzyme-adapter-react-16": "^1.0.1",
"eslint": "^4.8.0",
"eslint-config-airbnb": "^16.0.0",
"eslint-config-prettier": "^2.6.0",
"eslint-plugin-import": "^2.7.0",
"eslint-plugin-jsx-a11y": "^5.0.1",
"eslint-plugin-react": "^7.0.1",
"jest": "^20.0.4",
"eslint-plugin-jsx-a11y": "^6.0.2",
"eslint-plugin-react": "^7.4.0",
"jest": "^21.2.1",
"mversion": "^1.10.1",
"prettier": "^1.5.3",
"react": "^15.6.1",
"react-dom": "^15.6.1",
"react-router": "^4.1.2",
"react-test-renderer": "^15.6.1"
"prettier": "^1.7.4",
"raf": "^3.4.0",
"react": "^16.0.0",
"react-dom": "^16.0.0",
"react-router": "^4.2.0",
"react-test-renderer": "^16.0.0"
}
}
Binary file modified resources/loadable-components.sketch
Binary file not shown.
14 changes: 10 additions & 4 deletions src/loadable.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ describe('#loadable', () => {
const wrapper = mount(<Loadable />)
expect(wrapper.find('EmptyComponent').exists()).toBe(true)
await Loadable.load()
wrapper.update()
expect(wrapper.contains(<Dummy />)).toBe(true)
})

Expand All @@ -26,6 +27,7 @@ describe('#loadable', () => {
expect(wrapper.find('EmptyComponent').exists()).toBe(true)
Loadable.load()
await Loadable.load()
wrapper.update()
expect(getComponent).toHaveBeenCalledTimes(1)
expect(wrapper.contains(<Dummy />)).toBe(true)
})
Expand Down Expand Up @@ -63,13 +65,15 @@ describe('#loadable', () => {

it('should be possible to add a loading component', async () => {
const LoadableWithLoading = loadable(() => import('./__fixtures__/Dummy'), {
LoadingComponent: ({ className }) =>
<div className={className}>loading</div>,
LoadingComponent: ({ className }) => (
<div className={className}>loading</div>
),
})

const wrapper = mount(<LoadableWithLoading className="x" />)
expect(wrapper.contains(<div className="x">loading</div>)).toBe(true)
await LoadableWithLoading.load()
wrapper.update()
expect(wrapper.contains(<Dummy className="x" />)).toBe(true)
})

Expand All @@ -79,8 +83,9 @@ describe('#loadable', () => {
throw new Error('Bouh')
},
{
ErrorComponent: ({ error, props }) =>
<div className={props.className}>{error.message}</div>,
ErrorComponent: ({ error, props }) => (
<div className={props.className}>{error.message}</div>
),
},
)

Expand All @@ -90,6 +95,7 @@ describe('#loadable', () => {
await new Promise(resolve => setTimeout(resolve))
await LoadableWithError.load()
} catch (error) {
wrapper.update()
expect(wrapper.contains(<div className="x">Bouh</div>)).toBe(true)
}
})
Expand Down
5 changes: 5 additions & 0 deletions testSetup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/* eslint-disable import/no-extraneous-dependencies */
import Enzyme from 'enzyme'
import Adapter from 'enzyme-adapter-react-16'

Enzyme.configure({ adapter: new Adapter() })
Loading

0 comments on commit 712cbf3

Please sign in to comment.