Skip to content
This repository has been archived by the owner on Feb 2, 2019. It is now read-only.

Commit

Permalink
test(tabs): verify no ink behavior
Browse files Browse the repository at this point in the history
 - add test to verify no ink
 - fix issue where no-ink did not do anything.
  • Loading branch information
justindujardin committed Dec 24, 2015
1 parent 3cf848d commit 1863313
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
4 changes: 3 additions & 1 deletion ng2-material/components/tabs/tabs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {NgFor} from "angular2/common";
import {Host} from "angular2/core";
import {SkipSelf} from "angular2/core";
import {Query} from "angular2/core";
import {ElementRef} from "angular2/core";


// TODO: behaviors to test
Expand Down Expand Up @@ -89,6 +90,7 @@ export class MdTabs {
@Input() mdNoScroll: boolean = false;

constructor(@Query(MdTab) public panes: QueryList<MdTab>,
private _element: ElementRef,
@Attribute('mdNoScroll') noScroll: string) {
this.mdNoScroll = isPresent(noScroll);
this.panes.changes.subscribe((_) => {
Expand Down Expand Up @@ -134,7 +136,7 @@ export class MdTabs {
}

onTabClick(pane: MdTab, event?) {
if (event && Ink.canApply(event.target)) {
if (event && Ink.canApply(this._element.nativeElement)) {
Ink.rippleEvent(event.target, event);
}
this.selectedTab = pane;
Expand Down
21 changes: 21 additions & 0 deletions test/components/tabs/tabs_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {ComponentFixture} from "angular2/testing";
import {CORE_DIRECTIVES} from "angular2/common";
import {findChildrenByAttribute,findChildrenByTag,findChildByTag} from "../../util";
import {TimerWrapper} from "angular2/src/facade/async";
import {Ink} from "../../../ng2-material/core/util/ink";


export function main() {
Expand Down Expand Up @@ -117,6 +118,26 @@ export function main() {
async.done();
});
}));

it('md-tabs[md-no-ink] should not ripple', inject([AsyncTestCompleter], (async) => {
let template = `
<md-tabs md-no-ink [selected]="selectedIndex">
<template md-tab label="Tab1"><span>Tab1</span></template>
</md-tabs>`;

setup(template).then((api: ITabsFixture) => {
let save = Ink.rippleEvent;
let fired = false;
Ink.rippleEvent = () => {
fired = true;
return Promise.resolve();
};
api.tabButtons[0].click();
expect(fired).toBe(false);
Ink.rippleEvent = save;
async.done();
});
}));
});
});

Expand Down

0 comments on commit 1863313

Please sign in to comment.