Skip to content

Commit

Permalink
chore: use @jest/globals in the Angular example (#13345)
Browse files Browse the repository at this point in the history
  • Loading branch information
mrazauskas committed Sep 30, 2022
1 parent 3c31dd6 commit 2662f47
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 8 deletions.
9 changes: 5 additions & 4 deletions examples/angular/app.component.spec.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import {ComponentFixture, TestBed, async} from '@angular/core/testing';
import {ComponentFixture, TestBed, waitForAsync} from '@angular/core/testing';
import {describe, expect, it, jest} from '@jest/globals';

import {AppComponent} from './app.component';
import {DataService} from './shared/data.service';

const title = 'Test';
const getTitleFn = jest.fn().mockReturnValue(title);
const dataServiceSpy = jest.fn().mockImplementation(
const getTitleFn = jest.fn(() => title);
const dataServiceSpy = jest.fn(
(): Partial<DataService> => ({
getTitle: getTitleFn,
}),
Expand All @@ -15,7 +16,7 @@ describe('AppComponent', () => {
let fixture: ComponentFixture<AppComponent>;
let app: AppComponent;

beforeEach(async(() => {
beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
declarations: [AppComponent],
providers: [{provide: DataService, useClass: dataServiceSpy}],
Expand Down
2 changes: 1 addition & 1 deletion examples/angular/app.module.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {BrowserModule} from '@angular/platform-browser';
import {NgModule} from '@angular/core';
import {BrowserModule} from '@angular/platform-browser';

import {AppComponent} from './app.component';

Expand Down
1 change: 0 additions & 1 deletion examples/angular/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
"@babel/plugin-proposal-decorators": "*",
"@babel/preset-env": "^7.1.0",
"@babel/preset-typescript": "^7.0.0",
"@types/jest": "^27.4.0",
"babel-jest": "workspace:^",
"babel-plugin-transform-typescript-metadata": "*",
"jest": "workspace:^",
Expand Down
1 change: 1 addition & 0 deletions examples/angular/shared/data.service.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {TestBed} from '@angular/core/testing';
import {beforeEach, describe, expect, it, jest} from '@jest/globals';

import {DataService} from './data.service';
import {SubService} from './sub.service';
Expand Down
1 change: 1 addition & 0 deletions examples/angular/shared/sub.service.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {TestBed} from '@angular/core/testing';
import {beforeEach, describe, expect, it} from '@jest/globals';

import {SubService} from './sub.service';

Expand Down
2 changes: 1 addition & 1 deletion examples/angular/shared/sub.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ import {Injectable} from '@angular/core';
@Injectable()
export class SubService {
public getTitle() {
return 'Angular App with Jest24';
return 'Angular App with Jest';
}
}
7 changes: 7 additions & 0 deletions examples/angular/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"compilerOptions": {
"experimentalDecorators": true,
"strict": true
},
"include": ["./**/*"]
}
1 change: 0 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5661,7 +5661,6 @@ __metadata:
"@babel/plugin-proposal-decorators": "*"
"@babel/preset-env": ^7.1.0
"@babel/preset-typescript": ^7.0.0
"@types/jest": ^27.4.0
babel-jest: "workspace:^"
babel-plugin-transform-typescript-metadata: "*"
core-js: ^3.2.1
Expand Down

0 comments on commit 2662f47

Please sign in to comment.