Skip to content

Commit 0c5b6e9

Browse files
crisbetojosephperrott
authored andcommitted
chore: clean up internal usages of deprecated signatures (#13638)
1 parent b6fbe65 commit 0c5b6e9

File tree

9 files changed

+30
-33
lines changed

9 files changed

+30
-33
lines changed

src/cdk/accordion/accordion-item.spec.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ describe('CdkAccordionItem', () => {
2828
fixture = TestBed.createComponent(SingleItem);
2929
item = fixture.debugElement
3030
.query(By.directive(CdkAccordionItem))
31-
.injector.get(CdkAccordionItem);
31+
.injector.get<CdkAccordionItem>(CdkAccordionItem);
3232
});
3333

3434
describe('that is not disabled', () => {
@@ -182,9 +182,7 @@ describe('CdkAccordionItem', () => {
182182
fixture = TestBed.createComponent(ItemGroupWithoutAccordion);
183183
[firstItem, secondItem] = fixture.debugElement
184184
.queryAll(By.directive(CdkAccordionItem))
185-
.map(el => {
186-
return el.injector.get(CdkAccordionItem) as CdkAccordionItem;
187-
});
185+
.map(el => el.injector.get<CdkAccordionItem>(CdkAccordionItem));
188186
});
189187

190188
it('should not change expanded state based on unrelated items', () => {
@@ -225,9 +223,7 @@ describe('CdkAccordionItem', () => {
225223
fixture = TestBed.createComponent(ItemGroupWithAccordion);
226224
[firstItem, secondItem] = fixture.debugElement
227225
.queryAll(By.directive(CdkAccordionItem))
228-
.map(el => {
229-
return el.injector.get(CdkAccordionItem) as CdkAccordionItem;
230-
});
226+
.map(el => el.injector.get<CdkAccordionItem>(CdkAccordionItem));
231227
});
232228

233229
it('should change expanded state based on related items', () => {

src/cdk/accordion/accordion.spec.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,7 @@ describe('CdkAccordion', () => {
2323
const fixture = TestBed.createComponent(SetOfItems);
2424
const [firstPanel, secondPanel] = fixture.debugElement
2525
.queryAll(By.directive(CdkAccordionItem))
26-
.map(el => {
27-
return el.injector.get(CdkAccordionItem) as CdkAccordionItem;
28-
});
26+
.map(el => el.injector.get<CdkAccordionItem>(CdkAccordionItem));
2927

3028
firstPanel.open();
3129
fixture.detectChanges();
@@ -42,9 +40,7 @@ describe('CdkAccordion', () => {
4240
const fixture = TestBed.createComponent(SetOfItems);
4341
const [firstPanel, secondPanel] = fixture.debugElement
4442
.queryAll(By.directive(CdkAccordionItem))
45-
.map(el => {
46-
return el.injector.get(CdkAccordionItem) as CdkAccordionItem;
47-
});
43+
.map(el => el.injector.get<CdkAccordionItem>(CdkAccordionItem));
4844

4945
fixture.componentInstance.multi = true;
5046
fixture.detectChanges();

src/cdk/collections/selection.spec.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,28 +41,28 @@ describe('SelectionModel', () => {
4141
beforeEach(() => model = new SelectionModel(true));
4242

4343
it('should be able to select multiple options', () => {
44-
const onChangeSpy = jasmine.createSpy('onChange spy');
44+
const changedSpy = jasmine.createSpy('changed spy');
4545

46-
model.changed.subscribe(onChangeSpy);
46+
model.changed.subscribe(changedSpy);
4747
model.select(1);
4848
model.select(2);
4949

5050
expect(model.selected.length).toBe(2);
5151
expect(model.isSelected(1)).toBe(true);
5252
expect(model.isSelected(2)).toBe(true);
53-
expect(onChangeSpy).toHaveBeenCalledTimes(2);
53+
expect(changedSpy).toHaveBeenCalledTimes(2);
5454
});
5555

5656
it('should be able to select multiple options at the same time', () => {
57-
const onChangeSpy = jasmine.createSpy('onChange spy');
57+
const changedSpy = jasmine.createSpy('changed spy');
5858

59-
model.changed.subscribe(onChangeSpy);
59+
model.changed.subscribe(changedSpy);
6060
model.select(1, 2);
6161

6262
expect(model.selected.length).toBe(2);
6363
expect(model.isSelected(1)).toBe(true);
6464
expect(model.isSelected(2)).toBe(true);
65-
expect(onChangeSpy).toHaveBeenCalledTimes(1);
65+
expect(changedSpy).toHaveBeenCalledTimes(1);
6666
});
6767

6868
it('should be able to preselect multiple options', () => {
@@ -92,12 +92,12 @@ describe('SelectionModel', () => {
9292
});
9393
});
9494

95-
describe('onChange event', () => {
95+
describe('changed event', () => {
9696
it('should return the model that dispatched the event', () => {
9797
let model = new SelectionModel();
9898
let spy = jasmine.createSpy('SelectionModel change event');
9999

100-
model.onChange.subscribe(spy);
100+
model.changed.subscribe(spy);
101101
model.select(1);
102102

103103
let event = spy.calls.mostRecent().args[0];
@@ -130,7 +130,7 @@ describe('SelectionModel', () => {
130130
// Note: this assertion is only here to run the getter.
131131
expect(model.selected).toEqual([]);
132132

133-
model.onChange.subscribe(() => spy(model.selected));
133+
model.changed.subscribe(() => spy(model.selected));
134134
model.select(1);
135135

136136
expect(spy).toHaveBeenCalledWith([1]);

src/cdk/text-field/autosize.spec.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,8 @@ describe('CdkTextareaAutosize', () => {
157157
// detection should be triggered after a multiline content is set.
158158
fixture = TestBed.createComponent(AutosizeTextAreaWithContent);
159159
textarea = fixture.nativeElement.querySelector('textarea');
160-
autosize = fixture.debugElement.query(By.css('textarea')).injector.get(CdkTextareaAutosize);
160+
autosize = fixture.debugElement.query(By.css('textarea'))
161+
.injector.get<CdkTextareaAutosize>(CdkTextareaAutosize);
161162

162163
fixture.componentInstance.content = `
163164
Line
@@ -223,7 +224,7 @@ describe('CdkTextareaAutosize', () => {
223224
const fixtureWithoutAutosize = TestBed.createComponent(AutosizeTextareaWithoutAutosize);
224225
textarea = fixtureWithoutAutosize.nativeElement.querySelector('textarea');
225226
autosize = fixtureWithoutAutosize.debugElement.query(By.css('textarea'))
226-
.injector.get(CdkTextareaAutosize);
227+
.injector.get<CdkTextareaAutosize>(CdkTextareaAutosize);
227228

228229
fixtureWithoutAutosize.detectChanges();
229230

src/lib/chips/chip-input.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ describe('MatChipInput', () => {
4141
fixture.detectChanges();
4242

4343
inputDebugElement = fixture.debugElement.query(By.directive(MatChipInput));
44-
chipInputDirective = inputDebugElement.injector.get(MatChipInput) as MatChipInput;
44+
chipInputDirective = inputDebugElement.injector.get<MatChipInput>(MatChipInput);
4545
inputNativeElement = inputDebugElement.nativeElement;
4646
}));
4747

@@ -172,7 +172,7 @@ describe('MatChipInput', () => {
172172
fixture.detectChanges();
173173

174174
inputDebugElement = fixture.debugElement.query(By.directive(MatChipInput));
175-
chipInputDirective = inputDebugElement.injector.get(MatChipInput) as MatChipInput;
175+
chipInputDirective = inputDebugElement.injector.get<MatChipInput>(MatChipInput);
176176
inputNativeElement = inputDebugElement.nativeElement;
177177

178178
spyOn(testChipInput, 'add');

src/lib/chips/chip.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ describe('Chips', () => {
3535

3636
chipDebugElement = fixture.debugElement.query(By.directive(MatChip));
3737
chipNativeElement = chipDebugElement.nativeElement;
38-
chipInstance = chipDebugElement.injector.get(MatChip);
38+
chipInstance = chipDebugElement.injector.get<MatChip>(MatChip);
3939

4040
document.body.appendChild(chipNativeElement);
4141
});
@@ -59,7 +59,7 @@ describe('Chips', () => {
5959

6060
chipDebugElement = fixture.debugElement.query(By.directive(MatChip));
6161
chipNativeElement = chipDebugElement.nativeElement;
62-
chipInstance = chipDebugElement.injector.get(MatChip);
62+
chipInstance = chipDebugElement.injector.get<MatChip>(MatChip);
6363
testComponent = fixture.debugElement.componentInstance;
6464

6565
document.body.appendChild(chipNativeElement);

src/lib/input/input.spec.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -773,7 +773,8 @@ describe('MatInput without forms', () => {
773773
const fixture = createComponent(MatInputTextTestController);
774774
fixture.detectChanges();
775775

776-
const input = fixture.debugElement.query(By.directive(MatInput)).injector.get(MatInput);
776+
const input = fixture.debugElement.query(By.directive(MatInput))
777+
.injector.get<MatInput>(MatInput);
777778
const container = fixture.debugElement.query(By.css('mat-form-field')).nativeElement;
778779

779780
// Call the focus handler directly to avoid flakyness where

src/lib/tabs/tab-nav-bar/tab-nav-bar.spec.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ describe('MatTabNavBar', () => {
174174
it('should be able to disable ripples on a tab link', () => {
175175
const tabLinkDebug = fixture.debugElement.query(By.css('a'));
176176
const tabLinkElement = tabLinkDebug.nativeElement;
177-
const tabLinkInstance = tabLinkDebug.injector.get(MatTabLink);
177+
const tabLinkInstance = tabLinkDebug.injector.get<MatTabLink>(MatTabLink);
178178

179179
tabLinkInstance.disableRipple = true;
180180

@@ -264,7 +264,8 @@ describe('MatTabNavBar', () => {
264264
const fixture = TestBed.createComponent(TabLinkWithNativeTabindexAttr);
265265
fixture.detectChanges();
266266

267-
const tabLink = fixture.debugElement.query(By.directive(MatTabLink)).injector.get(MatTabLink);
267+
const tabLink = fixture.debugElement.query(By.directive(MatTabLink))
268+
.injector.get<MatTabLink>(MatTabLink);
268269

269270
expect(tabLink.tabIndex)
270271
.toBe(5, 'Expected the tabIndex to be set from the native tabindex attribute.');
@@ -274,7 +275,8 @@ describe('MatTabNavBar', () => {
274275
const fixture = TestBed.createComponent(TabLinkWithTabIndexBinding);
275276
fixture.detectChanges();
276277

277-
const tabLink = fixture.debugElement.query(By.directive(MatTabLink)).injector.get(MatTabLink);
278+
const tabLink = fixture.debugElement.query(By.directive(MatTabLink))
279+
.injector.get<MatTabLink>(MatTabLink);
278280

279281
expect(tabLink.tabIndex).toBe(0, 'Expected the tabIndex to be set to 0 by default.');
280282

src/lib/tooltip/tooltip.spec.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,8 @@ describe('MatTooltip', () => {
184184

185185
fixture = TestBed.createComponent(BasicTooltipDemo);
186186
fixture.detectChanges();
187-
tooltipDirective = fixture.debugElement.query(By.css('button')).injector.get(MatTooltip);
187+
tooltipDirective = fixture.debugElement.query(By.css('button'))
188+
.injector.get<MatTooltip>(MatTooltip);
188189

189190
tooltipDirective.show();
190191
fixture.detectChanges();

0 commit comments

Comments
 (0)