mirror of
https://github.com/angular/angular
synced 2026-05-24 09:28:37 +00:00
All components, directives and pipes will now use standalone as default. Non-standalone decorators have now . PR Close #58160
44 lines
1.3 KiB
TypeScript
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 = '';
|
|
}
|
|
});
|