app.component.spec.ts 922 B

1234567891011121314151617181920212223242526272829
  1. import { TestBed } from '@angular/core/testing';
  2. import { AppComponent } from './app.component';
  3. describe('AppComponent', () => {
  4. beforeEach(async () => {
  5. await TestBed.configureTestingModule({
  6. imports: [AppComponent],
  7. }).compileComponents();
  8. });
  9. it('should create the app', () => {
  10. const fixture = TestBed.createComponent(AppComponent);
  11. const app = fixture.componentInstance;
  12. expect(app).toBeTruthy();
  13. });
  14. it(`should have the 'textbook' title`, () => {
  15. const fixture = TestBed.createComponent(AppComponent);
  16. const app = fixture.componentInstance;
  17. expect(app.title).toEqual('textbook');
  18. });
  19. it('should render title', () => {
  20. const fixture = TestBed.createComponent(AppComponent);
  21. fixture.detectChanges();
  22. const compiled = fixture.nativeElement as HTMLElement;
  23. expect(compiled.querySelector('h1')?.textContent).toContain('Hello, textbook');
  24. });
  25. });