Skip to content

Commit

Permalink
Update tests for fallThrough fix.
Browse files Browse the repository at this point in the history
  • Loading branch information
tripp committed Aug 14, 2014
1 parent 3f5da32 commit e52c765
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/pjax/tests/unit/assets/pjax-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ suite.add(new Y.Test.Case({
'`navigate` event should not fire when a modifier key is pressed': !html5,
'`navigate` event should not fire when a click element is not an anchor': !html5,
'`navigate` event should not fire when a link is clicked with a URL from another origin': !html5,
'`navigate` event should not fire for a hash URL that resolves to the current page': !html5,
'`navigate` event should not fire for a hash URL that resolves to the current page when allowFallThrough is set to `false`': !html5,
'`navigate` event should fire for a hash-less URL that resolves to the current page': !html5,
'`navigate` event should fire for a hash URL that resolves to the current page when `navigateOnHash` is `true`': !html5
}
Expand Down Expand Up @@ -427,7 +427,8 @@ suite.add(new Y.Test.Case({
});
},

'`navigate` event should not fire for a hash URL that resolves to the current page': function () {
'`navigate` event should not fire for a hash URL that resolves to the current page when allowFallThrough is set to `false`': function () {
this.pjax.set("allowFallThrough", false);
this.pjax.on('navigate', function (e) {
Assert.fail();
});
Expand Down Expand Up @@ -569,6 +570,13 @@ suite.add(new Y.Test.Case({

didNavigate = this.pjax.navigate('http://some.random.host.example.com/foo/bar/');
Assert.areSame(false, didNavigate, '`navigate()` did not return `false`');
},

'`navigate()` should fall through to window.location with no matching route': function() {
var currentLocation = win.location;

Assert.isTrue(this.pjax.navigate('#unmatched-route'), 'navigate() did not return `true`');
Assert.areEqual(currentLocation, win.location, 'The current `window.location` does not match the `window.location` before `navigate()`.');
}
}));

Expand Down
1 change: 1 addition & 0 deletions src/pjax/tests/unit/pjax.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<a href="assets/page-full.html" id="link-full" class="yui3-pjax">full page</a>
<a href="assets/page-minimal.html" id="link-minimal" class="yui3-pjax">minimal page</a>
<a href="assets/page-text.html" id="link-text" class="yui3-pjax">text page</a>
<a href="assets/missing/pagedoesnotexist.html" id="unmatched-route" class="yui-pjax">missing page</a>
<a href="#log" id="link-in-page" class="yui3-pjax">in-page</a>
<a href="" id="link-current" class="yui3-pjax">current page</a>
<span id="link-fake" class="yui3-pjax">fake</span>
Expand Down

0 comments on commit e52c765

Please sign in to comment.