cleanup(router): fix e2e tests
This commit is contained in:
parent
b625f2471a
commit
9f784dcc5a
|
@ -22,7 +22,7 @@ import {ObservableWrapper} from '../facade/async';
|
|||
@Directive({selector: '[routerLink]'})
|
||||
export class RouterLink implements OnDestroy {
|
||||
@Input() target: string;
|
||||
private _comands: any[] = [];
|
||||
private _commands: any[] = [];
|
||||
private _subscription: any;
|
||||
|
||||
@HostBinding() href: string;
|
||||
|
@ -38,9 +38,9 @@ export class RouterLink implements OnDestroy {
|
|||
@Input()
|
||||
set routerLink(data: any[]|any) {
|
||||
if (isArray(data)) {
|
||||
this._comands = <any[]>data;
|
||||
this._commands = <any[]>data;
|
||||
} else {
|
||||
this._comands = [data];
|
||||
this._commands = [data];
|
||||
}
|
||||
this._updateTargetUrlAndHref();
|
||||
}
|
||||
|
@ -49,14 +49,14 @@ export class RouterLink implements OnDestroy {
|
|||
@HostListener("click")
|
||||
onClick(): boolean {
|
||||
if (!isString(this.target) || this.target == '_self') {
|
||||
this._router.navigate(this._comands, this._routeSegment);
|
||||
this._router.navigate(this._commands, this._routeSegment);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private _updateTargetUrlAndHref(): void {
|
||||
let tree = this._router.createUrlTree(this._comands, this._routeSegment);
|
||||
let tree = this._router.createUrlTree(this._commands, this._routeSegment);
|
||||
if (isPresent(tree)) {
|
||||
this.href = this._router.serializeUrl(tree);
|
||||
this.isActive = this._router.urlTree.contains(tree);
|
||||
|
|
|
@ -7,12 +7,11 @@ function waitForElement(selector) {
|
|||
}
|
||||
|
||||
describe('alt-routing inbox-app', () => {
|
||||
var URL = 'all/playground/src/alt_routing/';
|
||||
|
||||
afterEach(verifyNoBrowserErrors);
|
||||
|
||||
describe('index view', () => {
|
||||
var URL = 'all/playground/src/alt_routing/';
|
||||
|
||||
it('should list out the current collection of items', () => {
|
||||
browser.get(URL);
|
||||
waitForElement('.inbox-item-record');
|
||||
|
@ -31,8 +30,6 @@ describe('alt-routing inbox-app', () => {
|
|||
|
||||
|
||||
describe('drafts view', () => {
|
||||
var URL = 'all/playground/src/alt_routing/#/drafts';
|
||||
|
||||
it('should navigate to the drafts view when the drafts link is clicked', () => {
|
||||
browser.get(URL);
|
||||
waitForElement('.inbox-item-record');
|
||||
|
@ -55,8 +52,6 @@ describe('alt-routing inbox-app', () => {
|
|||
|
||||
|
||||
describe('detail view', () => {
|
||||
var URL = 'all/playground/src/alt_routing/';
|
||||
|
||||
it('should navigate to the detail view when an email is clicked', () => {
|
||||
browser.get(URL);
|
||||
waitForElement('#item-10');
|
||||
|
@ -83,7 +78,7 @@ describe('alt-routing inbox-app', () => {
|
|||
element(by.css('#item-10')).click();
|
||||
waitForElement('.sort-button');
|
||||
element(by.css('.sort-button')).click();
|
||||
expect(browser.getCurrentUrl()).toMatch(/\/;sort=date$/);
|
||||
expect(browser.getCurrentUrl()).toContain(';sort=date');
|
||||
waitForElement('.inbox-item-record');
|
||||
expect(element(by.css(".inbox-item-record > a")).getAttribute("id")).toEqual("item-137");
|
||||
});
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<inbox-side-menu class="inbox-aside">
|
||||
<a [routerLink]="['/']" class="link" [class.active]="inboxPageActive()">Inbox</a>
|
||||
<a [routerLink]="['/inbox']" class="link" [class.active]="inboxPageActive()">Inbox</a>
|
||||
<a [routerLink]="['/drafts']" class="link" [class.active]="draftsPageActive()">Drafts</a>
|
||||
</inbox-side-menu>
|
||||
<router-outlet></router-outlet>
|
||||
|
|
|
@ -156,6 +156,7 @@ class DraftsCmp {
|
|||
})
|
||||
@Routes([
|
||||
new Route({path: '/', component: InboxCmp}),
|
||||
new Route({path: '/inbox', component: InboxCmp}),
|
||||
new Route({path: '/drafts', component: DraftsCmp}),
|
||||
new Route({path: '/detail/:id', component: InboxDetailCmp})
|
||||
])
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
|
||||
<hr />
|
||||
|
||||
<a [routerLink]="['/', { sort: 'date'} ]" class="sort-button">
|
||||
<a [routerLink]="['/inbox', { sort: 'date'} ]" class="sort-button">
|
||||
View Latest Messages
|
||||
</a>
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue