Skip to content

Commit

Permalink
chore: fix tooltip failing tests (#8737)
Browse files Browse the repository at this point in the history
* Fixes the unit-test for the tooltip that currently fails. The test started to fail because an `inject(XX)` has been added to the `beforeEach`, which then caused the `overrideProvider` method to no longer work.
  • Loading branch information
devversion authored and tinayuangao committed Dec 1, 2017
1 parent 841f753 commit 847a60c
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/lib/tooltip/tooltip.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,12 @@ describe('MatTooltip', () => {
let overlayContainer: OverlayContainer;
let overlayContainerElement: HTMLElement;
let dir: {value: Direction};
let platform: {IOS: boolean, isBrowser: boolean};

beforeEach(async(() => {
// Set the default Platform override that can be updated before component creation.
platform = {IOS: false, isBrowser: true};

TestBed.configureTestingModule({
imports: [MatTooltipModule, OverlayModule, NoopAnimationsModule],
declarations: [
Expand All @@ -49,7 +53,7 @@ describe('MatTooltip', () => {
TooltipOnTextFields
],
providers: [
{provide: Platform, useValue: {IOS: false, isBrowser: true}},
{provide: Platform, useFactory: () => platform},
{provide: Directionality, useFactory: () => {
return dir = {value: 'ltr'};
}}
Expand Down Expand Up @@ -684,9 +688,7 @@ describe('MatTooltip', () => {

describe('special cases', () => {
it('should clear the `user-select` when a tooltip is set on a text field in iOS', () => {
TestBed.overrideProvider(Platform, {
useValue: {IOS: true, isBrowser: true}
});
platform.IOS = true;

const fixture = TestBed.createComponent(TooltipOnTextFields);
const instance = fixture.componentInstance;
Expand Down

0 comments on commit 847a60c

Please sign in to comment.