From b491f7afabc7be5a8111b92ce70133af2b8ce4e4 Mon Sep 17 00:00:00 2001 From: Kristiyan Kostadinov Date: Tue, 23 Jan 2018 16:44:48 +0100 Subject: [PATCH] chore: remove FakeViewportRuler (#9386) Now that all tests have been moved away from the `FakeViewportRuler`, we can safely get rid of it. In general we should avoid stubbing out the window dimensions, because it can be unreliable and it doesn't work well when something is positioned using `bottom` and `right`. --- src/cdk/testing/fake-viewport-ruler.ts | 24 ------------------------ src/cdk/testing/index.ts | 2 -- src/cdk/testing/public-api.ts | 1 - src/lib/button/button.spec.ts | 5 ----- src/lib/radio/radio.spec.ts | 6 +----- 5 files changed, 1 insertion(+), 37 deletions(-) delete mode 100644 src/cdk/testing/fake-viewport-ruler.ts diff --git a/src/cdk/testing/fake-viewport-ruler.ts b/src/cdk/testing/fake-viewport-ruler.ts deleted file mode 100644 index 267c45fa062..00000000000 --- a/src/cdk/testing/fake-viewport-ruler.ts +++ /dev/null @@ -1,24 +0,0 @@ -/** - * @license - * Copyright Google LLC All Rights Reserved. - * - * Use of this source code is governed by an MIT-style license that can be - * found in the LICENSE file at https://angular.io/license - */ - -/** @docs-private */ -export class FakeViewportRuler { - getViewportRect() { - return { - left: 0, top: 0, width: 1014, height: 686, bottom: 686, right: 1014 - }; - } - - getViewportSize() { - return {width: 1014, height: 686}; - } - - getViewportScrollPosition() { - return {top: 0, left: 0}; - } -} diff --git a/src/cdk/testing/index.ts b/src/cdk/testing/index.ts index 96b6b70a623..676ca90f1ff 100644 --- a/src/cdk/testing/index.ts +++ b/src/cdk/testing/index.ts @@ -6,6 +6,4 @@ * found in the LICENSE file at https://angular.io/license */ - - export * from './public-api'; diff --git a/src/cdk/testing/public-api.ts b/src/cdk/testing/public-api.ts index 7922e59e492..752df0b0d44 100644 --- a/src/cdk/testing/public-api.ts +++ b/src/cdk/testing/public-api.ts @@ -10,5 +10,4 @@ export * from './dispatch-events'; export * from './event-objects'; export * from './type-in-element'; export * from './wrapped-error-message'; -export * from './fake-viewport-ruler'; export * from './mock-ng-zone'; diff --git a/src/lib/button/button.spec.ts b/src/lib/button/button.spec.ts index 3aed8f7fafa..955454e523d 100644 --- a/src/lib/button/button.spec.ts +++ b/src/lib/button/button.spec.ts @@ -1,8 +1,6 @@ import {async, ComponentFixture, TestBed} from '@angular/core/testing'; import {Component, DebugElement} from '@angular/core'; import {By} from '@angular/platform-browser'; -import {ViewportRuler} from '@angular/cdk/scrolling'; -import {FakeViewportRuler} from '@angular/cdk/testing'; import {MatButtonModule} from './index'; import {MatRipple} from '@angular/material/core'; @@ -13,9 +11,6 @@ describe('MatButton', () => { TestBed.configureTestingModule({ imports: [MatButtonModule], declarations: [TestApp], - providers: [ - {provide: ViewportRuler, useClass: FakeViewportRuler}, - ] }); TestBed.compileComponents(); diff --git a/src/lib/radio/radio.spec.ts b/src/lib/radio/radio.spec.ts index aa275181a41..ddae2c3c640 100644 --- a/src/lib/radio/radio.spec.ts +++ b/src/lib/radio/radio.spec.ts @@ -2,8 +2,7 @@ import {async, ComponentFixture, fakeAsync, TestBed, tick} from '@angular/core/t import {FormControl, FormsModule, NgModel, ReactiveFormsModule} from '@angular/forms'; import {Component, DebugElement} from '@angular/core'; import {By} from '@angular/platform-browser'; -import {ViewportRuler} from '@angular/cdk/scrolling'; -import {dispatchFakeEvent, FakeViewportRuler} from '@angular/cdk/testing'; +import {dispatchFakeEvent} from '@angular/cdk/testing'; import {RIPPLE_FADE_IN_DURATION, RIPPLE_FADE_OUT_DURATION} from '@angular/material/core'; import {MatRadioButton, MatRadioChange, MatRadioGroup, MatRadioModule} from './index'; @@ -20,9 +19,6 @@ describe('MatRadio', () => { StandaloneRadioButtons, InterleavedRadioGroup, TranscludingWrapper - ], - providers: [ - {provide: ViewportRuler, useClass: FakeViewportRuler} ] });