Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace invariant by warning in createMemoryHistory #170

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 7 additions & 5 deletions CHANGES.md
@@ -1,19 +1,21 @@
## [v1.15.0]
> Dec 7, 2015
## [HEAD]
> Unreleased

- **Feature** Accept location descriptors in `createPath` and `createHref` ([#173])
- **Deprecation** Deprecate the `query` arg to `createPath` and `createHref` in favor of using location descriptor objects ([#173])
- **Bugfix:** Don't throw in memory history when out of history entries ([#170])

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

## [v1.14.0]
> Dec 6, 2015

- **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 @@ -34,7 +36,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
5 changes: 3 additions & 2 deletions modules/__tests__/MemoryHistory-test.js
Expand Up @@ -71,7 +71,7 @@ describe('memory history', function () {

expect(function () {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, if we already have test coverage, can we just leave the cases there (with some comments) just to check that they don't throw?

history.goForward()
}).toThrow(/Cannot go\(\d+\) there is not enough history/)
}).toNotThrow(/Cannot go\(\d+\) there is not enough history/)

history.goBack()
history.push({
Expand All @@ -81,7 +81,8 @@ describe('memory history', function () {

expect(function () {
history.goForward()
}).toThrow(/Cannot go\(\d+\) there is not enough history/)
}).toNotThrow(/Cannot go\(\d+\) there is not enough history/)

})
})
})
14 changes: 9 additions & 5 deletions modules/createMemoryHistory.js
@@ -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 @@ -94,11 +95,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