mirror of
https://github.com/angular/angular-cli.git
synced 2025-05-14 09:37:18 +08:00
To align with the updated style guide, Angular v20 will generate components without a `.component` file extension type for all component related files by default. Projects will automatically use this naming convention. Projects can however opt-out by setting the `type` option to `Component` for the component schematic. This can be done as a default in the `angular.json` or directly on the commandline via `--type=Component` when executing `ng generate`. As an example, `app.component.css` will now be named `app.css`. Additionally, the TypeScript class name will be `App` instead of the previous `AppComponent`.
38 lines
1.2 KiB
Plaintext
38 lines
1.2 KiB
Plaintext
<% if(experimentalZoneless) { %>import { provideExperimentalZonelessChangeDetection } from '@angular/core';
|
|
<% } %>import { TestBed } from '@angular/core/testing';<% if (routing) { %>
|
|
import { RouterModule } from '@angular/router';<% } %>
|
|
import { App } from './app';
|
|
|
|
describe('App', () => {
|
|
beforeEach(async () => {
|
|
await TestBed.configureTestingModule({<% if (routing) { %>
|
|
imports: [
|
|
RouterModule.forRoot([])
|
|
],<% } %>
|
|
declarations: [
|
|
App
|
|
],<% if(experimentalZoneless) { %>
|
|
providers: [provideExperimentalZonelessChangeDetection()]<% } %>
|
|
}).compileComponents();
|
|
});
|
|
|
|
it('should create the app', () => {
|
|
const fixture = TestBed.createComponent(App);
|
|
const app = fixture.componentInstance;
|
|
expect(app).toBeTruthy();
|
|
});
|
|
|
|
it(`should have as title '<%= name %>'`, () => {
|
|
const fixture = TestBed.createComponent(App);
|
|
const app = fixture.componentInstance;
|
|
expect(app.title).toEqual('<%= name %>');
|
|
});
|
|
|
|
it('should render title', () => {
|
|
const fixture = TestBed.createComponent(App);
|
|
fixture.detectChanges();
|
|
const compiled = fixture.nativeElement as HTMLElement;
|
|
expect(compiled.querySelector('h1')?.textContent).toContain('Hello, <%= name %>');
|
|
});
|
|
});
|