-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
updated: added support for routes with fragments
- Loading branch information
1 parent
760ee3c
commit c3413f0
Showing
4 changed files
with
50 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import {fireEvent, sleep} from './util' | ||
import {initDomListeners, route, setBase} from '../src' | ||
import $ from 'bianco.query' | ||
import {expect} from 'chai' | ||
import {spy} from 'sinon' | ||
|
||
describe('misc DOM-related', function() { | ||
let teardown // eslint-disable-line | ||
|
||
beforeEach(() => { | ||
setBase('/') | ||
|
||
document.body.innerHTML = ` | ||
<nav> | ||
<a id="a1" href="/hello#anchor">Hello</a> | ||
</nav> | ||
` | ||
teardown = initDomListeners($('nav')[0]) | ||
}) | ||
|
||
afterEach(() => { | ||
document.body.innerHTML = '' | ||
window.history.replaceState(null, '', '/') | ||
teardown() | ||
}) | ||
|
||
it('url with fragments are supported', async function() { | ||
const onRoute = spy() | ||
const hello = route('/hello(/?[?#].*)?').on.value(onRoute) | ||
|
||
const [a] = $('#a1') | ||
|
||
fireEvent(a, 'click') | ||
|
||
await sleep() | ||
|
||
expect(onRoute).to.have.been.called | ||
expect(window.location.pathname).to.be.equal('/hello') | ||
expect(window.location.hash).to.be.equal('#anchor') | ||
|
||
hello.end() | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters