Skip to content

Commit 847a60c

Browse files
devversiontinayuangao
authored andcommitted
chore: fix tooltip failing tests (#8737)
* 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.
1 parent 841f753 commit 847a60c

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/lib/tooltip/tooltip.spec.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,12 @@ describe('MatTooltip', () => {
3737
let overlayContainer: OverlayContainer;
3838
let overlayContainerElement: HTMLElement;
3939
let dir: {value: Direction};
40+
let platform: {IOS: boolean, isBrowser: boolean};
4041

4142
beforeEach(async(() => {
43+
// Set the default Platform override that can be updated before component creation.
44+
platform = {IOS: false, isBrowser: true};
45+
4246
TestBed.configureTestingModule({
4347
imports: [MatTooltipModule, OverlayModule, NoopAnimationsModule],
4448
declarations: [
@@ -49,7 +53,7 @@ describe('MatTooltip', () => {
4953
TooltipOnTextFields
5054
],
5155
providers: [
52-
{provide: Platform, useValue: {IOS: false, isBrowser: true}},
56+
{provide: Platform, useFactory: () => platform},
5357
{provide: Directionality, useFactory: () => {
5458
return dir = {value: 'ltr'};
5559
}}
@@ -684,9 +688,7 @@ describe('MatTooltip', () => {
684688

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

691693
const fixture = TestBed.createComponent(TooltipOnTextFields);
692694
const instance = fixture.componentInstance;

0 commit comments

Comments
 (0)