Skip to content

Commit

Permalink
[appSwitcher/tests] update to match propagation based fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
spalger committed Sep 23, 2015
1 parent e714193 commit 96a3406
Showing 1 changed file with 33 additions and 8 deletions.
41 changes: 33 additions & 8 deletions src/ui/public/chrome/appSwitcher/__tests__/appSwitcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,13 +121,36 @@ describe('appSwitcher directive', function () {
});
});

context('clicking a link with matching href but missing hash', function () {
var url = 'http://localhost:555/app/myApp?query=1';
beforeEach(setup(url + '#/lastSubUrl', [
{ url: url }
]));

it('just prevents propogation (no reload)', function () {
var event = new $.Event('click');

expect(env.location.reload.callCount).to.be(0);
expect(event.isDefaultPrevented()).to.be(false);
expect(event.isPropagationStopped()).to.be(false);

var $link = findTestSubject(env.$el, 'appLink');
expect($link.prop('href')).to.be(url);
$link.trigger(event);

expect(env.location.reload.callCount).to.be(0);
expect(event.isDefaultPrevented()).to.be(false);
expect(event.isPropagationStopped()).to.be(true);
});
});

context('clicking a link that matches entire url', function () {
var url = 'http://localhost:555/app/myApp#/lastSubUrl';
beforeEach(setup(url, [
{ url: url }
]));

it('calls window.location.reload and prevents default behavior', function () {
it('calls window.location.reload and prevents propogation', function () {
var event = new $.Event('click');

expect(env.location.reload.callCount).to.be(0);
Expand All @@ -138,19 +161,21 @@ describe('appSwitcher directive', function () {
expect($link.prop('href')).to.be(env.currentHref);
$link.trigger(event);

expect(event.isPropagationStopped()).to.be(false);
expect(event.isDefaultPrevented()).to.be(true);
expect(env.location.reload.callCount).to.be(1);
expect(event.isDefaultPrevented()).to.be(false);
expect(event.isPropagationStopped()).to.be(true);
});
});

context('clicking a link with matching href except different hash', function () {
var url = 'http://localhost:555/app/myApp?query=1';
context('clicking a link with matching href but changed hash', function () {
var rootUrl = 'http://localhost:555/app/myApp?query=1';
var url = rootUrl + '#/lastSubUrl2';

beforeEach(setup(url + '#/lastSubUrl', [
{ url: url }
]));

it('calls window.location.reload and prevents default behavior', function () {
it('calls window.location.reload and prevents propogation', function () {
var event = new $.Event('click');

expect(env.location.reload.callCount).to.be(0);
Expand All @@ -161,9 +186,9 @@ describe('appSwitcher directive', function () {
expect($link.prop('href')).to.be(url);
$link.trigger(event);

expect(event.isPropagationStopped()).to.be(false);
expect(event.isDefaultPrevented()).to.be(true);
expect(env.location.reload.callCount).to.be(1);
expect(event.isDefaultPrevented()).to.be(false);
expect(event.isPropagationStopped()).to.be(true);
});
});

Expand Down

0 comments on commit 96a3406

Please sign in to comment.