diff --git a/templates/app/angular/src/app/app.component.spec.ts b/templates/app/angular/src/app/app.component.spec.ts deleted file mode 100644 index 375c0b83f0..0000000000 --- a/templates/app/angular/src/app/app.component.spec.ts +++ /dev/null @@ -1,68 +0,0 @@ -import { LazyLoadService } from '@abp/ng.core'; -import { ComponentFixture, TestBed } from '@angular/core/testing'; -import { RouterTestingModule } from '@angular/router/testing'; -import { NgxsModule } from '@ngxs/store'; -import { OAuthService } from 'angular-oauth2-oidc'; -import { AppComponent } from './app.component'; -import { LoaderBarComponent } from '@abp/ng.theme.shared'; -import { Subject, Observable } from 'rxjs'; -import { Component } from '@angular/core'; -import { By } from '@angular/platform-browser'; - -@Component({ - template: '', - selector: 'abp-loader-bar', -}) -class DummyLoaderBarComponent {} - -describe('AppComponent', () => { - let component: AppComponent; - let fixture: ComponentFixture; - let mockLazyLoadService: { load: () => Observable }; - let loadResponse$: Subject; - let spy: jasmine.Spy<() => Observable>; - - beforeEach(() => { - TestBed.configureTestingModule({ - imports: [RouterTestingModule], - declarations: [AppComponent, DummyLoaderBarComponent], - providers: [{ provide: LazyLoadService, useValue: { load: () => loadResponse$ } }], - }); - loadResponse$ = new Subject(); - fixture = TestBed.createComponent(AppComponent); - component = fixture.componentInstance; - mockLazyLoadService = TestBed.get(LazyLoadService); - spy = spyOn(mockLazyLoadService, 'load'); - spy.and.returnValue(loadResponse$); - fixture.detectChanges(); - }); - - describe('LazyLoadService load method', () => { - it('should call', () => { - expect(spy).toHaveBeenCalledWith( - [ - 'primeng.min.css', - 'primeicons.css', - 'primeng-nova-light-theme.css', - 'fontawesome-all.min.css', - 'fontawesome-v4-shims.min.css', - ], - 'style', - null, - 'head', - ); - }); - }); - - describe('template', () => { - it('should have the abp-loader-bar', () => { - const abpLoader = fixture.debugElement.query(By.css('abp-loader-bar')); - expect(abpLoader).toBeTruthy(); - }); - - it('should have router-outlet', () => { - const abpLoader = fixture.debugElement.query(By.css('router-outlet')); - expect(abpLoader).toBeTruthy(); - }); - }); -}); diff --git a/templates/app/angular/src/app/home/home.component.spec.ts b/templates/app/angular/src/app/home/home.component.spec.ts deleted file mode 100644 index b52901d692..0000000000 --- a/templates/app/angular/src/app/home/home.component.spec.ts +++ /dev/null @@ -1,51 +0,0 @@ -import { ComponentFixture, TestBed } from '@angular/core/testing'; -import { OAuthService } from 'angular-oauth2-oidc'; -import { HomeComponent } from './home.component'; -import { HomeModule } from './home.module'; -import { RouterTestingModule } from '@angular/router/testing'; -import { NgxsModule } from '@ngxs/store'; -import { By } from '@angular/platform-browser'; - -describe('HomeComponent', () => { - let component: HomeComponent; - let fixture: ComponentFixture; - let mockOAuthService: { hasValidAccessToken: () => boolean }; - - beforeEach(() => { - TestBed.configureTestingModule({ - imports: [ NgxsModule.forRoot(), HomeModule, RouterTestingModule], - providers: [{ provide: OAuthService, useValue: { hasValidAccessToken: () => false } }], - }); - fixture = TestBed.createComponent(HomeComponent); - component = fixture.componentInstance; - mockOAuthService = TestBed.get(OAuthService); - fixture.detectChanges(); - }); - - describe('#hasLoggedIn', () => { - it('should return the hasValidAccessToken method of oAuthService', () => { - const spy = spyOn(mockOAuthService, 'hasValidAccessToken'); - spy.and.returnValue(false); - - expect(component.hasLoggedIn).toBe(false); - expect(spy).toHaveBeenCalled(); - }); - }); - - describe('login button', () => { - it('should display', () => { - const button = fixture.debugElement.query(By.css('[routerLink="/account/login"]')); - expect(button).toBeTruthy(); - expect(button.nativeElement.textContent).toContain('AbpAccount::Login'); - }); - - it('should not display when user logged in', () => { - const spy = spyOn(mockOAuthService, 'hasValidAccessToken'); - spy.and.returnValue(true); - fixture.detectChanges(); - - const button = fixture.debugElement.query(By.css('#login-button')); - expect(button).toBeFalsy(); - }); - }); -});