Skip to content

Commit b1852a8

Browse files
Update app.component.spec.ts to match standalone component
1 parent 4d2e74b commit b1852a8

1 file changed

Lines changed: 17 additions & 8 deletions

File tree

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
11
import { TestBed } from '@angular/core/testing';
2-
import { RouterTestingModule } from '@angular/router/testing';
32
import { AppComponent } from './app.component';
43

54
describe('AppComponent', () => {
65
beforeEach(async () => {
76
await TestBed.configureTestingModule({
87
imports: [
9-
RouterTestingModule,
10-
],
11-
declarations: [
128
AppComponent,
139
],
1410
}).compileComponents();
@@ -20,16 +16,29 @@ describe('AppComponent', () => {
2016
expect(app).toBeTruthy();
2117
});
2218

23-
it('should have as title \'angular-test\'', () => {
19+
it('should have as title \'Angular\'', () => {
2420
const fixture = TestBed.createComponent(AppComponent);
2521
const app = fixture.componentInstance;
26-
expect(app.title).toEqual('angular-test');
22+
expect(app.title).toEqual('Angular');
2723
});
2824

29-
it('should render title', () => {
25+
it('should render the dx-button', () => {
3026
const fixture = TestBed.createComponent(AppComponent);
3127
fixture.detectChanges();
3228
const compiled = fixture.nativeElement as HTMLElement;
33-
expect(compiled.querySelector('.content span')?.textContent).toContain('angular-test app is running!');
29+
expect(compiled.querySelector('dx-button')).toBeTruthy();
30+
});
31+
32+
it('should increment the counter and update the button text on click', () => {
33+
const fixture = TestBed.createComponent(AppComponent);
34+
const app = fixture.componentInstance;
35+
36+
expect(app.counter).toEqual(0);
37+
expect(app.buttonText).toEqual('Click count: 0');
38+
39+
app.onClick({} as never);
40+
41+
expect(app.counter).toEqual(1);
42+
expect(app.buttonText).toEqual('Click count: 1');
3443
});
3544
});

0 commit comments

Comments
 (0)