app.component.spec.ts 966 B

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