app.component.spec.ts 947 B

123456789101112131415161718192021222324252627282930
  1. import { TestBed } from '@angular/core/testing';
  2. import { provideRouter } from '@angular/router';
  3. import { AppComponent } from './app.component';
  4. import { APP_NAME } from './core/app.constants';
  5. describe('AppComponent', () => {
  6. beforeEach(async () => {
  7. await TestBed.configureTestingModule({
  8. imports: [AppComponent],
  9. providers: [provideRouter([])],
  10. }).compileComponents();
  11. });
  12. it('should create the app', () => {
  13. const fixture = TestBed.createComponent(AppComponent);
  14. const app = fixture.componentInstance;
  15. expect(app).toBeTruthy();
  16. });
  17. it('should render the router outlet', () => {
  18. const fixture = TestBed.createComponent(AppComponent);
  19. fixture.detectChanges();
  20. const compiled = fixture.nativeElement as HTMLElement;
  21. expect(compiled.querySelector('router-outlet')).not.toBeNull();
  22. });
  23. it('uses the final product name', () => {
  24. expect(APP_NAME).toBe('小树陪练');
  25. });
  26. });