Add some unittests. npm i && ng test to run
This commit is contained in:
parent
8dcc3a1f45
commit
561dadd2c5
@ -1,15 +1,20 @@
|
|||||||
// Karma configuration file, see link for more information
|
// Karma configuration file, see link for more information
|
||||||
// https://karma-runner.github.io/1.0/config/configuration-file.html
|
// https://karma-runner.github.io/1.0/config/configuration-file.html
|
||||||
|
|
||||||
|
const process = require('process');
|
||||||
|
process.env.CHROME_BIN = require('puppeteer').executablePath();
|
||||||
|
|
||||||
module.exports = function (config) {
|
module.exports = function (config) {
|
||||||
config.set({
|
config.set({
|
||||||
basePath: '',
|
basePath: '',
|
||||||
|
files: ['src/assets/env.js'],
|
||||||
frameworks: ['jasmine', '@angular-devkit/build-angular'],
|
frameworks: ['jasmine', '@angular-devkit/build-angular'],
|
||||||
plugins: [
|
plugins: [
|
||||||
require('karma-jasmine'),
|
require('karma-jasmine'),
|
||||||
require('karma-chrome-launcher'),
|
require('karma-chrome-launcher'),
|
||||||
require('karma-jasmine-html-reporter'),
|
require('karma-jasmine-html-reporter'),
|
||||||
require('karma-coverage-istanbul-reporter'),
|
require('karma-coverage-istanbul-reporter'),
|
||||||
|
require('karma-spec-reporter'),
|
||||||
require('@angular-devkit/build-angular/plugins/karma')
|
require('@angular-devkit/build-angular/plugins/karma')
|
||||||
],
|
],
|
||||||
client: {
|
client: {
|
||||||
@ -20,13 +25,12 @@ module.exports = function (config) {
|
|||||||
reports: ['html', 'lcovonly', 'text-summary'],
|
reports: ['html', 'lcovonly', 'text-summary'],
|
||||||
fixWebpackSourcePaths: true
|
fixWebpackSourcePaths: true
|
||||||
},
|
},
|
||||||
reporters: ['progress', 'kjhtml'],
|
reporters: ['progress', 'kjhtml', 'spec'],
|
||||||
port: 9876,
|
port: 9876,
|
||||||
colors: true,
|
colors: true,
|
||||||
logLevel: config.LOG_INFO,
|
logLevel: config.LOG_INFO,
|
||||||
autoWatch: true,
|
autoWatch: true,
|
||||||
browsers: ['Chrome'],
|
browsers: ['ChromeHeadless'],
|
||||||
singleRun: false,
|
singleRun: true
|
||||||
restartOnFileChange: true
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
@ -32,9 +32,9 @@
|
|||||||
"@angular-devkit/build-angular": "~0.901.7",
|
"@angular-devkit/build-angular": "~0.901.7",
|
||||||
"@angular/cli": "~9.1.7",
|
"@angular/cli": "~9.1.7",
|
||||||
"@angular/compiler-cli": "~9.1.9",
|
"@angular/compiler-cli": "~9.1.9",
|
||||||
"@types/node": "^12.11.1",
|
|
||||||
"@types/jasmine": "~3.5.0",
|
"@types/jasmine": "~3.5.0",
|
||||||
"@types/jasminewd2": "~2.0.3",
|
"@types/jasminewd2": "~2.0.3",
|
||||||
|
"@types/node": "^12.11.1",
|
||||||
"codelyzer": "^5.1.2",
|
"codelyzer": "^5.1.2",
|
||||||
"jasmine-core": "~3.5.0",
|
"jasmine-core": "~3.5.0",
|
||||||
"jasmine-spec-reporter": "~4.2.1",
|
"jasmine-spec-reporter": "~4.2.1",
|
||||||
@ -43,7 +43,9 @@
|
|||||||
"karma-coverage-istanbul-reporter": "~2.1.0",
|
"karma-coverage-istanbul-reporter": "~2.1.0",
|
||||||
"karma-jasmine": "~3.0.1",
|
"karma-jasmine": "~3.0.1",
|
||||||
"karma-jasmine-html-reporter": "^1.4.2",
|
"karma-jasmine-html-reporter": "^1.4.2",
|
||||||
|
"karma-spec-reporter": "0.0.32",
|
||||||
"protractor": "~7.0.0",
|
"protractor": "~7.0.0",
|
||||||
|
"puppeteer": "^5.1.0",
|
||||||
"ts-node": "~8.3.0",
|
"ts-node": "~8.3.0",
|
||||||
"tslint": "~6.1.0",
|
"tslint": "~6.1.0",
|
||||||
"typescript": "~3.8.3"
|
"typescript": "~3.8.3"
|
||||||
|
@ -6,10 +6,10 @@ describe('AppComponent', () => {
|
|||||||
beforeEach(async(() => {
|
beforeEach(async(() => {
|
||||||
TestBed.configureTestingModule({
|
TestBed.configureTestingModule({
|
||||||
imports: [
|
imports: [
|
||||||
RouterTestingModule
|
RouterTestingModule,
|
||||||
],
|
],
|
||||||
declarations: [
|
declarations: [
|
||||||
AppComponent
|
AppComponent,
|
||||||
],
|
],
|
||||||
}).compileComponents();
|
}).compileComponents();
|
||||||
}));
|
}));
|
||||||
@ -20,16 +20,10 @@ describe('AppComponent', () => {
|
|||||||
expect(app).toBeTruthy();
|
expect(app).toBeTruthy();
|
||||||
});
|
});
|
||||||
|
|
||||||
it(`should have as title 'frontend'`, () => {
|
it('should render router-outlet', () => {
|
||||||
const fixture = TestBed.createComponent(AppComponent);
|
|
||||||
const app = fixture.debugElement.componentInstance;
|
|
||||||
expect(app.title).toEqual('frontend');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should render title', () => {
|
|
||||||
const fixture = TestBed.createComponent(AppComponent);
|
const fixture = TestBed.createComponent(AppComponent);
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
const compiled = fixture.debugElement.nativeElement;
|
const compiled = fixture.debugElement.nativeElement;
|
||||||
expect(compiled.querySelector('.content span').textContent).toContain('frontend app is running!');
|
expect(compiled.querySelector('router-outlet').textContent).toBeDefined();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
28
src/app/components/backlog/backlog.component.spec.ts
Normal file
28
src/app/components/backlog/backlog.component.spec.ts
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
import { TestBed, async } from '@angular/core/testing';
|
||||||
|
import { RouterTestingModule } from '@angular/router/testing';
|
||||||
|
import { BacklogComponent } from './backlog.component';
|
||||||
|
import { BackendService } from '../../services/backend.service';
|
||||||
|
import { HttpClientModule } from '@angular/common/http';
|
||||||
|
|
||||||
|
describe('BacklogComponent', () => {
|
||||||
|
beforeEach(async(() => {
|
||||||
|
TestBed.configureTestingModule({
|
||||||
|
imports: [
|
||||||
|
RouterTestingModule,
|
||||||
|
HttpClientModule,
|
||||||
|
],
|
||||||
|
declarations: [
|
||||||
|
BacklogComponent,
|
||||||
|
],
|
||||||
|
providers: [
|
||||||
|
BackendService,
|
||||||
|
]
|
||||||
|
}).compileComponents();
|
||||||
|
}));
|
||||||
|
|
||||||
|
it('should create the component', () => {
|
||||||
|
const fixture = TestBed.createComponent(BacklogComponent);
|
||||||
|
const app = fixture.debugElement.componentInstance;
|
||||||
|
expect(app).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
35
src/app/components/dashboard/dashboard.component.spec.ts
Normal file
35
src/app/components/dashboard/dashboard.component.spec.ts
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
import { TestBed, async } from '@angular/core/testing';
|
||||||
|
import { RouterTestingModule } from '@angular/router/testing';
|
||||||
|
import { BackendService } from '../../services/backend.service';
|
||||||
|
import { HttpClientModule } from '@angular/common/http';
|
||||||
|
import { DashboardComponent } from './dashboard.component';
|
||||||
|
|
||||||
|
describe('DashboardComponent', () => {
|
||||||
|
beforeEach(async(() => {
|
||||||
|
TestBed.configureTestingModule({
|
||||||
|
imports: [
|
||||||
|
RouterTestingModule,
|
||||||
|
HttpClientModule,
|
||||||
|
],
|
||||||
|
declarations: [
|
||||||
|
DashboardComponent,
|
||||||
|
],
|
||||||
|
providers: [
|
||||||
|
BackendService,
|
||||||
|
]
|
||||||
|
}).compileComponents();
|
||||||
|
}));
|
||||||
|
|
||||||
|
it('should create the component', () => {
|
||||||
|
const fixture = TestBed.createComponent(DashboardComponent);
|
||||||
|
const app = fixture.debugElement.componentInstance;
|
||||||
|
expect(app).toBeTruthy();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should parse dates correctly', () => {
|
||||||
|
const fixture = TestBed.createComponent(DashboardComponent);
|
||||||
|
const app = fixture.componentInstance;
|
||||||
|
expect(app.toDateString('2020-07-01T14:30:20')).toEqual('1.7.2020');
|
||||||
|
expect(app.toDateString('2020-11-23T07:30:20')).toEqual('23.11.2020');
|
||||||
|
});
|
||||||
|
});
|
36
src/app/components/sprint-form/sprint-form.component.spec.ts
Normal file
36
src/app/components/sprint-form/sprint-form.component.spec.ts
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
|
|
||||||
|
import { HttpClientModule } from '@angular/common/http';
|
||||||
|
import { BackendService } from '../../services/backend.service';
|
||||||
|
import { NgbActiveModal, NgbModule } from '@ng-bootstrap/ng-bootstrap';
|
||||||
|
import { SprintFormComponent } from './sprint-form.component';
|
||||||
|
|
||||||
|
describe('SprintFormComponent', () => {
|
||||||
|
let component: SprintFormComponent;
|
||||||
|
let fixture: ComponentFixture<SprintFormComponent>;
|
||||||
|
|
||||||
|
beforeEach(async(() => {
|
||||||
|
TestBed.configureTestingModule({
|
||||||
|
imports: [
|
||||||
|
HttpClientModule,
|
||||||
|
NgbModule,
|
||||||
|
],
|
||||||
|
declarations: [ SprintFormComponent ],
|
||||||
|
providers: [
|
||||||
|
BackendService,
|
||||||
|
NgbActiveModal,
|
||||||
|
]
|
||||||
|
})
|
||||||
|
.compileComponents();
|
||||||
|
}));
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
fixture = TestBed.createComponent(SprintFormComponent);
|
||||||
|
component = fixture.componentInstance;
|
||||||
|
fixture.detectChanges();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should create the component', () => {
|
||||||
|
expect(component).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
@ -0,0 +1,28 @@
|
|||||||
|
import { TestBed, async } from '@angular/core/testing';
|
||||||
|
import { RouterTestingModule } from '@angular/router/testing';
|
||||||
|
import { BackendService } from '../../services/backend.service';
|
||||||
|
import { HttpClientModule } from '@angular/common/http';
|
||||||
|
import { SprintTableComponent } from './sprint-table.component';
|
||||||
|
|
||||||
|
describe('SprintTableComponent', () => {
|
||||||
|
beforeEach(async(() => {
|
||||||
|
TestBed.configureTestingModule({
|
||||||
|
imports: [
|
||||||
|
RouterTestingModule,
|
||||||
|
HttpClientModule,
|
||||||
|
],
|
||||||
|
declarations: [
|
||||||
|
SprintTableComponent,
|
||||||
|
],
|
||||||
|
providers: [
|
||||||
|
BackendService,
|
||||||
|
]
|
||||||
|
}).compileComponents();
|
||||||
|
}));
|
||||||
|
|
||||||
|
it('should create the component', () => {
|
||||||
|
const fixture = TestBed.createComponent(SprintTableComponent);
|
||||||
|
const app = fixture.debugElement.componentInstance;
|
||||||
|
expect(app).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
@ -1,6 +1,9 @@
|
|||||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
|
|
||||||
import { TaskFormComponent } from './task-form.component';
|
import { TaskFormComponent } from './task-form.component';
|
||||||
|
import { HttpClientModule } from '@angular/common/http';
|
||||||
|
import { BackendService } from '../../services/backend.service';
|
||||||
|
import { NgbActiveModal, NgbModule } from '@ng-bootstrap/ng-bootstrap';
|
||||||
|
|
||||||
describe('TaskFormComponent', () => {
|
describe('TaskFormComponent', () => {
|
||||||
let component: TaskFormComponent;
|
let component: TaskFormComponent;
|
||||||
@ -8,9 +11,17 @@ describe('TaskFormComponent', () => {
|
|||||||
|
|
||||||
beforeEach(async(() => {
|
beforeEach(async(() => {
|
||||||
TestBed.configureTestingModule({
|
TestBed.configureTestingModule({
|
||||||
declarations: [ TaskFormComponent ]
|
imports: [
|
||||||
|
HttpClientModule,
|
||||||
|
NgbModule,
|
||||||
|
],
|
||||||
|
declarations: [TaskFormComponent],
|
||||||
|
providers: [
|
||||||
|
BackendService,
|
||||||
|
NgbActiveModal,
|
||||||
|
]
|
||||||
})
|
})
|
||||||
.compileComponents();
|
.compileComponents();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
@ -19,7 +30,7 @@ describe('TaskFormComponent', () => {
|
|||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should create', () => {
|
it('should create the component', () => {
|
||||||
expect(component).toBeTruthy();
|
expect(component).toBeTruthy();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
28
src/app/components/task-table/task-table.component.spec.ts
Normal file
28
src/app/components/task-table/task-table.component.spec.ts
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
import { TestBed, async } from '@angular/core/testing';
|
||||||
|
import { RouterTestingModule } from '@angular/router/testing';
|
||||||
|
import { BackendService } from '../../services/backend.service';
|
||||||
|
import { HttpClientModule } from '@angular/common/http';
|
||||||
|
import { TaskTableComponent } from './task-table.component';
|
||||||
|
|
||||||
|
describe('TaskTableComponent', () => {
|
||||||
|
beforeEach(async(() => {
|
||||||
|
TestBed.configureTestingModule({
|
||||||
|
imports: [
|
||||||
|
RouterTestingModule,
|
||||||
|
HttpClientModule,
|
||||||
|
],
|
||||||
|
declarations: [
|
||||||
|
TaskTableComponent,
|
||||||
|
],
|
||||||
|
providers: [
|
||||||
|
BackendService,
|
||||||
|
]
|
||||||
|
}).compileComponents();
|
||||||
|
}));
|
||||||
|
|
||||||
|
it('should create the component', () => {
|
||||||
|
const fixture = TestBed.createComponent(TaskTableComponent);
|
||||||
|
const app = fixture.debugElement.componentInstance;
|
||||||
|
expect(app).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
@ -0,0 +1,36 @@
|
|||||||
|
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
|
|
||||||
|
import { HttpClientModule } from '@angular/common/http';
|
||||||
|
import { BackendService } from '../../services/backend.service';
|
||||||
|
import { NgbActiveModal, NgbModule } from '@ng-bootstrap/ng-bootstrap';
|
||||||
|
import { UserstoryFormComponent } from './userstory-form.component';
|
||||||
|
|
||||||
|
describe('UserstoryFormComponent', () => {
|
||||||
|
let component: UserstoryFormComponent;
|
||||||
|
let fixture: ComponentFixture<UserstoryFormComponent>;
|
||||||
|
|
||||||
|
beforeEach(async(() => {
|
||||||
|
TestBed.configureTestingModule({
|
||||||
|
imports: [
|
||||||
|
HttpClientModule,
|
||||||
|
NgbModule,
|
||||||
|
],
|
||||||
|
declarations: [ UserstoryFormComponent ],
|
||||||
|
providers: [
|
||||||
|
BackendService,
|
||||||
|
NgbActiveModal,
|
||||||
|
]
|
||||||
|
})
|
||||||
|
.compileComponents();
|
||||||
|
}));
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
fixture = TestBed.createComponent(UserstoryFormComponent);
|
||||||
|
component = fixture.componentInstance;
|
||||||
|
fixture.detectChanges();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should create the component', () => {
|
||||||
|
expect(component).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
@ -0,0 +1,28 @@
|
|||||||
|
import { TestBed, async } from '@angular/core/testing';
|
||||||
|
import { RouterTestingModule } from '@angular/router/testing';
|
||||||
|
import { BackendService } from '../../services/backend.service';
|
||||||
|
import { HttpClientModule } from '@angular/common/http';
|
||||||
|
import { UserstoryInnerTableComponent } from './userstory-inner-table.component';
|
||||||
|
|
||||||
|
describe('UserstoryInnerTableComponent', () => {
|
||||||
|
beforeEach(async(() => {
|
||||||
|
TestBed.configureTestingModule({
|
||||||
|
imports: [
|
||||||
|
RouterTestingModule,
|
||||||
|
HttpClientModule,
|
||||||
|
],
|
||||||
|
declarations: [
|
||||||
|
UserstoryInnerTableComponent,
|
||||||
|
],
|
||||||
|
providers: [
|
||||||
|
BackendService,
|
||||||
|
]
|
||||||
|
}).compileComponents();
|
||||||
|
}));
|
||||||
|
|
||||||
|
it('should create the component', () => {
|
||||||
|
const fixture = TestBed.createComponent(UserstoryInnerTableComponent);
|
||||||
|
const app = fixture.debugElement.componentInstance;
|
||||||
|
expect(app).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
@ -0,0 +1,28 @@
|
|||||||
|
import { TestBed, async } from '@angular/core/testing';
|
||||||
|
import { RouterTestingModule } from '@angular/router/testing';
|
||||||
|
import { BackendService } from '../../services/backend.service';
|
||||||
|
import { HttpClientModule } from '@angular/common/http';
|
||||||
|
import { UserstoryTableComponent } from './userstory-table.component';
|
||||||
|
|
||||||
|
describe('UserstoryTableComponent', () => {
|
||||||
|
beforeEach(async(() => {
|
||||||
|
TestBed.configureTestingModule({
|
||||||
|
imports: [
|
||||||
|
RouterTestingModule,
|
||||||
|
HttpClientModule,
|
||||||
|
],
|
||||||
|
declarations: [
|
||||||
|
UserstoryTableComponent,
|
||||||
|
],
|
||||||
|
providers: [
|
||||||
|
BackendService,
|
||||||
|
]
|
||||||
|
}).compileComponents();
|
||||||
|
}));
|
||||||
|
|
||||||
|
it('should create the component', () => {
|
||||||
|
const fixture = TestBed.createComponent(UserstoryTableComponent);
|
||||||
|
const app = fixture.debugElement.componentInstance;
|
||||||
|
expect(app).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
39
src/app/services/sorting.service.spec.ts
Normal file
39
src/app/services/sorting.service.spec.ts
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
import { sortByDateAscending, sortByNumberAscending, sortByStringAscending } from './sorting.service';
|
||||||
|
|
||||||
|
describe('SortingService', () => {
|
||||||
|
|
||||||
|
it('should sort correctly by number', () => {
|
||||||
|
const items = [7, 3, 2, 6, 4, 8, 0];
|
||||||
|
sortByNumberAscending(items, x => x);
|
||||||
|
expect(items).toEqual([0, 2, 3, 4, 6, 7, 8]);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should sort strings by length correctly', () => {
|
||||||
|
const items = ['aaaaa', 'a', 'aaa'];
|
||||||
|
sortByNumberAscending(items, x => x.length);
|
||||||
|
expect(items).toEqual(['a', 'aaa', 'aaaaa']);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should sort strings alphanumerically', () => {
|
||||||
|
const items = ['biz', 'bar', 'foo'];
|
||||||
|
sortByStringAscending(items, x => x);
|
||||||
|
expect(items).toEqual(['bar', 'biz', 'foo']);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should sort dates correctly', () => {
|
||||||
|
const items = [
|
||||||
|
new Date(2020, 2, 10, 13, 30),
|
||||||
|
new Date(2020, 2, 10, 12, 30),
|
||||||
|
new Date(2019, 4, 4),
|
||||||
|
new Date(2020, 2, 11, 13, 30),
|
||||||
|
];
|
||||||
|
sortByDateAscending(items, x => x);
|
||||||
|
expect(items).toEqual([
|
||||||
|
new Date(2019, 4, 4),
|
||||||
|
new Date(2020, 2, 10, 12, 30),
|
||||||
|
new Date(2020, 2, 10, 13, 30),
|
||||||
|
new Date(2020, 2, 11, 13, 30),
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
Loading…
x
Reference in New Issue
Block a user