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

Test improvement: observe window.location #918

Open
thejohnhoffer opened this issue Dec 21, 2021 · 0 comments
Open

Test improvement: observe window.location #918

thejohnhoffer opened this issue Dec 21, 2021 · 0 comments

Comments

@thejohnhoffer
Copy link

thejohnhoffer commented Dec 21, 2021

Expected behavior

Tests should ensure window.location is correctly modified.

Actual behavior

Test sequences only test against history.location

Details

For HashHistory, "window.location" and "history" should be related as follows:

const historyHref = createPath(history.location);
const windowHref = window.location.hash.substr(1);
expect(historyHref).toEqual(windowHref)

All of the tests in the "TestSequences" folder only test against history.location, but there is currently "no guarantee" that the location is actually reflected in the window.location.

In my PR to solve Issue #912, I noticed there is currently no test of the relationship between the two location states. That PR therefore happens to include a general fix for this issue. If PR #911 is ultimately rejected, this issue could be solved with a new PR just with this:

afterEach(() => { 
  const historyHref = createPath(history.location);
  const windowHref = window.location.hash.substr(1);
  expect(historyHref).toEqual(windowHref);
})

added to packages/history/__tests__/hash-test.js

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant