Skip to content

Commit b3d8ab7

Browse files
committed
fix: use testbed.inject instead of testbed.get
2 parents 2c60547 + d15eb1e commit b3d8ab7

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

projects/jest-utils/tests/create-mock.spec.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ it('provides a mock service', async () => {
3535
const { click, getByText } = await render(FixtureComponent, {
3636
providers: [provideMock(FixtureService)],
3737
});
38-
const service = TestBed.get<FixtureService>(FixtureService);
38+
const service = TestBed.inject(FixtureService);
3939

4040
click(getByText('Print'));
4141
expect(service.print).toHaveBeenCalledTimes(1);
@@ -46,7 +46,7 @@ it('is possible to write a mock implementation', async done => {
4646
providers: [provideMock(FixtureService)],
4747
});
4848

49-
const service = TestBed.get<FixtureService>(FixtureService) as Mock<FixtureService>;
49+
const service = TestBed.inject(FixtureService) as Mock<FixtureService>;
5050
service.print.mockImplementation(() => done());
5151

5252
click(getByText('Print'));

projects/testing-library/tests/render.spec.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ describe('excludeComponentDeclaration', () => {
5656
describe('animationModule', () => {
5757
test('adds NoopAnimationsModule by default', async () => {
5858
await render(FixtureComponent);
59-
const noopAnimationsModule = TestBed.get<NoopAnimationsModule>(NoopAnimationsModule);
59+
const noopAnimationsModule = TestBed.inject(NoopAnimationsModule);
6060
expect(noopAnimationsModule).toBeDefined();
6161
});
6262

@@ -65,9 +65,9 @@ describe('animationModule', () => {
6565
imports: [BrowserAnimationsModule],
6666
});
6767

68-
const browserAnimationsModule = TestBed.get<BrowserAnimationsModule>(BrowserAnimationsModule);
68+
const browserAnimationsModule = TestBed.inject(BrowserAnimationsModule);
6969
expect(browserAnimationsModule).toBeDefined();
7070

71-
expect(() => TestBed.get<NoopAnimationsModule>(NoopAnimationsModule)).toThrow();
71+
expect(() => TestBed.inject(NoopAnimationsModule)).toThrow();
7272
});
7373
});

0 commit comments

Comments
 (0)