Browse Source

chore: remove the spec files.

(They will be added later)
pull/2927/head
mehmet-erim 7 years ago
parent
commit
a9b19f8f34
  1. 68
      templates/app/angular/src/app/app.component.spec.ts
  2. 51
      templates/app/angular/src/app/home/home.component.spec.ts

68
templates/app/angular/src/app/app.component.spec.ts

@ -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<AppComponent>;
let mockLazyLoadService: { load: () => Observable<void> };
let loadResponse$: Subject<void>;
let spy: jasmine.Spy<() => Observable<void>>;
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();
});
});
});

51
templates/app/angular/src/app/home/home.component.spec.ts

@ -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<HomeComponent>;
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();
});
});
});
Loading…
Cancel
Save