Skip to content

Commit

Permalink
chore(unit-tests): improve unit-tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Helias committed Jun 13, 2020
1 parent 41f00fb commit e303574
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 68 deletions.
52 changes: 16 additions & 36 deletions opis-manager/src/app/app.component.spec.ts
Original file line number Diff line number Diff line change
@@ -1,46 +1,26 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { BrowserModule } from '@angular/platform-browser';
import { FontAwesomeModule } from '@fortawesome/angular-fontawesome';
import { KatexModule } from 'ng-katex';
import { TestBed, async } from '@angular/core/testing';
import { RouterTestingModule } from '@angular/router/testing';
import { AppComponent } from './app.component';
import { AppRoutingModule } from './app-routing.module';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { HttpClientModule } from '@angular/common/http';
import { FormsModule } from '@angular/forms';
import { ChartModule } from 'angular2-chartjs';
import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
import { Ng5SliderModule } from 'ng5-slider';

xdescribe('AppComponent', () => { // TODO
let component: AppComponent;
let fixture: ComponentFixture<AppComponent>;
import { HttpClientTestingModule } from '@angular/common/http/testing';
import { FontAwesomeModule } from '@fortawesome/angular-fontawesome';

describe('AppComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ AppComponent ],
imports: [
BrowserModule,
AppRoutingModule,
RouterTestingModule,
HttpClientTestingModule,
FontAwesomeModule,
KatexModule,
BrowserAnimationsModule,
HttpClientModule,
FormsModule,
ChartModule,
NgbModule,
Ng5SliderModule
]
})
.compileComponents();
],
declarations: [
AppComponent
],
}).compileComponents();
}));

beforeEach(() => {
fixture = TestBed.createComponent(AppComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
it('onInit should work correctly', () => {
const fixture = TestBed.createComponent(AppComponent);
const app = fixture.debugElement.componentInstance;
expect(app).toBeTruthy();
});
});
12 changes: 3 additions & 9 deletions opis-manager/src/app/formula/formula.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ import { FormulaComponent } from './formula.component';
import { KatexModule } from 'ng-katex';

describe('FormulaComponent', () => {
let component: FormulaComponent;
let fixture: ComponentFixture<FormulaComponent>;

beforeEach(async(() => {
TestBed.configureTestingModule({
Expand All @@ -20,13 +18,9 @@ describe('FormulaComponent', () => {
.compileComponents();
}));

beforeEach(() => {
fixture = TestBed.createComponent(FormulaComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
const fixture = TestBed.createComponent(FormulaComponent);
const app = fixture.debugElement.componentInstance;
expect(app).toBeTruthy();
});
});
38 changes: 25 additions & 13 deletions opis-manager/src/app/home/home.component.spec.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,35 @@
import { HttpClientModule } from '@angular/common/http';
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { Component, Input, Output, EventEmitter } from '@angular/core';
import { async, TestBed } from '@angular/core/testing';
import { FormsModule } from '@angular/forms';
import { BrowserModule } from '@angular/platform-browser';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { FontAwesomeModule } from '@fortawesome/angular-fontawesome';
import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
import { ChartModule } from 'angular2-chartjs';
import { Ng5SliderModule } from 'ng5-slider';
import { ConfigService } from '../config.service';
import { HomeComponent } from './home.component';

/* Mock NgSliderComponent */
// tslint:disable-next-line: component-selector
@Component({selector: 'ng5-slider', template: ''})
class NgSliderStubComponent {
@Input() value;
@Input() highValue;
@Input() options;
// hidden
@Input() manualRefresh;
@Output() valueChange = new EventEmitter<any>();
}

describe('HomeComponent', () => {
let component: HomeComponent;
let fixture: ComponentFixture<HomeComponent>;

beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ HomeComponent ],
declarations: [
NgSliderStubComponent,
HomeComponent,
],
imports: [
BrowserModule,
FontAwesomeModule,
Expand All @@ -24,19 +38,17 @@ describe('HomeComponent', () => {
FormsModule,
ChartModule,
NgbModule,
Ng5SliderModule
],
providers: [
ConfigService,
]
})
.compileComponents();
}));

beforeEach(() => {
fixture = TestBed.createComponent(HomeComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
const fixture = TestBed.createComponent(HomeComponent);
const app = fixture.debugElement.componentInstance;
expect(app).toBeTruthy();
});
});
13 changes: 3 additions & 10 deletions opis-manager/src/app/info/info.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ import { FontAwesomeModule } from '@fortawesome/angular-fontawesome';
import { InfoComponent } from './info.component';

describe('InfoComponent', () => {
let component: InfoComponent;
let fixture: ComponentFixture<InfoComponent>;

beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ InfoComponent ],
Expand All @@ -18,13 +15,9 @@ describe('InfoComponent', () => {
.compileComponents();
}));

beforeEach(() => {
fixture = TestBed.createComponent(InfoComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
const fixture = TestBed.createComponent(InfoComponent);
const app = fixture.debugElement.componentInstance;
expect(app).toBeTruthy();
});
});

0 comments on commit e303574

Please sign in to comment.