Skip to content

Commit

Permalink
Release v2.0.1
Browse files Browse the repository at this point in the history
Do not need to launch on mount.
That fixes server side rendering.
  • Loading branch information
mironov committed May 23, 2016
1 parent 3582de5 commit 96a6ecc
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 21 deletions.
5 changes: 0 additions & 5 deletions build/loading_bar.js
Expand Up @@ -45,11 +45,6 @@ var LoadingBar = exports.LoadingBar = function (_React$Component) {
}

_createClass(LoadingBar, [{
key: 'componentWillMount',
value: function componentWillMount() {
this.launch();
}
}, {
key: 'componentWillReceiveProps',
value: function componentWillReceiveProps(nextProps) {
if (nextProps.loading > this.props.loading) {
Expand Down
4 changes: 2 additions & 2 deletions package.json
@@ -1,6 +1,6 @@
{
"name": "react-redux-loading-bar",
"version": "2.0.0",
"version": "2.0.1",
"description": "Simple Loading Bar for Redux and React",
"main": "build/index.js",
"scripts": {
Expand All @@ -11,7 +11,7 @@
"test:watch": "npm run test -- --watch",
"test:coverage": "`npm bin`/istanbul cover -x 'spec/**' `npm bin`/_mocha -- -u exports --compilers js:babel-register spec/",
"test:coveralls": "npm run test:coverage && node ./node_modules/coveralls/bin/coveralls.js < coverage/lcov.info",
"prepublish": "pkgfiles"
"pkgfiles": "pkgfiles"
},
"repository": {
"type": "git",
Expand Down
23 changes: 13 additions & 10 deletions spec/loading_bar.js
Expand Up @@ -59,24 +59,24 @@ describe('LoadingBar', () => {
restoreSpies()
})

it('launches on component mount', () => {
it('does not launch on component mount', () => {
shallow(<LoadingBar />)
expect(spyLaunch).toHaveBeenCalled()
expect(spyLaunch.calls.length).toEqual(1)
expect(spyLaunch).toNotHaveBeenCalled()
expect(spyLaunch.calls.length).toEqual(0)
})

it('launches on component mount and then on loading increase', () => {
it('launches on loading count increase', () => {
const wrapper = shallow(<LoadingBar />)
wrapper.setProps({ loading: 1 })
expect(spyLaunch).toHaveBeenCalled()
expect(spyLaunch.calls.length).toEqual(2)
expect(spyLaunch.calls.length).toEqual(1)
})

it('does not launch if loading count is not increased', () => {
const wrapper = shallow(<LoadingBar />)
wrapper.setProps({ loading: 0 })
expect(spyLaunch).toHaveBeenCalled()
expect(spyLaunch.calls.length).toEqual(1)
expect(spyLaunch).toNotHaveBeenCalled()
expect(spyLaunch.calls.length).toEqual(0)
})
})

Expand All @@ -97,21 +97,24 @@ describe('LoadingBar', () => {
})

it('schedules simulateProgress on UPDATE_TIME', () => {
shallow(<LoadingBar />)
const wrapper = shallow(<LoadingBar />)
wrapper.setProps({ loading: 1 })
clock.tick(UPDATE_TIME)
expect(spySimulateProgress).toHaveBeenCalled()
expect(spySimulateProgress.calls.length).toEqual(1)
})

it('does not schedule simulateProgress before UPDATE_TIME', () => {
shallow(<LoadingBar />)
const wrapper = shallow(<LoadingBar />)
wrapper.setProps({ loading: 1 })
clock.tick(UPDATE_TIME - 1)
expect(spySimulateProgress).toNotHaveBeenCalled()
expect(spySimulateProgress.calls.length).toEqual(0)
})

it('schedules simulateProgress twice after UPDATE_TIME * 2', () => {
shallow(<LoadingBar />)
const wrapper = shallow(<LoadingBar />)
wrapper.setProps({ loading: 1 })
clock.tick(UPDATE_TIME * 2)
expect(spySimulateProgress).toHaveBeenCalled()
expect(spySimulateProgress.calls.length).toEqual(2)
Expand Down
4 changes: 0 additions & 4 deletions src/loading_bar.js
Expand Up @@ -17,10 +17,6 @@ export class LoadingBar extends React.Component {
this.boundSimulateProgress = this.simulateProgress.bind(this)
}

componentWillMount() {
this.launch()
}

componentWillReceiveProps(nextProps) {
if (nextProps.loading > this.props.loading) {
this.launch()
Expand Down

0 comments on commit 96a6ecc

Please sign in to comment.