Skip to content

Commit 4ab8031

Browse files
crisbetojelbourn
authored andcommitted
test: clean up usages of deprecated TestBed method (#17846)
Replaces all the usages of the deprecated `TestBed.get` with `TestBed.inject` which has better type inference.
1 parent 7defaa6 commit 4ab8031

File tree

4 files changed

+10
-10
lines changed

4 files changed

+10
-10
lines changed

src/cdk/a11y/focus-trap/focus-trap.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ describe('FocusTrap', () => {
4848
// focus event handler directly.
4949
const result = focusTrapInstance.focusLastTabbableElement();
5050

51-
const platformId = TestBed.get(PLATFORM_ID);
51+
const platformId = TestBed.inject(PLATFORM_ID);
5252
// In iOS button elements are never tabbable, so the last element will be the input.
5353
const lastElement = new Platform(platformId).IOS ? 'input' : 'button';
5454

src/cdk/clipboard/clipboard.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ describe('Clipboard', () => {
1717
beforeEach(() => {
1818
TestBed.configureTestingModule({});
1919

20-
clipboard = TestBed.get(Clipboard);
21-
document = TestBed.get(DOCUMENT);
20+
clipboard = TestBed.inject(Clipboard);
21+
document = TestBed.inject(DOCUMENT);
2222
execCommand = spyOn(document, 'execCommand').and.returnValue(true);
2323
body = document.body;
2424

src/cdk/clipboard/copy-to-clipboard.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ describe('CdkCopyToClipboard', () => {
3939

4040
const host = fixture.componentInstance;
4141
host.content = COPY_CONTENT;
42-
clipboard = TestBed.get(Clipboard);
42+
clipboard = TestBed.inject(Clipboard);
4343
fixture.detectChanges();
4444
});
4545

src/cdk/drag-drop/directives/drag.spec.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3217,7 +3217,7 @@ describe('CdkDrag', () => {
32173217

32183218
const cleanup = makePageScrollable();
32193219
const item = fixture.componentInstance.dragItems.first.element.nativeElement;
3220-
const viewportRuler: ViewportRuler = TestBed.get(ViewportRuler);
3220+
const viewportRuler = TestBed.inject(ViewportRuler);
32213221
const viewportSize = viewportRuler.getViewportSize();
32223222

32233223
expect(viewportRuler.getViewportScrollPosition().top).toBe(0);
@@ -3238,7 +3238,7 @@ describe('CdkDrag', () => {
32383238

32393239
const cleanup = makePageScrollable();
32403240
const item = fixture.componentInstance.dragItems.first.element.nativeElement;
3241-
const viewportRuler: ViewportRuler = TestBed.get(ViewportRuler);
3241+
const viewportRuler = TestBed.inject(ViewportRuler);
32423242
const viewportSize = viewportRuler.getViewportSize();
32433243

32443244
scrollTo(0, viewportSize.height * 5);
@@ -3261,7 +3261,7 @@ describe('CdkDrag', () => {
32613261

32623262
const cleanup = makePageScrollable('horizontal');
32633263
const item = fixture.componentInstance.dragItems.first.element.nativeElement;
3264-
const viewportRuler: ViewportRuler = TestBed.get(ViewportRuler);
3264+
const viewportRuler = TestBed.inject(ViewportRuler);
32653265
const viewportSize = viewportRuler.getViewportSize();
32663266

32673267
expect(viewportRuler.getViewportScrollPosition().left).toBe(0);
@@ -3282,7 +3282,7 @@ describe('CdkDrag', () => {
32823282

32833283
const cleanup = makePageScrollable('horizontal');
32843284
const item = fixture.componentInstance.dragItems.first.element.nativeElement;
3285-
const viewportRuler: ViewportRuler = TestBed.get(ViewportRuler);
3285+
const viewportRuler = TestBed.inject(ViewportRuler);
32863286
const viewportSize = viewportRuler.getViewportSize();
32873287

32883288
scrollTo(viewportSize.width * 5, 0);
@@ -3305,7 +3305,7 @@ describe('CdkDrag', () => {
33053305
fixture.detectChanges();
33063306

33073307
const list = fixture.componentInstance.dropInstance.element.nativeElement;
3308-
const viewportRuler: ViewportRuler = TestBed.get(ViewportRuler);
3308+
const viewportRuler = TestBed.inject(ViewportRuler);
33093309
const item = fixture.componentInstance.dragItems.first.element.nativeElement;
33103310

33113311
// Position the list so that its top aligns with the viewport top. That way the pointer
@@ -3343,7 +3343,7 @@ describe('CdkDrag', () => {
33433343
fixture.detectChanges();
33443344

33453345
const list = fixture.componentInstance.dropInstance.element.nativeElement;
3346-
const viewportRuler: ViewportRuler = TestBed.get(ViewportRuler);
3346+
const viewportRuler = TestBed.inject(ViewportRuler);
33473347
const item = fixture.componentInstance.dragItems.first.element.nativeElement;
33483348

33493349
// Position the list so that its top aligns with the viewport top. That way the pointer

0 commit comments

Comments
 (0)