From 1863313132c68031065b65b1089c8d2791e47c01 Mon Sep 17 00:00:00 2001 From: Justin DuJardin Date: Wed, 23 Dec 2015 16:36:27 -0800 Subject: [PATCH] test(tabs): verify no ink behavior - add test to verify no ink - fix issue where no-ink did not do anything. --- ng2-material/components/tabs/tabs.ts | 4 +++- test/components/tabs/tabs_spec.ts | 21 +++++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/ng2-material/components/tabs/tabs.ts b/ng2-material/components/tabs/tabs.ts index b9f8de63..b8e0e170 100644 --- a/ng2-material/components/tabs/tabs.ts +++ b/ng2-material/components/tabs/tabs.ts @@ -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 @@ -89,6 +90,7 @@ export class MdTabs { @Input() mdNoScroll: boolean = false; constructor(@Query(MdTab) public panes: QueryList, + private _element: ElementRef, @Attribute('mdNoScroll') noScroll: string) { this.mdNoScroll = isPresent(noScroll); this.panes.changes.subscribe((_) => { @@ -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; diff --git a/test/components/tabs/tabs_spec.ts b/test/components/tabs/tabs_spec.ts index 7016ba9e..54585ec3 100644 --- a/test/components/tabs/tabs_spec.ts +++ b/test/components/tabs/tabs_spec.ts @@ -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() { @@ -117,6 +118,26 @@ export function main() { async.done(); }); })); + + it('md-tabs[md-no-ink] should not ripple', inject([AsyncTestCompleter], (async) => { + let template = ` + + + `; + + 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(); + }); + })); }); });