/
githubmirror
/
jest
Обзор
Документация
Войти
/
githubmirror
/
jest
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
examples/angular/app.component.spec.ts
40 строк
1 KB
Simen Bekkhus
chore: update "vulnerable" dependencies (#15915)
12 дек 2025, 12:11
Не верифицирован
12 дек 2025, 12:11
61bb2eb
Код
Авторство
О чём код?
import {ComponentFixture, TestBed} from '@angular/core/testing'; import {beforeEach, 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(() => title); const dataServiceMock: Partial<DataService> = { getTitle: getTitleFn, }; describe('AppComponent', () => { let fixture: ComponentFixture<AppComponent>; let app: AppComponent; beforeEach(async () => { await TestBed.configureTestingModule({ imports: [AppComponent], providers: [{provide: DataService, useValue: dataServiceMock}], }).compileComponents(); fixture = TestBed.createComponent(AppComponent); app = fixture.debugElement.componentInstance; }); it('should create the app', () => { expect(app).toBeTruthy(); }); it("should have as title 'angular'", () => { expect(app.title).toEqual(title); }); it('should render title in a h1 tag', () => { fixture.detectChanges(); const compiled = fixture.debugElement.nativeElement; expect(compiled.querySelector('h1').textContent).toContain( `Welcome to ${title}!`, ); }); });