Skip to content

Commit

Permalink
Merge branch 'petrbrzek-master'
Browse files Browse the repository at this point in the history
  • Loading branch information
taion committed Dec 11, 2015
2 parents a154e88 + b666195 commit e73011a
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 13 deletions.
12 changes: 10 additions & 2 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
## [HEAD]
> Unreleased
- **Bugfix:** Don't throw in memory history when out of history entries ([#170])

[HEAD]: https://github.com/rackt/history/compare/latest...HEAD
[#170]: https://github.com/rackt/history/pull/170

## [v1.16.0]

- **Bugfix:** Silence all warnings that were introduced since 1.13 (see [rackt/react-router#2682])
Expand All @@ -22,7 +30,7 @@
- **Feature:** Accept objects in `history.push` and `history.replace` ([#141])
- **Deprecation:** Deprecate `history.pushState` and `history.replaceState` in favor of passing objects to `history.push` and `history.replace` ([#168])
- **Bugfix:** Disable browser history on Chrome iOS ([#146])
- **Bugfix:** Do not convert same-path PUSH to REPLACE if the hash has changed ([#167])
- **Bugfix:** Do not convert same-path PUSH to REPLACE if the hash has changed ([#167])
- Add ES2015 module build ([#152])
- Use query-string module instead of qs to save on bytes ([#121])

Expand All @@ -43,7 +51,7 @@

[v1.13.1]: https://github.com/rackt/history/compare/v1.13.0...v1.13.1
[#43]: https://github.com/rackt/history/pull/43
[#139]: https://github.com/rackt/history/pull/139
[#139]: https://github.com/rackt/history/pull/139

## [v1.13.0]
> Oct 28, 2015
Expand Down
20 changes: 14 additions & 6 deletions modules/__tests__/MemoryHistory-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,19 +69,27 @@ describe('memory history', function () {
expect(location.state).toEqual({ id: 5 })
expect(location.pathname).toEqual('/5')

expect(function () {
history.goForward()
}).toThrow(/Cannot go\(\d+\) there is not enough history/)
// Mkae sure this doesn't do anything.
history.goForward()
expect(location.state).toEqual({ id: 5 })
expect(location.pathname).toEqual('/5')

history.goBack()
history.push({
pathname: '/6',
state: { id: 6 }
})

expect(function () {
history.goForward()
}).toThrow(/Cannot go\(\d+\) there is not enough history/)
// Make sure this doesn't do anything.
history.goForward()
expect(location.state).toEqual({ id: 6 })
expect(location.pathname).toEqual('/6')

// Make sure this doesn't do anything.
history.go(-999)
expect(location.state).toEqual({ id: 6 })
expect(location.pathname).toEqual('/6')

})
})
})
14 changes: 9 additions & 5 deletions modules/createMemoryHistory.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import warning from 'warning'
import invariant from 'invariant'
import { PUSH, REPLACE, POP } from './Actions'
import createHistory from './createHistory'
Expand Down Expand Up @@ -97,11 +98,14 @@ function createMemoryHistory(options={}) {

function go(n) {
if (n) {
invariant(
canGo(n),
'Cannot go(%s) there is not enough history',
n
)
if (!canGo(n)) {
warning(
false,
'Cannot go(%s) there is not enough history',
n
)
return
}

current += n

Expand Down

0 comments on commit e73011a

Please sign in to comment.