angular/integration/cli-elements-universal/src/app/app.component.spec.ts
Matthieu Riegler e85021a7ba build: Migrate all integration tests with the schematic. (#58160)
All components, directives and pipes will now use standalone as default. Non-standalone decorators have now .

PR Close #58160
2024-10-14 14:58:58 +00:00

44 lines
1.3 KiB
TypeScript

import {Component, Input} from '@angular/core';
import {TestBed} from '@angular/core/testing';
import {By} from '@angular/platform-browser';
import {RouterModule} from '@angular/router';
import {AppComponent} from './app.component';
describe('AppComponent', () => {
beforeEach(async () => {
TestBed.configureTestingModule({
declarations: [AppComponent, TestTitleComponent],
imports: [RouterModule.forRoot([])],
});
await TestBed.compileComponents();
});
it('should create the app', () => {
const fixture = TestBed.createComponent(AppComponent);
const appComp = fixture.componentInstance;
expect(appComp).toBeTruthy();
expect(appComp.title).toBe('cli-elements-universal');
});
it('should pass the app title to the `TitleComponent`', () => {
const fixture = TestBed.createComponent(AppComponent);
const titleDebugElement = fixture.debugElement.query(By.directive(TestTitleComponent));
const titleComp: TestTitleComponent = titleDebugElement.componentInstance;
fixture.detectChanges();
expect(titleComp).toBeTruthy();
expect(titleComp.appName).toBe('cli-elements-universal');
});
// Helpers
@Component({
selector: 'app-title-ce',
template: '',
standalone: false,
})
class TestTitleComponent {
@Input() appName = '';
}
});