TSK-1343: Migrate from karma/jasmine to jest (#1203)
* TSK-1289: Bumped to latest angular@8 * TSK-1289: Bumped to angular@9 * TSK-1289: Configured app for angular@9 * TSK-1343: Migrate from karma/jasmine to jest * TSK-1343: Remove unused packages * TSK-1343: Removed unnecessary dependencies * TSK-1343: Update jest output settings Co-authored-by: Tristan Eisermann <19949441+Tristan2357@users.noreply.github.com>
This commit is contained in:
parent
16d32fe5ab
commit
e022d62f91
|
@ -36,6 +36,7 @@ nbdist/
|
|||
# compiled output
|
||||
tmp/
|
||||
out-tsc/
|
||||
coverage/
|
||||
|
||||
# dependencies
|
||||
node_modules/
|
||||
|
|
|
@ -72,22 +72,6 @@
|
|||
"browserTarget": "taskana-web:build"
|
||||
}
|
||||
},
|
||||
"test": {
|
||||
"builder": "@angular-devkit/build-angular:karma",
|
||||
"options": {
|
||||
"main": "src/test.ts",
|
||||
"karmaConfig": "./karma.conf.js",
|
||||
"polyfills": "src/polyfills.ts",
|
||||
"tsConfig": "src/tsconfig.spec.json",
|
||||
"scripts": [
|
||||
"node_modules/jquery/dist/jquery.min.js",
|
||||
"node_modules/popper.js/dist/umd/popper.min.js",
|
||||
"node_modules/bootstrap/dist/js/bootstrap.min.js"
|
||||
],
|
||||
"styles": ["./node_modules/@angular/material/prebuilt-themes/indigo-pink.css", "src/theme/_main.scss"],
|
||||
"assets": ["src/assets", "src/environments/data-sources"]
|
||||
}
|
||||
},
|
||||
"lint": {
|
||||
"builder": "@angular-devkit/build-angular:tslint",
|
||||
"options": {
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
const { pathsToModuleNameMapper } = require('ts-jest/utils');
|
||||
const { compilerOptions } = require('./tsconfig');
|
||||
|
||||
module.exports = {
|
||||
preset: 'jest-preset-angular',
|
||||
roots: ['<rootDir>/src/'],
|
||||
testMatch: ['**/+(*.)+(spec).+(ts)'],
|
||||
setupFilesAfterEnv: ['<rootDir>/src/test.ts'],
|
||||
collectCoverage: true,
|
||||
coverageReporters: ['html', 'text'],
|
||||
coverageDirectory: 'coverage/taskana-web',
|
||||
moduleNameMapper: pathsToModuleNameMapper(compilerOptions.paths || {}, {
|
||||
prefix: '<rootDir>/'
|
||||
})
|
||||
};
|
|
@ -1,47 +0,0 @@
|
|||
// Karma configuration file, see link for more information
|
||||
// https://karma-runner.github.io/0.13/config/configuration-file.html
|
||||
|
||||
module.exports = function (config) {
|
||||
config.set({
|
||||
basePath: '',
|
||||
frameworks: ['jasmine', '@angular-devkit/build-angular'],
|
||||
plugins: [
|
||||
require('karma-jasmine'),
|
||||
require('karma-chrome-launcher'),
|
||||
require('karma-jasmine-html-reporter'),
|
||||
require('karma-coverage-istanbul-reporter'),
|
||||
require('@angular-devkit/build-angular/plugins/karma'),
|
||||
require('karma-firefox-launcher'),
|
||||
require('karma-firefox-launcher'),
|
||||
require('./jasmine-seed-reporter')
|
||||
],
|
||||
client: {
|
||||
jasmine: {
|
||||
// seed: '56124', // Specify if you need to re-run the same seed
|
||||
},
|
||||
clearContext: false // leave Jasmine Spec Runner output visible in browser
|
||||
},
|
||||
files: [],
|
||||
preprocessors: {},
|
||||
mime: {
|
||||
'text/x-typescript': ['ts', 'tsx']
|
||||
},
|
||||
coverageIstanbulReporter: {
|
||||
dir: require('path').join(__dirname, 'coverage'),
|
||||
reports: ['html', 'lcovonly'],
|
||||
fixWebpackSourcePaths: true
|
||||
},
|
||||
|
||||
reporters:
|
||||
config.angularCli && config.angularCli.codeCoverage
|
||||
? ['progress', 'coverage-istanbul', 'jasmine-seed']
|
||||
: ['progress', 'kjhtml', 'jasmine-seed'],
|
||||
port: 9876,
|
||||
colors: true,
|
||||
logLevel: config.LOG_INFO,
|
||||
autoWatch: true,
|
||||
browsers: ['Firefox'],
|
||||
singleRun: false,
|
||||
browserNoActivityTimeout: 30000
|
||||
});
|
||||
};
|
File diff suppressed because it is too large
Load Diff
|
@ -8,8 +8,8 @@
|
|||
"build": "ng build",
|
||||
"build:prod": "ng build --prod=true",
|
||||
"build:prod-silent": "ng build --prod=true --no-progress",
|
||||
"test": "ng test --karma-config karma.conf.js --watch=false --browsers Firefox",
|
||||
"test:watch": "ng test --karma-config karma.conf.js --browsers Chrome",
|
||||
"test": "jest",
|
||||
"test:watch": "jest --watch",
|
||||
"lint": "eslint --ext .ts src",
|
||||
"lint:fix": "eslint --ext .ts src --fix",
|
||||
"format": "prettier --write \"**/*.{js,ts,css,scss,md,json,yml}\"",
|
||||
|
@ -32,19 +32,15 @@
|
|||
"angular-tree-component": "8.5.2",
|
||||
"bootstrap": "4.4.1",
|
||||
"bootstrap-sass": "3.4.1",
|
||||
"chart.js": "2.7.2",
|
||||
"core-js": "3.6.5",
|
||||
"file-saver": "1.3.3",
|
||||
"jquery": "3.5.0",
|
||||
"magic-string": "0.22.4",
|
||||
"material-design-icons": "3.0.1",
|
||||
"ng2-charts": "1.6.0",
|
||||
"ngx-bootstrap": "5.4.0",
|
||||
"ngx-infinite-scroll": "9.0.0",
|
||||
"node-sass": "4.13.1",
|
||||
"popper.js": "1.16.1",
|
||||
"rxjs": "6.5.4",
|
||||
"set-value": "3.0.2",
|
||||
"tslib": "1.10.0",
|
||||
"zone.js": "~0.10.2"
|
||||
},
|
||||
|
@ -53,33 +49,19 @@
|
|||
"@angular/cli": "9.1.12",
|
||||
"@angular/compiler": "9.1.12",
|
||||
"@angular/compiler-cli": "9.1.12",
|
||||
"@types/jasmine": "2.8.4",
|
||||
"@types/jest": "26.0.7",
|
||||
"@types/node": "12.11.1",
|
||||
"@typescript-eslint/eslint-plugin": "2.15.0",
|
||||
"@typescript-eslint/eslint-plugin-tslint": "2.15.0",
|
||||
"@typescript-eslint/parser": "2.15.0",
|
||||
"ajv": "6.11.0",
|
||||
"codelyzer": "5.1.2",
|
||||
"diff": "3.5.0",
|
||||
"eslint": "6.8.0",
|
||||
"eslint-plugin-import": "2.22.0",
|
||||
"@hapi/hoek": "9.0.4",
|
||||
"eslint-config-prettier": "6.11.0",
|
||||
"eslint-plugin-import": "2.22.0",
|
||||
"eslint-plugin-prettier": "3.1.4",
|
||||
"jasmine-core": "3.5.0",
|
||||
"jasmine-spec-reporter": "4.2.1",
|
||||
"karma": "5.1.0",
|
||||
"karma-chrome-launcher": "2.2.0",
|
||||
"karma-cli": "2.0.0",
|
||||
"karma-coverage-istanbul-reporter": "2.0.5",
|
||||
"karma-firefox-launcher": "1.1.0",
|
||||
"karma-jasmine": "2.0.1",
|
||||
"karma-jasmine-html-reporter": "1.4.0",
|
||||
"moment": "2.22.1",
|
||||
"ng2-mock-component": "0.1.1",
|
||||
"jest": "26.1.0",
|
||||
"jest-preset-angular": "8.2.1",
|
||||
"prettier": "2.0.5",
|
||||
"protractor": "7.0.0",
|
||||
"ts-mockito": "2.3.0",
|
||||
"ts-jest": "26.1.4",
|
||||
"ts-node": "4.1.0",
|
||||
"tslint": "5.20.1",
|
||||
"typescript": "3.8.3"
|
||||
|
|
|
@ -1,41 +0,0 @@
|
|||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { configureTests } from 'app/app.test.configuration';
|
||||
import { AccessIdsService } from 'app/shared/services/access-ids/access-ids.service';
|
||||
import { FormsValidatorService } from 'app/shared/services/forms-validator/forms-validator.service';
|
||||
import { AccessIdDefinition } from 'app/shared/models/access-id';
|
||||
import { AccessItemWorkbasketResource } from 'app/shared/models/access-item-workbasket-resource';
|
||||
import { of } from 'rxjs';
|
||||
import { NgxsModule } from '@ngxs/store';
|
||||
import { AccessItemsManagementComponent } from './access-items-management.component';
|
||||
|
||||
describe('AccessItemsManagementComponent', () => {
|
||||
let component: AccessItemsManagementComponent;
|
||||
let fixture: ComponentFixture<AccessItemsManagementComponent>;
|
||||
let accessIdsService;
|
||||
|
||||
const configure = (testBed: TestBed) => {
|
||||
testBed.configureTestingModule({
|
||||
imports: [NgxsModule.forRoot()],
|
||||
declarations: [AccessItemsManagementComponent],
|
||||
providers: [AccessIdsService, FormsValidatorService]
|
||||
});
|
||||
};
|
||||
|
||||
beforeEach((done) => {
|
||||
configureTests(configure).then((testBed) => {
|
||||
fixture = testBed.createComponent(AccessItemsManagementComponent);
|
||||
component = fixture.componentInstance;
|
||||
accessIdsService = testBed.get(AccessIdsService);
|
||||
spyOn(accessIdsService, 'getAccessItems').and.returnValue(of(new Array<AccessIdDefinition>()));
|
||||
spyOn(accessIdsService, 'searchForAccessId').and.returnValue(of(new AccessItemWorkbasketResource()));
|
||||
spyOn(accessIdsService, 'getGroupsByAccessId').and.returnValue(of(new AccessItemWorkbasketResource()));
|
||||
fixture.detectChanges();
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
|
@ -1,112 +0,0 @@
|
|||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { FormsModule } from '@angular/forms';
|
||||
import { HttpClient, HttpClientModule } from '@angular/common/http';
|
||||
import { Component } from '@angular/core';
|
||||
import { of } from 'rxjs';
|
||||
import { AngularSvgIconModule } from 'angular-svg-icon';
|
||||
import { configureTests } from 'app/app.test.configuration';
|
||||
import { NgxsModule, Store } from '@ngxs/store';
|
||||
import { Location } from '@angular/common';
|
||||
|
||||
import { MasterAndDetailService } from 'app/shared/services/master-and-detail/master-and-detail.service';
|
||||
import { RequestInProgressService } from 'app/shared/services/request-in-progress/request-in-progress.service';
|
||||
import { ClassificationsService } from 'app/shared/services/classifications/classifications.service';
|
||||
import { TreeNodeModel } from 'app/administration/models/tree-node';
|
||||
import { ImportExportService } from 'app/administration/services/import-export.service';
|
||||
import { EngineConfigurationSelectors } from 'app/shared/store/engine-configuration-store/engine-configuration.selectors';
|
||||
import { ClassificationSelectors } from 'app/shared/store/classification-store/classification.selectors';
|
||||
import { ClassificationDetailsComponent } from './classification-details.component';
|
||||
import { NotificationService } from '../../../shared/services/notifications/notification.service';
|
||||
|
||||
@Component({
|
||||
selector: 'taskana-dummy-detail',
|
||||
template: 'dummydetail'
|
||||
})
|
||||
class DummyDetailComponent {}
|
||||
|
||||
describe('ClassificationDetailsComponent', () => {
|
||||
let component: ClassificationDetailsComponent;
|
||||
let fixture: ComponentFixture<ClassificationDetailsComponent>;
|
||||
const treeNodes: TreeNodeModel[] = [];
|
||||
|
||||
let classificationsService;
|
||||
|
||||
const locationSpy: jasmine.SpyObj<Location> = jasmine.createSpyObj('Location', ['go']);
|
||||
const storeSpy: jasmine.SpyObj<Store> = jasmine.createSpyObj('Store', ['select', 'dispatch']);
|
||||
const configure = (testBed: TestBed) => {
|
||||
testBed.configureTestingModule({
|
||||
imports: [FormsModule, HttpClientModule, AngularSvgIconModule, NgxsModule.forRoot()],
|
||||
declarations: [ClassificationDetailsComponent, DummyDetailComponent],
|
||||
providers: [
|
||||
MasterAndDetailService,
|
||||
RequestInProgressService,
|
||||
ClassificationsService,
|
||||
HttpClient,
|
||||
NotificationService,
|
||||
ImportExportService,
|
||||
{ provide: Location, useValue: locationSpy },
|
||||
{ provide: Store, useValue: storeSpy }
|
||||
]
|
||||
});
|
||||
};
|
||||
|
||||
beforeEach((done) => {
|
||||
configureTests(configure).then((testBed) => {
|
||||
storeSpy.select.and.callFake((selector) => {
|
||||
switch (selector) {
|
||||
case EngineConfigurationSelectors.classificationsCustomisation:
|
||||
return of({ information: {} });
|
||||
case ClassificationSelectors.selectCategories:
|
||||
return of(['EXTERNAL', 'MANUAL']);
|
||||
default:
|
||||
return of();
|
||||
}
|
||||
});
|
||||
|
||||
fixture = testBed.createComponent(ClassificationDetailsComponent);
|
||||
|
||||
component = fixture.componentInstance;
|
||||
classificationsService = testBed.get(ClassificationsService);
|
||||
spyOn(classificationsService, 'getClassifications').and.returnValue(of(treeNodes));
|
||||
spyOn(classificationsService, 'deleteClassification').and.returnValue(of(true));
|
||||
component.classification = {
|
||||
classificationId: 'CLI:100000000000000000000000000000000002',
|
||||
key: 'L10303',
|
||||
applicationEntryPoint: '',
|
||||
category: 'EXTERNAL',
|
||||
domain: 'DOMAIN_A',
|
||||
name: 'Beratungsprotokoll',
|
||||
parentId: '',
|
||||
parentKey: '',
|
||||
priority: 101,
|
||||
serviceLevel: 'P1D',
|
||||
type: 'TASK',
|
||||
custom1: 'VNR,RVNR,KOLVNR, ANR',
|
||||
custom2: '',
|
||||
custom3: '',
|
||||
custom4: '',
|
||||
custom5: '',
|
||||
custom6: '',
|
||||
custom7: '',
|
||||
custom8: '',
|
||||
isValidInDomain: true,
|
||||
created: '2020-06-22T12:51:31.164Z',
|
||||
modified: '2020-06-22T12:51:31.164Z',
|
||||
description: 'Beratungsprotokoll'
|
||||
};
|
||||
fixture.detectChanges();
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should enable editing of key on create and on copy', async (done) => {
|
||||
component.isCreatingNewClassification = true;
|
||||
await fixture.detectChanges();
|
||||
expect(fixture.debugElement.nativeElement.querySelector('#classification-key').disabled).toEqual(false);
|
||||
done();
|
||||
});
|
||||
});
|
|
@ -1,86 +0,0 @@
|
|||
import { Component } from '@angular/core';
|
||||
import { FormsModule } from '@angular/forms';
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { HttpClient, HttpClientModule } from '@angular/common/http';
|
||||
import { of } from 'rxjs';
|
||||
import { Routes } from '@angular/router';
|
||||
import { RouterTestingModule } from '@angular/router/testing';
|
||||
import { AngularSvgIconModule } from 'angular-svg-icon';
|
||||
|
||||
import { TreeNodeModel } from 'app/administration/models/tree-node';
|
||||
|
||||
import { ImportExportComponent } from 'app/administration/components/import-export/import-export.component';
|
||||
import { ClassificationTypesSelectorComponent } from 'app/administration/components/classification-types-selector/classification-types-selector.component';
|
||||
|
||||
import { WorkbasketDefinitionService } from 'app/administration/services/workbasket-definition.service';
|
||||
import { ClassificationsService } from 'app/shared/services/classifications/classifications.service';
|
||||
import { ClassificationDefinitionService } from 'app/administration/services/classification-definition.service';
|
||||
import { DomainService } from 'app/shared/services/domain/domain.service';
|
||||
import { RequestInProgressService } from 'app/shared/services/request-in-progress/request-in-progress.service';
|
||||
import { configureTests } from 'app/app.test.configuration';
|
||||
import { ImportExportService } from 'app/administration/services/import-export.service';
|
||||
import { NgxsModule } from '@ngxs/store';
|
||||
import { MatRadioModule } from '@angular/material/radio';
|
||||
import { ClassificationListComponent } from './classification-list.component';
|
||||
import { NotificationService } from '../../../shared/services/notifications/notification.service';
|
||||
|
||||
@Component({
|
||||
selector: 'taskana-dummy-detail',
|
||||
template: 'dummydetail'
|
||||
})
|
||||
class DummyDetailComponent {}
|
||||
|
||||
const routes: Routes = [{ path: ':id', component: DummyDetailComponent }];
|
||||
|
||||
describe('ClassificationListComponent', () => {
|
||||
let component: ClassificationListComponent;
|
||||
let fixture: ComponentFixture<ClassificationListComponent>;
|
||||
const treeNodes: TreeNodeModel[] = [{ children: [] }];
|
||||
let classificationsService;
|
||||
|
||||
const configure = (testBed: TestBed) => {
|
||||
testBed.configureTestingModule({
|
||||
declarations: [
|
||||
ClassificationListComponent,
|
||||
ImportExportComponent,
|
||||
ClassificationTypesSelectorComponent,
|
||||
DummyDetailComponent
|
||||
],
|
||||
imports: [
|
||||
HttpClientModule,
|
||||
RouterTestingModule.withRoutes(routes),
|
||||
FormsModule,
|
||||
AngularSvgIconModule,
|
||||
NgxsModule.forRoot([]),
|
||||
MatRadioModule
|
||||
],
|
||||
providers: [
|
||||
HttpClient,
|
||||
WorkbasketDefinitionService,
|
||||
NotificationService,
|
||||
ClassificationsService,
|
||||
DomainService,
|
||||
ClassificationDefinitionService,
|
||||
RequestInProgressService,
|
||||
ImportExportService
|
||||
]
|
||||
});
|
||||
};
|
||||
|
||||
beforeEach((done) => {
|
||||
configureTests(configure).then((testBed) => {
|
||||
fixture = testBed.createComponent(ClassificationListComponent);
|
||||
component = fixture.componentInstance;
|
||||
|
||||
classificationsService = testBed.get(ClassificationsService);
|
||||
spyOn(classificationsService, 'getClassifications').and.returnValue(of(treeNodes));
|
||||
|
||||
fixture.detectChanges();
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
|
@ -1,43 +0,0 @@
|
|||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { Location } from '@angular/common';
|
||||
import { RouterTestingModule } from '@angular/router/testing';
|
||||
import { NgxsModule } from '@ngxs/store';
|
||||
import { Component, NO_ERRORS_SCHEMA } from '@angular/core';
|
||||
import { Router, Routes } from '@angular/router';
|
||||
import { ClassificationOverviewComponent } from './classification-overview.component';
|
||||
|
||||
@Component({
|
||||
selector: 'taskana-dummy-detail',
|
||||
template: 'dummydetail'
|
||||
})
|
||||
export class DummyDetailComponent {}
|
||||
|
||||
describe('ClassificationOverviewComponent', () => {
|
||||
let component: ClassificationOverviewComponent;
|
||||
let fixture: ComponentFixture<ClassificationOverviewComponent>;
|
||||
let router;
|
||||
let debugElement;
|
||||
const locationSpy: jasmine.SpyObj<Location> = jasmine.createSpyObj('Location', ['go']);
|
||||
|
||||
beforeEach(() => {
|
||||
const routes: Routes = [{ path: ':id', component: DummyDetailComponent }];
|
||||
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ClassificationOverviewComponent, DummyDetailComponent],
|
||||
imports: [RouterTestingModule.withRoutes(routes), NgxsModule.forRoot()],
|
||||
providers: [{ provide: Location, useValue: locationSpy }],
|
||||
schemas: [NO_ERRORS_SCHEMA]
|
||||
});
|
||||
|
||||
fixture = TestBed.createComponent(ClassificationOverviewComponent);
|
||||
component = fixture.componentInstance;
|
||||
debugElement = fixture.debugElement.nativeElement;
|
||||
router = TestBed.get(Router);
|
||||
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
|
@ -1,30 +0,0 @@
|
|||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { NgxsModule } from '@ngxs/store';
|
||||
import { MatRadioModule } from '@angular/material/radio';
|
||||
import { Location } from '@angular/common';
|
||||
import { ClassificationTypesSelectorComponent } from './classification-types-selector.component';
|
||||
|
||||
describe('ClassificationTypesSelectorComponent', () => {
|
||||
let component: ClassificationTypesSelectorComponent;
|
||||
let fixture: ComponentFixture<ClassificationTypesSelectorComponent>;
|
||||
const locationSpy: jasmine.SpyObj<Location> = jasmine.createSpyObj('Location', ['go']);
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [NgxsModule.forRoot(), MatRadioModule],
|
||||
declarations: [ClassificationTypesSelectorComponent],
|
||||
providers: [{ provide: Location, useValue: locationSpy }]
|
||||
}).compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(ClassificationTypesSelectorComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
|
@ -1,48 +0,0 @@
|
|||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { WorkbasketService } from 'app/shared/services/workbasket/workbasket.service';
|
||||
import { ClassificationDefinitionService } from 'app/administration/services/classification-definition.service';
|
||||
import { HttpClientModule } from '@angular/common/http';
|
||||
import { AngularSvgIconModule } from 'angular-svg-icon';
|
||||
import { configureTests } from 'app/app.test.configuration';
|
||||
import { ImportExportService } from 'app/administration/services/import-export.service';
|
||||
import { WorkbasketDefinitionService } from '../../services/workbasket-definition.service';
|
||||
import { ImportExportComponent } from './import-export.component';
|
||||
import { NotificationService } from '../../../shared/services/notifications/notification.service';
|
||||
|
||||
describe('ImportExportComponent', () => {
|
||||
let component: ImportExportComponent;
|
||||
let fixture: ComponentFixture<ImportExportComponent>;
|
||||
let debugElement;
|
||||
|
||||
beforeEach((done) => {
|
||||
const configure = (testBed: TestBed) => {
|
||||
testBed.configureTestingModule({
|
||||
declarations: [ImportExportComponent],
|
||||
imports: [HttpClientModule, AngularSvgIconModule],
|
||||
providers: [
|
||||
WorkbasketService,
|
||||
ClassificationDefinitionService,
|
||||
WorkbasketDefinitionService,
|
||||
NotificationService,
|
||||
ImportExportService
|
||||
]
|
||||
});
|
||||
};
|
||||
configureTests(configure).then((testBed) => {
|
||||
fixture = TestBed.createComponent(ImportExportComponent);
|
||||
component = fixture.componentInstance;
|
||||
debugElement = fixture.debugElement.nativeElement;
|
||||
fixture.detectChanges();
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
document.body.removeChild(debugElement);
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
|
@ -1,148 +0,0 @@
|
|||
import { Component, Input } from '@angular/core';
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { AngularSvgIconModule } from 'angular-svg-icon';
|
||||
import { HttpClientModule } from '@angular/common/http';
|
||||
|
||||
import { configureTests } from 'app/app.test.configuration';
|
||||
import { NgxsModule, Store } from '@ngxs/store';
|
||||
import { ClassificationSelectors } from 'app/shared/store/classification-store/classification.selectors';
|
||||
import { of } from 'rxjs';
|
||||
import { Location } from '@angular/common';
|
||||
import { UpdateClassification } from 'app/shared/store/classification-store/classification.actions';
|
||||
import { TaskanaTreeComponent } from './tree.component';
|
||||
import { ClassificationsService } from '../../../shared/services/classifications/classifications.service';
|
||||
import { Classification } from '../../../shared/models/classification';
|
||||
|
||||
@Component({
|
||||
selector: 'tree-root',
|
||||
template: ''
|
||||
})
|
||||
class TreeVendorComponent {
|
||||
@Input() options;
|
||||
@Input() state;
|
||||
@Input() nodes;
|
||||
}
|
||||
|
||||
describe('TaskanaTreeComponent', () => {
|
||||
let component: TaskanaTreeComponent;
|
||||
let fixture: ComponentFixture<TaskanaTreeComponent>;
|
||||
let classificationsService;
|
||||
let moveNodeEvent;
|
||||
let dropEvent;
|
||||
|
||||
const locationSpy: jasmine.SpyObj<Location> = jasmine.createSpyObj('Location', ['go', 'path']);
|
||||
const storeSpy: jasmine.SpyObj<Store> = jasmine.createSpyObj('Store', ['select', 'dispatch']);
|
||||
|
||||
const configure = (testBed: TestBed) => {
|
||||
testBed.configureTestingModule({
|
||||
imports: [AngularSvgIconModule, HttpClientModule, NgxsModule.forRoot()],
|
||||
declarations: [TreeVendorComponent],
|
||||
providers: [
|
||||
ClassificationsService,
|
||||
{ provide: Location, useValue: locationSpy },
|
||||
{ provide: Store, useValue: storeSpy }
|
||||
]
|
||||
});
|
||||
};
|
||||
|
||||
beforeEach((done) => {
|
||||
configureTests(configure).then((testBed) => {
|
||||
locationSpy.path.and.callFake(() => '');
|
||||
storeSpy.select.and.callFake((selector) => {
|
||||
switch (selector) {
|
||||
case ClassificationSelectors.selectedClassificationId:
|
||||
return of('id4');
|
||||
case ClassificationSelectors.classifications:
|
||||
return of([{ classificationId: 'id4' }]);
|
||||
default:
|
||||
return of();
|
||||
}
|
||||
});
|
||||
storeSpy.dispatch.and.callFake(() => of());
|
||||
|
||||
fixture = testBed.createComponent(TaskanaTreeComponent);
|
||||
classificationsService = testBed.get(ClassificationsService);
|
||||
moveNodeEvent = {
|
||||
eventName: 'moveNode',
|
||||
node: { classificationId: 'id4', parentId: '', parentKey: '', _links: { self: { href: 'url' } } },
|
||||
to: { parent: { classificationId: 'id3', key: 'key3' } }
|
||||
};
|
||||
|
||||
dropEvent = {
|
||||
event: { target: { tagName: 'TREE-VIEWPORT' } },
|
||||
element: { data: { classificationId: 'id3', parentId: 'id1', parentKey: 'key1' } }
|
||||
};
|
||||
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should be change the classification parent (onMoveNode)', async () => {
|
||||
const classification: Classification = {
|
||||
classificationId: 'id4',
|
||||
key: 'key4',
|
||||
category: 'MANUAL',
|
||||
domain: 'DOMAIN_A',
|
||||
parentId: '',
|
||||
parentKey: '',
|
||||
type: 'TASK',
|
||||
isValidInDomain: true,
|
||||
created: '019-04-10T10:23:34.985Z',
|
||||
modified: '2019-04-10T10:23:34.985Z',
|
||||
name: 'classification4',
|
||||
description: 'description',
|
||||
priority: 1,
|
||||
serviceLevel: 'level'
|
||||
};
|
||||
|
||||
// using parameter 'any' since getClassification is a private method
|
||||
spyOn<any>(component, 'getClassification').and.returnValue(classification);
|
||||
spyOn(component, 'switchTaskanaSpinner');
|
||||
|
||||
expect(classification.parentId).toEqual('');
|
||||
expect(classification.parentKey).toEqual('');
|
||||
|
||||
await component.onMoveNode(moveNodeEvent);
|
||||
|
||||
expect(classification.parentId).toEqual('id3');
|
||||
expect(classification.parentKey).toEqual('key3');
|
||||
expect(storeSpy.dispatch).toHaveBeenCalledWith(new UpdateClassification(classification));
|
||||
});
|
||||
|
||||
it('should be changed the parent classification to root node (onDrop)', async () => {
|
||||
const classification: Classification = {
|
||||
classificationId: 'id3',
|
||||
key: 'key3',
|
||||
parentId: 'id1',
|
||||
parentKey: 'key1',
|
||||
category: 'MANUAL',
|
||||
domain: 'DOMAIN_A',
|
||||
type: 'TASK',
|
||||
isValidInDomain: true,
|
||||
created: '019-04-10T10:23:34.985Z',
|
||||
modified: '2019-04-10T10:23:34.985Z',
|
||||
name: 'classification3',
|
||||
description: 'description',
|
||||
priority: 1,
|
||||
serviceLevel: 'level'
|
||||
};
|
||||
|
||||
// using parameter 'any' since getClassification is a private method
|
||||
spyOn<any>(component, 'getClassification').and.returnValue(classification);
|
||||
spyOn(component, 'switchTaskanaSpinner');
|
||||
|
||||
expect(classification.parentId).toEqual('id1');
|
||||
expect(classification.parentKey).toEqual('key1');
|
||||
|
||||
await component.onDrop(dropEvent);
|
||||
|
||||
expect(classification.parentId).toEqual('');
|
||||
expect(classification.parentKey).toEqual('');
|
||||
});
|
||||
});
|
|
@ -1,34 +0,0 @@
|
|||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { AngularSvgIconModule } from 'angular-svg-icon';
|
||||
import { HttpClientModule } from '@angular/common/http';
|
||||
import { configureTests } from 'app/app.test.configuration';
|
||||
import { IconTypeComponent } from './icon-type.component';
|
||||
|
||||
describe('IconTypeComponent', () => {
|
||||
let component: IconTypeComponent;
|
||||
let fixture: ComponentFixture<IconTypeComponent>;
|
||||
let debugElement;
|
||||
|
||||
beforeEach((done) => {
|
||||
const configure = (testBed: TestBed) => {
|
||||
testBed.configureTestingModule({
|
||||
imports: [AngularSvgIconModule, HttpClientModule]
|
||||
});
|
||||
};
|
||||
configureTests(configure).then((testBed) => {
|
||||
fixture = TestBed.createComponent(IconTypeComponent);
|
||||
component = fixture.componentInstance;
|
||||
debugElement = fixture.debugElement.nativeElement;
|
||||
fixture.detectChanges();
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
document.body.removeChild(debugElement);
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
|
@ -1,174 +0,0 @@
|
|||
import { Component } from '@angular/core';
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { RouterTestingModule } from '@angular/router/testing';
|
||||
import { Router, Routes } from '@angular/router';
|
||||
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
|
||||
import { AngularSvgIconModule } from 'angular-svg-icon';
|
||||
import { HttpClientModule } from '@angular/common/http';
|
||||
import { of } from 'rxjs';
|
||||
|
||||
import { Workbasket } from 'app/shared/models/workbasket';
|
||||
import { WorkbasketSummaryRepresentation } from 'app/shared/models/workbasket-summary-representation';
|
||||
import { WorkbasketAccessItemsRepresentation } from 'app/shared/models/workbasket-access-items-representation';
|
||||
import { ICONTYPES } from 'app/shared/models/icon-types';
|
||||
import { Links } from 'app/shared/models/links';
|
||||
|
||||
import { WorkbasketService } from 'app/shared/services/workbasket/workbasket.service';
|
||||
import { MasterAndDetailService } from 'app/shared/services/master-and-detail/master-and-detail.service';
|
||||
import { SavingWorkbasketService } from 'app/administration/services/saving-workbaskets.service';
|
||||
import { RequestInProgressService } from 'app/shared/services/request-in-progress/request-in-progress.service';
|
||||
import { configureTests } from 'app/app.test.configuration';
|
||||
|
||||
import { InfiniteScrollModule } from 'ngx-infinite-scroll';
|
||||
import { ImportExportService } from 'app/administration/services/import-export.service';
|
||||
import { NgxsModule } from '@ngxs/store';
|
||||
import { WorkbasketDetailsComponent } from './workbasket-details.component';
|
||||
import { WorkbasketInformationComponent } from '../workbasket-information/workbasket-information.component';
|
||||
import { WorkbasketAccessItemsComponent } from '../workbasket-access-items/workbasket-access-items.component';
|
||||
import { WorkbasketDistributionTargetsComponent } from '../workbasket-distribution-targets/workbasket-distribution-targets.component';
|
||||
import { WorkbasketDualListComponent } from '../workbasket-dual-list/workbasket-dual-list.component';
|
||||
import { NotificationService } from '../../../shared/services/notifications/notification.service';
|
||||
|
||||
@Component({
|
||||
selector: 'taskana-dummy-detail',
|
||||
template: 'dummydetail'
|
||||
})
|
||||
export class DummyDetailComponent {}
|
||||
|
||||
function createWorkbasket(
|
||||
workbasketId?,
|
||||
created?,
|
||||
key?,
|
||||
domain?,
|
||||
type?,
|
||||
modified?,
|
||||
name?,
|
||||
description?,
|
||||
owner?,
|
||||
custom1?,
|
||||
custom2?,
|
||||
custom3?,
|
||||
custom4?,
|
||||
orgLevel1?,
|
||||
orgLevel2?,
|
||||
orgLevel3?,
|
||||
orgLevel4?,
|
||||
_links?: Links,
|
||||
markedForDeletion?: boolean
|
||||
) {
|
||||
const workbasket: Workbasket = {
|
||||
workbasketId,
|
||||
created,
|
||||
key,
|
||||
domain,
|
||||
type,
|
||||
modified,
|
||||
name,
|
||||
description,
|
||||
owner,
|
||||
custom1,
|
||||
custom2,
|
||||
custom3,
|
||||
custom4,
|
||||
orgLevel1,
|
||||
orgLevel2,
|
||||
orgLevel3,
|
||||
orgLevel4,
|
||||
markedForDeletion,
|
||||
_links
|
||||
};
|
||||
return workbasket;
|
||||
}
|
||||
|
||||
describe('WorkbasketDetailsComponent', () => {
|
||||
let component: WorkbasketDetailsComponent;
|
||||
let fixture: ComponentFixture<WorkbasketDetailsComponent>;
|
||||
let debugElement;
|
||||
let masterAndDetailService;
|
||||
let workbasketService;
|
||||
let router;
|
||||
const workbasket = createWorkbasket(
|
||||
'1',
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
ICONTYPES.TOPIC,
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
{}
|
||||
);
|
||||
|
||||
const workbasketSummaryRepresentation: WorkbasketSummaryRepresentation = { workbaskets: [], _links: {}, page: {} };
|
||||
|
||||
const workbasketAccessItemsRepresentation: WorkbasketAccessItemsRepresentation = { accessItems: [], _links: {} };
|
||||
const routes: Routes = [{ path: '*', component: DummyDetailComponent }];
|
||||
|
||||
beforeEach((done) => {
|
||||
const configure = (testBed: TestBed) => {
|
||||
testBed.configureTestingModule({
|
||||
imports: [
|
||||
RouterTestingModule.withRoutes(routes),
|
||||
FormsModule,
|
||||
AngularSvgIconModule,
|
||||
HttpClientModule,
|
||||
ReactiveFormsModule,
|
||||
InfiniteScrollModule,
|
||||
NgxsModule.forRoot()
|
||||
],
|
||||
declarations: [
|
||||
WorkbasketDetailsComponent,
|
||||
WorkbasketInformationComponent,
|
||||
WorkbasketAccessItemsComponent,
|
||||
WorkbasketDistributionTargetsComponent,
|
||||
WorkbasketDualListComponent,
|
||||
DummyDetailComponent
|
||||
],
|
||||
providers: [
|
||||
WorkbasketService,
|
||||
MasterAndDetailService,
|
||||
RequestInProgressService,
|
||||
NotificationService,
|
||||
SavingWorkbasketService,
|
||||
ImportExportService
|
||||
]
|
||||
});
|
||||
};
|
||||
configureTests(configure).then((testBed) => {
|
||||
fixture = TestBed.createComponent(WorkbasketDetailsComponent);
|
||||
component = fixture.componentInstance;
|
||||
debugElement = fixture.debugElement.nativeElement;
|
||||
router = TestBed.get(Router);
|
||||
fixture.detectChanges();
|
||||
masterAndDetailService = TestBed.get(MasterAndDetailService);
|
||||
workbasketService = TestBed.get(WorkbasketService);
|
||||
spyOn(masterAndDetailService, 'getShowDetail').and.callFake(() => of(true));
|
||||
spyOn(workbasketService, 'getSelectedWorkBasket').and.callFake(() => of('id1'));
|
||||
spyOn(workbasketService, 'getWorkBasketsSummary').and.callFake(() => of(workbasketSummaryRepresentation));
|
||||
|
||||
spyOn(workbasketService, 'getWorkBasket').and.callFake(() => of(workbasket));
|
||||
spyOn(workbasketService, 'getWorkBasketAccessItems').and.callFake(() => of(workbasketAccessItemsRepresentation));
|
||||
spyOn(workbasketService, 'getWorkBasketsDistributionTargets').and.callFake(() =>
|
||||
of(workbasketSummaryRepresentation)
|
||||
);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
fixture.destroy();
|
||||
});
|
||||
|
||||
it('should be created', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
|
@ -1,218 +0,0 @@
|
|||
import { SimpleChange } from '@angular/core';
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { of } from 'rxjs';
|
||||
import { AngularSvgIconModule } from 'angular-svg-icon';
|
||||
import { HttpClientModule } from '@angular/common/http';
|
||||
|
||||
import { WorkbasketSummaryRepresentation } from 'app/shared/models/workbasket-summary-representation';
|
||||
import { WorkbasketSummary } from 'app/shared/models/workbasket-summary';
|
||||
import { ICONTYPES } from 'app/shared/models/icon-types';
|
||||
import { Links } from 'app/shared/models/links';
|
||||
import { Workbasket } from 'app/shared/models/workbasket';
|
||||
import { WorkbasketDistributionTargets } from 'app/shared/models/workbasket-distribution-targets';
|
||||
|
||||
import { WorkbasketService } from 'app/shared/services/workbasket/workbasket.service';
|
||||
import { SavingWorkbasketService } from 'app/administration/services/saving-workbaskets.service';
|
||||
import { RequestInProgressService } from 'app/shared/services/request-in-progress/request-in-progress.service';
|
||||
|
||||
import { LinksWorkbasketSummary } from 'app/shared/models/links-workbasket-summary';
|
||||
import { configureTests } from 'app/app.test.configuration';
|
||||
import { InfiniteScrollModule } from 'ngx-infinite-scroll';
|
||||
import { NgxsModule, Store } from '@ngxs/store';
|
||||
import { WorkbasketDistributionTargetsComponent, Side } from './workbasket-distribution-targets.component';
|
||||
import { WorkbasketDualListComponent } from '../workbasket-dual-list/workbasket-dual-list.component';
|
||||
import { NotificationService } from '../../../shared/services/notifications/notification.service';
|
||||
import { ClassificationSelectors } from '../../../shared/store/classification-store/classification.selectors';
|
||||
import { WorkbasketSelectors } from '../../../shared/store/workbasket-store/workbasket.selectors';
|
||||
|
||||
describe('WorkbasketDistributionTargetsComponent', () => {
|
||||
let component: WorkbasketDistributionTargetsComponent;
|
||||
let fixture: ComponentFixture<WorkbasketDistributionTargetsComponent>;
|
||||
let workbasketService;
|
||||
const workbasket = createWorkbasket(
|
||||
'1',
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
ICONTYPES.TOPIC,
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
{}
|
||||
);
|
||||
function createWorkbasket(
|
||||
workbasketId?,
|
||||
created?,
|
||||
key?,
|
||||
domain?,
|
||||
type?,
|
||||
modified?,
|
||||
name?,
|
||||
description?,
|
||||
owner?,
|
||||
custom1?,
|
||||
custom2?,
|
||||
custom3?,
|
||||
custom4?,
|
||||
orgLevel1?,
|
||||
orgLevel2?,
|
||||
orgLevel3?,
|
||||
orgLevel4?,
|
||||
_links?: Links,
|
||||
markedForDeletion?: boolean
|
||||
): Workbasket {
|
||||
return {
|
||||
workbasketId,
|
||||
created,
|
||||
key,
|
||||
domain,
|
||||
type,
|
||||
modified,
|
||||
name,
|
||||
description,
|
||||
owner,
|
||||
custom1,
|
||||
custom2,
|
||||
custom3,
|
||||
custom4,
|
||||
orgLevel1,
|
||||
orgLevel2,
|
||||
orgLevel3,
|
||||
orgLevel4,
|
||||
markedForDeletion,
|
||||
_links
|
||||
};
|
||||
}
|
||||
|
||||
function createWorkbasketSummary(
|
||||
workbasketId,
|
||||
key,
|
||||
name,
|
||||
domain,
|
||||
type,
|
||||
description,
|
||||
owner,
|
||||
custom1,
|
||||
custom2,
|
||||
custom3,
|
||||
custom4
|
||||
) {
|
||||
const workbasketSummary: WorkbasketSummary = {
|
||||
workbasketId,
|
||||
key,
|
||||
name,
|
||||
domain,
|
||||
type,
|
||||
description,
|
||||
owner,
|
||||
custom1,
|
||||
custom2,
|
||||
custom3,
|
||||
custom4
|
||||
};
|
||||
return workbasketSummary;
|
||||
}
|
||||
const workbasketSummaryResource: WorkbasketSummaryRepresentation = {
|
||||
workbaskets: [
|
||||
createWorkbasketSummary('1', 'key1', 'NAME1', '', 'PERSONAL', 'description 1', 'owner1', '', '', '', ''),
|
||||
createWorkbasketSummary('2', 'key2', 'NAME2', '', 'PERSONAL', 'description 2', 'owner2', '', '', '', '')
|
||||
],
|
||||
_links: new LinksWorkbasketSummary({ href: 'url' }),
|
||||
page: {}
|
||||
};
|
||||
|
||||
const workbasketDistributionTargets: WorkbasketDistributionTargets = {
|
||||
distributionTargets: [createWorkbasketSummary('id2', '', '', '', '', '', '', '', '', '', '')],
|
||||
_links: {}
|
||||
};
|
||||
|
||||
const storeSpy: jasmine.SpyObj<Store> = jasmine.createSpyObj('Store', ['select', 'dispatch']);
|
||||
|
||||
beforeEach((done) => {
|
||||
const configure = (testBed: TestBed) => {
|
||||
testBed.configureTestingModule({
|
||||
imports: [AngularSvgIconModule, HttpClientModule, InfiniteScrollModule, NgxsModule.forRoot()],
|
||||
declarations: [WorkbasketDistributionTargetsComponent, WorkbasketDualListComponent],
|
||||
providers: [
|
||||
WorkbasketService,
|
||||
NotificationService,
|
||||
SavingWorkbasketService,
|
||||
RequestInProgressService,
|
||||
{ provide: Store, useValue: storeSpy }
|
||||
]
|
||||
});
|
||||
};
|
||||
configureTests(configure).then((testBed) => {
|
||||
storeSpy.select.and.callFake((selector) => {
|
||||
switch (selector) {
|
||||
case WorkbasketSelectors.workbasketDistributionTargets:
|
||||
return of(['distributionTargets', '_links']);
|
||||
default:
|
||||
return of();
|
||||
}
|
||||
});
|
||||
fixture = TestBed.createComponent(WorkbasketDistributionTargetsComponent);
|
||||
component = fixture.componentInstance;
|
||||
component.workbasket = workbasket;
|
||||
workbasketService = TestBed.get(WorkbasketService);
|
||||
spyOn(workbasketService, 'getWorkBasketsSummary').and.callFake(() => of(workbasketSummaryResource));
|
||||
spyOn(workbasketService, 'getWorkBasketsDistributionTargets').and.callFake(() =>
|
||||
of(workbasketDistributionTargets)
|
||||
);
|
||||
component.ngOnChanges({
|
||||
active: new SimpleChange(undefined, 'distributionTargets', true)
|
||||
});
|
||||
fixture.detectChanges();
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should clone distribution target selected on init', () => {
|
||||
expect(component.distributionTargetsClone).toBeDefined();
|
||||
});
|
||||
|
||||
it('should clone distribution target left and distribution target right lists on init', () => {
|
||||
expect(component.distributionTargetsLeft).toBeDefined();
|
||||
expect(component.distributionTargetsRight).toBeDefined();
|
||||
});
|
||||
|
||||
it('should have two list with same elements onInit', () => {
|
||||
let repeteadElemens = false;
|
||||
expect(component.distributionTargetsLeft.length).toBe(2);
|
||||
expect(component.distributionTargetsRight.length).toBe(2);
|
||||
component.distributionTargetsLeft.forEach((leftElement) => {
|
||||
component.distributionTargetsRight.forEach((rightElement) => {
|
||||
if (leftElement.workbasketId === rightElement.workbasketId) {
|
||||
repeteadElemens = true;
|
||||
}
|
||||
});
|
||||
});
|
||||
expect(repeteadElemens).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should reset distribution target and distribution target selected on reset', () => {
|
||||
component.distributionTargetsLeft.push(createWorkbasketSummary('id4', '', '', '', '', '', '', '', '', '', ''));
|
||||
component.distributionTargetsRight.push(createWorkbasketSummary('id5', '', '', '', '', '', '', '', '', '', ''));
|
||||
|
||||
expect(component.distributionTargetsLeft.length).toBe(3);
|
||||
expect(component.distributionTargetsRight.length).toBe(3);
|
||||
|
||||
component.onClear();
|
||||
fixture.detectChanges();
|
||||
expect(component.distributionTargetsLeft.length).toBe(2);
|
||||
expect(component.distributionTargetsRight.length).toBe(0);
|
||||
});
|
||||
});
|
|
@ -1,171 +0,0 @@
|
|||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { WorkbasketService } from 'app/shared/services/workbasket/workbasket.service';
|
||||
import { FormsModule } from '@angular/forms';
|
||||
import { AngularSvgIconModule } from 'angular-svg-icon';
|
||||
import { HttpClientModule } from '@angular/common/http';
|
||||
import { RouterTestingModule } from '@angular/router/testing';
|
||||
import { Component } from '@angular/core';
|
||||
import { Routes } from '@angular/router';
|
||||
|
||||
import { Workbasket } from 'app/shared/models/workbasket';
|
||||
import { ICONTYPES } from 'app/shared/models/icon-types';
|
||||
import { Links } from 'app/shared/models/links';
|
||||
|
||||
import { SavingWorkbasketService } from 'app/administration/services/saving-workbaskets.service';
|
||||
import { RequestInProgressService } from 'app/shared/services/request-in-progress/request-in-progress.service';
|
||||
import { configureTests } from 'app/app.test.configuration';
|
||||
import { FormsValidatorService } from 'app/shared/services/forms-validator/forms-validator.service';
|
||||
import { NgxsModule } from '@ngxs/store';
|
||||
import { WorkbasketInformationComponent } from './workbasket-information.component';
|
||||
import { NotificationService } from '../../../shared/services/notifications/notification.service';
|
||||
|
||||
@Component({
|
||||
selector: 'taskana-dummy-detail',
|
||||
template: 'dummydetail'
|
||||
})
|
||||
export class DummyDetailComponent {}
|
||||
|
||||
const routes: Routes = [
|
||||
{ path: ':id', component: DummyDetailComponent, outlet: 'detail' },
|
||||
{ path: 'someNewId', component: DummyDetailComponent }
|
||||
];
|
||||
|
||||
describe('WorkbasketInformationComponent', () => {
|
||||
let component: WorkbasketInformationComponent;
|
||||
let fixture: ComponentFixture<WorkbasketInformationComponent>;
|
||||
let debugElement;
|
||||
let workbasketService;
|
||||
let alertService;
|
||||
let savingWorkbasketService;
|
||||
let requestInProgressService;
|
||||
let formsValidatorService;
|
||||
|
||||
const configure = (testBed: TestBed) => {
|
||||
testBed.configureTestingModule({
|
||||
declarations: [WorkbasketInformationComponent, DummyDetailComponent],
|
||||
imports: [
|
||||
FormsModule,
|
||||
AngularSvgIconModule,
|
||||
HttpClientModule,
|
||||
RouterTestingModule.withRoutes(routes),
|
||||
NgxsModule.forRoot()
|
||||
],
|
||||
providers: [
|
||||
WorkbasketService,
|
||||
NotificationService,
|
||||
SavingWorkbasketService,
|
||||
RequestInProgressService,
|
||||
FormsValidatorService
|
||||
]
|
||||
});
|
||||
};
|
||||
|
||||
function createWorkbasket(
|
||||
workbasketId?,
|
||||
created?,
|
||||
key?,
|
||||
domain?,
|
||||
type?,
|
||||
modified?,
|
||||
name?,
|
||||
description?,
|
||||
owner?,
|
||||
custom1?,
|
||||
custom2?,
|
||||
custom3?,
|
||||
custom4?,
|
||||
orgLevel1?,
|
||||
orgLevel2?,
|
||||
orgLevel3?,
|
||||
orgLevel4?,
|
||||
_links?: Links,
|
||||
markedForDeletion?: boolean
|
||||
) {
|
||||
if (!type) {
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
type = 'PERSONAL';
|
||||
}
|
||||
const workbasket: Workbasket = {
|
||||
workbasketId,
|
||||
created,
|
||||
key,
|
||||
domain,
|
||||
type,
|
||||
modified,
|
||||
name,
|
||||
description,
|
||||
owner,
|
||||
custom1,
|
||||
custom2,
|
||||
custom3,
|
||||
custom4,
|
||||
orgLevel1,
|
||||
orgLevel2,
|
||||
orgLevel3,
|
||||
orgLevel4,
|
||||
markedForDeletion,
|
||||
_links
|
||||
};
|
||||
return workbasket;
|
||||
}
|
||||
|
||||
beforeEach((done) => {
|
||||
configureTests(configure).then((testBed) => {
|
||||
fixture = testBed.createComponent(WorkbasketInformationComponent);
|
||||
component = fixture.componentInstance;
|
||||
debugElement = fixture.debugElement.nativeElement;
|
||||
workbasketService = testBed.get(WorkbasketService);
|
||||
alertService = testBed.get(NotificationService);
|
||||
savingWorkbasketService = testBed.get(SavingWorkbasketService);
|
||||
requestInProgressService = testBed.get(RequestInProgressService);
|
||||
|
||||
formsValidatorService = testBed.get(FormsValidatorService);
|
||||
|
||||
spyOn(alertService, 'showToast');
|
||||
fixture.detectChanges();
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
fixture.destroy();
|
||||
document.body.removeChild(debugElement);
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
|
||||
it('selectType should set workbasket.type to personal with 0 and group in other case', () => {
|
||||
component.workbasket = createWorkbasket('id1');
|
||||
expect(component.workbasket.type).toEqual('PERSONAL');
|
||||
component.selectType(ICONTYPES.GROUP);
|
||||
expect(component.workbasket.type).toEqual('GROUP');
|
||||
});
|
||||
|
||||
it('should create a copy of workbasket when workbasket is selected', () => {
|
||||
expect(component.workbasketClone).toBeUndefined();
|
||||
component.workbasket = createWorkbasket(
|
||||
'id',
|
||||
'created',
|
||||
'keyModified',
|
||||
'domain',
|
||||
ICONTYPES.TOPIC,
|
||||
'modified',
|
||||
'name',
|
||||
'description',
|
||||
'owner',
|
||||
'custom1',
|
||||
'custom2',
|
||||
'custom3',
|
||||
'custom4',
|
||||
'orgLevel1',
|
||||
'orgLevel2',
|
||||
'orgLevel3',
|
||||
'orgLevel4'
|
||||
);
|
||||
component.ngOnChanges(undefined);
|
||||
fixture.detectChanges();
|
||||
expect(component.workbasket.workbasketId).toEqual(component.workbasketClone.workbasketId);
|
||||
});
|
||||
});
|
|
@ -1,168 +0,0 @@
|
|||
import { Component, EventEmitter, Input, Output } from '@angular/core';
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { of } from 'rxjs';
|
||||
|
||||
import { AngularSvgIconModule } from 'angular-svg-icon';
|
||||
import { HttpClientModule } from '@angular/common/http';
|
||||
import { Routes } from '@angular/router';
|
||||
import { RouterTestingModule } from '@angular/router/testing';
|
||||
|
||||
import { WorkbasketSummary } from 'app/shared/models/workbasket-summary';
|
||||
import { WorkbasketSummaryRepresentation } from 'app/shared/models/workbasket-summary-representation';
|
||||
import { LinksWorkbasketSummary } from 'app/shared/models/links-workbasket-summary';
|
||||
|
||||
import { ImportExportComponent } from 'app/administration/components/import-export/import-export.component';
|
||||
|
||||
import { WorkbasketDefinitionService } from 'app/administration/services/workbasket-definition.service';
|
||||
import { ClassificationDefinitionService } from 'app/administration/services/classification-definition.service';
|
||||
import { WorkbasketService } from 'app/shared/services/workbasket/workbasket.service';
|
||||
import { OrientationService } from 'app/shared/services/orientation/orientation.service';
|
||||
import { configureTests } from 'app/app.test.configuration';
|
||||
import { Page } from 'app/shared/models/page';
|
||||
import { ImportExportService } from 'app/administration/services/import-export.service';
|
||||
import { NgxsModule } from '@ngxs/store';
|
||||
import { WorkbasketListToolbarComponent } from '../workbasket-list-toolbar/workbasket-list-toolbar.component';
|
||||
import { WorkbasketListComponent } from './workbasket-list.component';
|
||||
|
||||
@Component({
|
||||
selector: 'taskana-dummy-detail',
|
||||
template: 'dummydetail'
|
||||
})
|
||||
class DummyDetailComponent {}
|
||||
|
||||
@Component({
|
||||
selector: 'taskana-pagination',
|
||||
template: 'dummydetail'
|
||||
})
|
||||
class PaginationComponent {
|
||||
@Input()
|
||||
page: Page;
|
||||
|
||||
@Output()
|
||||
workbasketsResourceChange = new EventEmitter<any>();
|
||||
|
||||
@Output() changePage = new EventEmitter<any>();
|
||||
}
|
||||
|
||||
function createWorkbasketSummary(
|
||||
workbasketId,
|
||||
key,
|
||||
name,
|
||||
domain,
|
||||
type,
|
||||
description,
|
||||
owner,
|
||||
custom1,
|
||||
custom2,
|
||||
custom3,
|
||||
custom4
|
||||
) {
|
||||
const workbasketSummary: WorkbasketSummary = {
|
||||
workbasketId,
|
||||
key,
|
||||
name,
|
||||
domain,
|
||||
type,
|
||||
description,
|
||||
owner,
|
||||
custom1,
|
||||
custom2,
|
||||
custom3,
|
||||
custom4
|
||||
};
|
||||
return workbasketSummary;
|
||||
}
|
||||
const workbasketSummaryResource: WorkbasketSummaryRepresentation = {
|
||||
workbaskets: [
|
||||
createWorkbasketSummary('1', 'key1', 'NAME1', '', 'PERSONAL', 'description 1', 'owner1', '', '', '', ''),
|
||||
createWorkbasketSummary('2', 'key2', 'NAME2', '', 'PERSONAL', 'description 2', 'owner2', '', '', '', '')
|
||||
],
|
||||
_links: new LinksWorkbasketSummary({ href: 'url' }),
|
||||
page: {}
|
||||
};
|
||||
|
||||
describe('WorkbasketListComponent', () => {
|
||||
let component: WorkbasketListComponent;
|
||||
let fixture: ComponentFixture<WorkbasketListComponent>;
|
||||
let debugElement: any;
|
||||
let workbasketService: WorkbasketService;
|
||||
let workbasketSummarySpy;
|
||||
|
||||
const routes: Routes = [
|
||||
{ path: ':id', component: DummyDetailComponent, outlet: 'detail' },
|
||||
{ path: 'workbaskets', component: DummyDetailComponent }
|
||||
];
|
||||
|
||||
beforeEach((done) => {
|
||||
const configure = (testBed: TestBed) => {
|
||||
testBed.configureTestingModule({
|
||||
declarations: [
|
||||
WorkbasketListComponent,
|
||||
DummyDetailComponent,
|
||||
WorkbasketListToolbarComponent,
|
||||
ImportExportComponent
|
||||
],
|
||||
imports: [AngularSvgIconModule, HttpClientModule, RouterTestingModule.withRoutes(routes), NgxsModule.forRoot()],
|
||||
providers: [
|
||||
WorkbasketService,
|
||||
WorkbasketDefinitionService,
|
||||
ClassificationDefinitionService,
|
||||
OrientationService,
|
||||
ImportExportService
|
||||
]
|
||||
});
|
||||
};
|
||||
configureTests(configure).then((testBed) => {
|
||||
fixture = TestBed.createComponent(WorkbasketListComponent);
|
||||
component = fixture.componentInstance;
|
||||
Object.defineProperty(component, 'workbasketsSummaryRepresentation$', { writable: true });
|
||||
const page = {
|
||||
workbaskets: [],
|
||||
_links: {},
|
||||
page: new Page(6, 3, 3, 1)
|
||||
};
|
||||
component.workbasketsSummaryRepresentation$ = of(page);
|
||||
debugElement = fixture.debugElement.nativeElement;
|
||||
workbasketService = TestBed.get(WorkbasketService);
|
||||
const orientationService = TestBed.get(OrientationService);
|
||||
workbasketSummarySpy = spyOn(workbasketService, 'getWorkBasketsSummary').and.returnValue(
|
||||
of(workbasketSummaryResource)
|
||||
);
|
||||
spyOn(workbasketService, 'getSelectedWorkBasket').and.returnValue(of('2'));
|
||||
spyOn(orientationService, 'getOrientation').and.returnValue(of(undefined));
|
||||
|
||||
fixture.detectChanges();
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
fixture.detectChanges();
|
||||
document.body.removeChild(debugElement);
|
||||
});
|
||||
|
||||
it('should be created', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
|
||||
it(
|
||||
'should have wb-action-toolbar, wb-search-bar, wb-list-container, wb-pagination,' +
|
||||
' collapsedMenufilterWb and taskana-filter created in the html',
|
||||
() => {
|
||||
expect(debugElement.querySelector('#wb-action-toolbar')).toBeDefined();
|
||||
expect(debugElement.querySelector('#wb-search-bar')).toBeDefined();
|
||||
expect(debugElement.querySelector('#wb-pagination')).toBeDefined();
|
||||
expect(debugElement.querySelector('#wb-list-container')).toBeDefined();
|
||||
expect(debugElement.querySelector('#collapsedMenufilterWb')).toBeDefined();
|
||||
expect(debugElement.querySelector('taskana-filter')).toBeDefined();
|
||||
}
|
||||
);
|
||||
|
||||
it('should have rendered sort by: name, id, description, owner and type', () => {
|
||||
expect(debugElement.querySelector('#sort-by-name')).toBeDefined();
|
||||
expect(debugElement.querySelector('#sort-by-key')).toBeDefined();
|
||||
expect(debugElement.querySelector('#sort-by-description')).toBeDefined();
|
||||
expect(debugElement.querySelector('#sort-by-owner')).toBeDefined();
|
||||
expect(debugElement.querySelector('#sort-by-type')).toBeDefined();
|
||||
});
|
||||
});
|
|
@ -1,60 +0,0 @@
|
|||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { RouterTestingModule } from '@angular/router/testing';
|
||||
import { Routes } from '@angular/router';
|
||||
import { NgxsModule } from '@ngxs/store';
|
||||
import { Component, NO_ERRORS_SCHEMA } from '@angular/core';
|
||||
import { Location } from '@angular/common';
|
||||
import { WorkbasketOverviewComponent } from './workbasket-overview.component';
|
||||
|
||||
@Component({
|
||||
selector: 'taskana-dummy-detail',
|
||||
template: 'dummydetail'
|
||||
})
|
||||
export class DummyDetailComponent {}
|
||||
@Component({
|
||||
selector: 'taskana-workbasket-list',
|
||||
template: 'dummylist'
|
||||
})
|
||||
export class DummyListComponent {}
|
||||
describe('WorkbasketOverviewComponent', () => {
|
||||
let debugElement: any;
|
||||
let component: WorkbasketOverviewComponent;
|
||||
let fixture: ComponentFixture<WorkbasketOverviewComponent>;
|
||||
const locationSpy: jasmine.SpyObj<Location> = jasmine.createSpyObj('Location', ['go']);
|
||||
const routes: Routes = [{ path: ':id', component: DummyDetailComponent }];
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [RouterTestingModule.withRoutes(routes), NgxsModule.forRoot()],
|
||||
declarations: [WorkbasketOverviewComponent, DummyDetailComponent, DummyListComponent],
|
||||
providers: [{ provide: Location, useValue: locationSpy }],
|
||||
schemas: [NO_ERRORS_SCHEMA]
|
||||
}).compileComponents();
|
||||
}));
|
||||
|
||||
afterEach(() => {
|
||||
fixture.destroy();
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(WorkbasketOverviewComponent);
|
||||
component = fixture.componentInstance;
|
||||
debugElement = fixture.debugElement.nativeElement;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should not display detail component if showDetail is false', () => {
|
||||
component.showDetail = false;
|
||||
expect(debugElement.querySelector('taskana-administration-workbasket-details')).toBeNull();
|
||||
});
|
||||
|
||||
it('should display detail component if showDetail is true', () => {
|
||||
component.showDetail = true;
|
||||
fixture.detectChanges();
|
||||
expect(debugElement.querySelector('taskana-administration-workbasket-details')).toBeTruthy();
|
||||
});
|
||||
});
|
|
@ -1,15 +0,0 @@
|
|||
import { TestBed, inject } from '@angular/core/testing';
|
||||
|
||||
import { SavingWorkbasketService } from './saving-workbaskets.service';
|
||||
|
||||
describe('SavingWorkbasketsService', () => {
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
providers: [SavingWorkbasketService]
|
||||
});
|
||||
});
|
||||
|
||||
it('should be created', inject([SavingWorkbasketService], (service: SavingWorkbasketService) => {
|
||||
expect(service).toBeTruthy();
|
||||
}));
|
||||
});
|
|
@ -1,51 +0,0 @@
|
|||
import { async, inject, TestBed } from '@angular/core/testing';
|
||||
import { Router, Routes } from '@angular/router';
|
||||
import { AngularSvgIconModule } from 'angular-svg-icon';
|
||||
import { RouterTestingModule } from '@angular/router/testing';
|
||||
import { HttpClientModule } from '@angular/common/http';
|
||||
import { SharedModule } from 'app/shared/shared.module';
|
||||
import { AppComponent } from './app.component';
|
||||
|
||||
import { NavBarComponent } from './shared/components/nav-bar/nav-bar.component';
|
||||
|
||||
describe('AppComponent', () => {
|
||||
let app;
|
||||
let fixture;
|
||||
let debugElement;
|
||||
|
||||
const routes: Routes = [{ path: 'classifications', component: AppComponent }];
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [AppComponent, NavBarComponent],
|
||||
imports: [AngularSvgIconModule, RouterTestingModule.withRoutes(routes), HttpClientModule, SharedModule]
|
||||
}).compileComponents();
|
||||
|
||||
fixture = TestBed.createComponent(AppComponent);
|
||||
app = fixture.debugElement.componentInstance;
|
||||
debugElement = fixture.debugElement.nativeElement;
|
||||
}));
|
||||
|
||||
afterEach(async(() => {
|
||||
document.body.removeChild(debugElement);
|
||||
}));
|
||||
|
||||
it('should create the app', () => {
|
||||
expect(app).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should render title in a <a> tag', () => {
|
||||
fixture.detectChanges();
|
||||
expect(debugElement.querySelector('ul p a').textContent).toContain('Taskana administration');
|
||||
});
|
||||
|
||||
it('should call Router.navigateByUrl("classifications") and workbasketRoute should be false', inject(
|
||||
[Router],
|
||||
(router: Router) => {
|
||||
expect(app.workbasketsRoute).toBe(true);
|
||||
fixture.detectChanges();
|
||||
router.navigateByUrl('/classifications');
|
||||
expect(app.workbasketsRoute).toBe(false);
|
||||
}
|
||||
));
|
||||
});
|
|
@ -1,13 +0,0 @@
|
|||
import { HistoryModule } from './history.module';
|
||||
|
||||
describe('HistoryModule', () => {
|
||||
let historyModule: HistoryModule;
|
||||
|
||||
beforeEach(() => {
|
||||
historyModule = new HistoryModule();
|
||||
});
|
||||
|
||||
it('should create an instance', () => {
|
||||
expect(historyModule).toBeTruthy();
|
||||
});
|
||||
});
|
|
@ -1,15 +0,0 @@
|
|||
import { TestBed, inject } from '@angular/core/testing';
|
||||
|
||||
import { TaskQueryService } from './task-query.service';
|
||||
|
||||
describe('TaskQueryService', () => {
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
providers: [TaskQueryService]
|
||||
});
|
||||
});
|
||||
|
||||
it('should be created', inject([TaskQueryService], (service: TaskQueryService) => {
|
||||
expect(service).toBeTruthy();
|
||||
}));
|
||||
});
|
|
@ -1,24 +0,0 @@
|
|||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { TaskQueryComponent } from './task-query.component';
|
||||
|
||||
describe('TaskQueryComponent', () => {
|
||||
let component: TaskQueryComponent;
|
||||
let fixture: ComponentFixture<TaskQueryComponent>;
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [TaskQueryComponent]
|
||||
}).compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(TaskQueryComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
|
@ -1,24 +0,0 @@
|
|||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { ClassificationReportComponent } from './classification-report.component';
|
||||
|
||||
describe('ClassificationReportComponent', () => {
|
||||
let component: ClassificationReportComponent;
|
||||
let fixture: ComponentFixture<ClassificationReportComponent>;
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ClassificationReportComponent]
|
||||
}).compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(ClassificationReportComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
|
@ -1,24 +0,0 @@
|
|||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { TaskReportComponent } from './task-report.component';
|
||||
|
||||
describe('TaskReportComponent', () => {
|
||||
let component: TaskReportComponent;
|
||||
let fixture: ComponentFixture<TaskReportComponent>;
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [TaskReportComponent]
|
||||
}).compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(TaskReportComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should be created', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
|
@ -1,24 +0,0 @@
|
|||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { WorkbasketReportDueDateComponent } from './workbasket-report-due-date.component';
|
||||
|
||||
describe('WorkbasketReportDueDateComponent', () => {
|
||||
let component: WorkbasketReportDueDateComponent;
|
||||
let fixture: ComponentFixture<WorkbasketReportDueDateComponent>;
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [WorkbasketReportDueDateComponent]
|
||||
}).compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(WorkbasketReportDueDateComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should be created', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
|
@ -1,24 +0,0 @@
|
|||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { WorkbasketReportPlannedDateComponent } from './workbasket-report-planned-date.component';
|
||||
|
||||
describe('WorkbasketReportPlannedDateComponent', () => {
|
||||
let component: WorkbasketReportPlannedDateComponent;
|
||||
let fixture: ComponentFixture<WorkbasketReportPlannedDateComponent>;
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [WorkbasketReportPlannedDateComponent]
|
||||
}).compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(WorkbasketReportPlannedDateComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
|
@ -1,24 +0,0 @@
|
|||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { WorkbasketReportComponent } from './workbasket-report.component';
|
||||
|
||||
describe('WorkbasketReportComponent', () => {
|
||||
let component: WorkbasketReportComponent;
|
||||
let fixture: ComponentFixture<WorkbasketReportComponent>;
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [WorkbasketReportComponent]
|
||||
}).compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(WorkbasketReportComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
|
@ -1,15 +0,0 @@
|
|||
import { TestBed, inject } from '@angular/core/testing';
|
||||
|
||||
import { RestConnectorService } from './rest-connector.service';
|
||||
|
||||
describe('RestConnectorService', () => {
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
providers: [RestConnectorService]
|
||||
});
|
||||
});
|
||||
|
||||
it('should be created', inject([RestConnectorService], (service: RestConnectorService) => {
|
||||
expect(service).toBeTruthy();
|
||||
}));
|
||||
});
|
|
@ -1,59 +0,0 @@
|
|||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import {
|
||||
BsDatepickerModule,
|
||||
BsDatepickerConfig,
|
||||
ComponentLoaderFactory,
|
||||
PositioningService,
|
||||
BsLocaleService
|
||||
} from 'ngx-bootstrap';
|
||||
import { DatePickerComponent } from './date-picker.component';
|
||||
|
||||
describe('DatePickerComponent', () => {
|
||||
let component: DatePickerComponent;
|
||||
let fixture: ComponentFixture<DatePickerComponent>;
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [BsDatepickerModule],
|
||||
declarations: [DatePickerComponent],
|
||||
providers: [BsDatepickerConfig, ComponentLoaderFactory, PositioningService, BsLocaleService]
|
||||
}).compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(DatePickerComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should receive the input properties', () => {
|
||||
component.placeholder = 'placeholder';
|
||||
component.value = '01/01/2019';
|
||||
component.id = 'id';
|
||||
component.name = 'name';
|
||||
expect(component.placeholder).toBe('placeholder');
|
||||
expect(component.value).toBe('01/01/2019');
|
||||
expect(component.id).toBe('id');
|
||||
expect(component.name).toBe('name');
|
||||
});
|
||||
|
||||
it('should all properties have a value', () => {
|
||||
component.placeholder = 'test';
|
||||
component.value = '01/01/2019';
|
||||
component.id = 'id';
|
||||
component.name = 'name';
|
||||
expect(component.placeholder).not.toBeNull('');
|
||||
expect(component.placeholder).not.toBeNaN();
|
||||
expect(component.value).not.toBeNull('');
|
||||
expect(component.value).not.toBeNaN();
|
||||
expect(component.id).not.toBeNull('');
|
||||
expect(component.id).not.toBeNaN();
|
||||
expect(component.name).not.toBeNull('');
|
||||
expect(component.name).not.toBeNaN();
|
||||
});
|
||||
});
|
|
@ -1,24 +0,0 @@
|
|||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { FieldErrorDisplayComponent } from './field-error-display.component';
|
||||
|
||||
describe('FieldErrorDisplayComponent', () => {
|
||||
let component: FieldErrorDisplayComponent;
|
||||
let fixture: ComponentFixture<FieldErrorDisplayComponent>;
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [FieldErrorDisplayComponent]
|
||||
}).compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(FieldErrorDisplayComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
|
@ -1,77 +0,0 @@
|
|||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { FormsModule } from '@angular/forms';
|
||||
import { AngularSvgIconModule } from 'angular-svg-icon';
|
||||
import { HttpClientModule } from '@angular/common/http';
|
||||
|
||||
import { configureTests } from 'app/app.test.configuration';
|
||||
import { MatSnackBar } from '@angular/material/snack-bar';
|
||||
import { Overlay } from '@angular/cdk/overlay';
|
||||
import { FilterComponent } from './filter.component';
|
||||
|
||||
describe('FilterComponent', () => {
|
||||
let component: FilterComponent;
|
||||
let fixture: ComponentFixture<FilterComponent>;
|
||||
let debugElement: any;
|
||||
|
||||
beforeEach((done) => {
|
||||
const configure = (testBed: TestBed) => {
|
||||
testBed.configureTestingModule({
|
||||
providers: [MatSnackBar, Overlay],
|
||||
imports: [AngularSvgIconModule, FormsModule, HttpClientModule]
|
||||
});
|
||||
};
|
||||
configureTests(configure).then((testBed) => {
|
||||
fixture = TestBed.createComponent(FilterComponent);
|
||||
component = fixture.componentInstance;
|
||||
component.filterParams = {
|
||||
name: 'someName',
|
||||
owner: 'someOwner',
|
||||
description: 'someDescription',
|
||||
key: 'someKey',
|
||||
type: 'PERSONAL'
|
||||
};
|
||||
debugElement = fixture.debugElement.nativeElement;
|
||||
fixture.detectChanges();
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
document.body.removeChild(debugElement);
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should create a component', () => {
|
||||
expect(debugElement.querySelector('#some-id')).toBeNull();
|
||||
fixture.detectChanges();
|
||||
expect(debugElement.querySelector('#some-id')).toBeDefined();
|
||||
});
|
||||
|
||||
it('should have filter by: name, description, key, owner and type defined', () => {
|
||||
expect(debugElement.querySelector('#display-name-filter')).toBeDefined();
|
||||
expect(debugElement.querySelector('#display-description-filter')).toBeDefined();
|
||||
expect(debugElement.querySelector('#display-key-filter')).toBeDefined();
|
||||
expect(debugElement.querySelector('#display-owner-filter')).toBeDefined();
|
||||
expect(debugElement.querySelector('#display-type-filter')).toBeDefined();
|
||||
});
|
||||
|
||||
it('should be able to clear all fields after pressing clear button', () => {
|
||||
component.filterParams = {
|
||||
name: 'someName',
|
||||
owner: 'someOwner',
|
||||
description: 'someDescription',
|
||||
key: 'someKey',
|
||||
type: 'PERSONAL'
|
||||
};
|
||||
fixture.detectChanges();
|
||||
debugElement.querySelector('[title="Clear"]').click();
|
||||
expect(component.filter.filterParams.name).toBe('');
|
||||
expect(component.filter.filterParams.description).toBe('');
|
||||
expect(component.filter.filterParams.owner).toBe('');
|
||||
expect(component.filter.filterParams.type).toBe('');
|
||||
expect(component.filter.filterParams.key).toBe('');
|
||||
});
|
||||
});
|
|
@ -1,92 +0,0 @@
|
|||
import { Component } from '@angular/core';
|
||||
import { TestBed, async } from '@angular/core/testing';
|
||||
import { RouterTestingModule } from '@angular/router/testing';
|
||||
import { Router, Routes } from '@angular/router';
|
||||
import { AngularSvgIconModule } from 'angular-svg-icon';
|
||||
import { HttpClientModule } from '@angular/common/http';
|
||||
import { MasterAndDetailService } from '../../services/master-and-detail/master-and-detail.service';
|
||||
|
||||
import { MasterAndDetailComponent } from './master-and-detail.component';
|
||||
|
||||
@Component({
|
||||
selector: 'taskana-dummy-master',
|
||||
template: 'dummymaster'
|
||||
})
|
||||
export class DummyMasterComponent {}
|
||||
|
||||
@Component({
|
||||
selector: 'taskana-dummy-detail',
|
||||
template: 'dummydetail'
|
||||
})
|
||||
export class DummyDetailComponent {}
|
||||
|
||||
describe('MasterAndDetailComponent ', () => {
|
||||
let component;
|
||||
let fixture;
|
||||
let debugElement;
|
||||
let router;
|
||||
|
||||
const routes: Routes = [
|
||||
{
|
||||
path: 'workbaskets',
|
||||
component: MasterAndDetailComponent,
|
||||
children: [
|
||||
{
|
||||
path: '',
|
||||
component: DummyMasterComponent,
|
||||
outlet: 'master'
|
||||
},
|
||||
{
|
||||
path: ':id',
|
||||
component: DummyDetailComponent,
|
||||
outlet: 'detail'
|
||||
}
|
||||
]
|
||||
}
|
||||
];
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [MasterAndDetailComponent, DummyMasterComponent, DummyDetailComponent],
|
||||
imports: [RouterTestingModule.withRoutes(routes), AngularSvgIconModule, HttpClientModule],
|
||||
providers: [MasterAndDetailService]
|
||||
}).compileComponents();
|
||||
|
||||
fixture = TestBed.createComponent(MasterAndDetailComponent);
|
||||
component = fixture.debugElement.componentInstance;
|
||||
debugElement = fixture.debugElement.nativeElement;
|
||||
router = TestBed.get(Router);
|
||||
router.initialNavigation();
|
||||
}));
|
||||
|
||||
afterEach(async(() => {
|
||||
document.body.removeChild(debugElement);
|
||||
}));
|
||||
|
||||
it('should be created', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should call Router.navigateByUrl("/wokbaskets") and showDetail property should be false', async(() => {
|
||||
expect(component.showDetail).toBe(false);
|
||||
fixture.detectChanges();
|
||||
router.navigateByUrl('/workbaskets');
|
||||
expect(component.showDetail).toBe(false);
|
||||
}));
|
||||
|
||||
it('should call Router.navigateByUrl("/wokbaskets/(detail:Id)") and showDetail property should be true', async(() => {
|
||||
expect(component.showDetail).toBe(false);
|
||||
fixture.detectChanges();
|
||||
router.navigateByUrl('/workbaskets/(detail:2)');
|
||||
expect(component.showDetail).toBe(true);
|
||||
}));
|
||||
|
||||
it('should navigate to parent state when backIsClicked', async(() => {
|
||||
const spy = spyOn(router, 'navigateByUrl');
|
||||
router.navigateByUrl('/workbaskets/(detail:2)');
|
||||
fixture.detectChanges();
|
||||
expect(spy.calls.first().args[0]).toBe('/workbaskets/(detail:2)');
|
||||
component.backClicked();
|
||||
expect(spy.calls.mostRecent().args.length).toBe(2);
|
||||
}));
|
||||
});
|
|
@ -1,67 +0,0 @@
|
|||
import { Routes } from '@angular/router';
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { RouterTestingModule } from '@angular/router/testing';
|
||||
import { AngularSvgIconModule } from 'angular-svg-icon';
|
||||
import { HttpClientModule } from '@angular/common/http';
|
||||
import { SharedModule } from 'app/shared/shared.module';
|
||||
|
||||
import { UserInformationComponent } from 'app/shared/components/user-information/user-information.component';
|
||||
|
||||
import { SelectedRouteService } from 'app/shared/services/selected-route/selected-route';
|
||||
import { BusinessAdminGuard } from 'app/shared/guards/business-admin.guard';
|
||||
import { MonitorGuard } from 'app/shared/guards/monitor.guard';
|
||||
import { WindowRefService } from 'app/shared/services/window/window.service';
|
||||
import { RequestInProgressService } from 'app/shared/services/request-in-progress/request-in-progress.service';
|
||||
|
||||
import { configureTests } from 'app/app.test.configuration';
|
||||
import { MatSnackBar } from '@angular/material/snack-bar';
|
||||
import { Overlay } from '@angular/cdk/overlay';
|
||||
import { NavBarComponent } from './nav-bar.component';
|
||||
|
||||
describe('NavBarComponent', () => {
|
||||
let component: NavBarComponent;
|
||||
let fixture: ComponentFixture<NavBarComponent>;
|
||||
let debugElement;
|
||||
let navBar;
|
||||
|
||||
const routes: Routes = [{ path: 'classifications', component: NavBarComponent }];
|
||||
|
||||
beforeEach((done) => {
|
||||
const configure = (testBed: TestBed) => {
|
||||
testBed.configureTestingModule({
|
||||
declarations: [NavBarComponent, UserInformationComponent],
|
||||
imports: [AngularSvgIconModule, HttpClientModule, RouterTestingModule.withRoutes(routes), SharedModule],
|
||||
providers: [
|
||||
SelectedRouteService,
|
||||
BusinessAdminGuard,
|
||||
MonitorGuard,
|
||||
WindowRefService,
|
||||
RequestInProgressService,
|
||||
MatSnackBar,
|
||||
Overlay
|
||||
]
|
||||
});
|
||||
};
|
||||
configureTests(configure).then((testBed) => {
|
||||
fixture = TestBed.createComponent(NavBarComponent);
|
||||
component = fixture.componentInstance;
|
||||
debugElement = fixture.debugElement.nativeElement;
|
||||
navBar = fixture.debugElement.componentInstance;
|
||||
fixture.detectChanges();
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
fixture.detectChanges();
|
||||
document.body.removeChild(debugElement);
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
|
||||
it("should have as title ''", () => {
|
||||
expect(navBar.title).toEqual('');
|
||||
});
|
||||
});
|
|
@ -1,36 +0,0 @@
|
|||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { RouterTestingModule } from '@angular/router/testing';
|
||||
import { AngularSvgIconModule } from 'angular-svg-icon';
|
||||
import { HttpClientModule } from '@angular/common/http';
|
||||
import { configureTests } from 'app/app.test.configuration';
|
||||
import { NoAccessComponent } from './no-access.component';
|
||||
|
||||
describe('NoAccessComponent', () => {
|
||||
let component: NoAccessComponent;
|
||||
let fixture: ComponentFixture<NoAccessComponent>;
|
||||
let debugElement;
|
||||
|
||||
beforeEach((done) => {
|
||||
const configure = (testBed: TestBed) => {
|
||||
testBed.configureTestingModule({
|
||||
imports: [RouterTestingModule, AngularSvgIconModule, HttpClientModule],
|
||||
declarations: [NoAccessComponent]
|
||||
});
|
||||
};
|
||||
configureTests(configure).then((testBed) => {
|
||||
fixture = TestBed.createComponent(NoAccessComponent);
|
||||
component = fixture.componentInstance;
|
||||
debugElement = fixture.debugElement.nativeElement;
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
document.body.removeChild(debugElement);
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
|
@ -1,115 +0,0 @@
|
|||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { SimpleChange } from '@angular/core';
|
||||
import { FormsModule } from '@angular/forms';
|
||||
import { SharedModule } from 'app/shared/shared.module';
|
||||
|
||||
import { Page } from 'app/shared/models/page';
|
||||
import { configureTests } from 'app/app.test.configuration';
|
||||
import { PaginationComponent } from './pagination.component';
|
||||
|
||||
describe('PaginationComponent', () => {
|
||||
let component: PaginationComponent;
|
||||
let fixture: ComponentFixture<PaginationComponent>;
|
||||
let debugElement;
|
||||
|
||||
beforeEach((done) => {
|
||||
const configure = (testBed: TestBed) => {
|
||||
testBed.configureTestingModule({
|
||||
imports: [FormsModule, SharedModule]
|
||||
});
|
||||
};
|
||||
configureTests(configure).then((testBed) => {
|
||||
fixture = TestBed.createComponent(PaginationComponent);
|
||||
component = fixture.componentInstance;
|
||||
component.page = new Page(6, 3, 3, 1);
|
||||
debugElement = fixture.debugElement.nativeElement;
|
||||
fixture.detectChanges();
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
fixture.detectChanges();
|
||||
document.body.removeChild(debugElement);
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should create 3 pages if total pages are 3', () => {
|
||||
component.page = new Page(6, 3, 3, 1);
|
||||
fixture.detectChanges();
|
||||
expect(debugElement.querySelectorAll('#wb-pagination > li').length).toBe(5);
|
||||
});
|
||||
|
||||
it('should emit change if previous page was different than current one', () => {
|
||||
component.page = new Page(6, 3, 3, 1);
|
||||
component.previousPageSelected = 2;
|
||||
fixture.detectChanges();
|
||||
component.changePage.subscribe((value) => {
|
||||
expect(value).toBe(1);
|
||||
});
|
||||
component.changeToPage(1);
|
||||
});
|
||||
|
||||
it('should not emit change if previous page was the same than current one', () => {
|
||||
component.page = new Page(6, 3, 3, 1);
|
||||
component.previousPageSelected = 2;
|
||||
fixture.detectChanges();
|
||||
component.changePage.subscribe((value) => {
|
||||
expect(false).toBe(true);
|
||||
});
|
||||
component.changeToPage(2);
|
||||
});
|
||||
|
||||
it('should emit totalPages if page is more than page.totalPages', () => {
|
||||
component.page = new Page(6, 3, 3, 1);
|
||||
component.previousPageSelected = 2;
|
||||
fixture.detectChanges();
|
||||
component.changePage.subscribe((value) => {
|
||||
expect(value).toBe(3);
|
||||
});
|
||||
component.changeToPage(100);
|
||||
});
|
||||
|
||||
it('should emit 1 if page is less than 1', () => {
|
||||
component.page = new Page(6, 3, 3, 1);
|
||||
component.previousPageSelected = 2;
|
||||
fixture.detectChanges();
|
||||
component.changePage.subscribe((value) => {
|
||||
expect(value).toBe(1);
|
||||
});
|
||||
component.changeToPage(0);
|
||||
});
|
||||
|
||||
it('should change pageSelected onChanges', () => {
|
||||
expect(component.pageSelected).toBe(1);
|
||||
component.ngOnChanges({
|
||||
page: new SimpleChange(null, new Page(6, 3, 3, 2), true)
|
||||
});
|
||||
fixture.detectChanges();
|
||||
expect(component.pageSelected).toBe(2);
|
||||
});
|
||||
|
||||
it('should getPagesTextToShow return 7 of 13 with size < totalElements', () => {
|
||||
component.page = new Page(7, 13, 3, 2);
|
||||
component.type = 'workbaskets';
|
||||
component.numberOfItems = 5;
|
||||
expect(component.getPagesTextToShow()).toBe(component.numberOfItems.toString().concat(' of 13 workbaskets'));
|
||||
});
|
||||
|
||||
it('should getPagesTextToShow return 6 of 6 with size > totalElements', () => {
|
||||
component.page = new Page(7, 6, 3, 2);
|
||||
component.type = 'tasks';
|
||||
component.numberOfItems = 6;
|
||||
expect(component.getPagesTextToShow()).toBe(component.numberOfItems.toString().concat(' of 6 tasks'));
|
||||
});
|
||||
|
||||
it('should getPagesTextToShow return of with totalElements = 0', () => {
|
||||
component.page = new Page(7, 0, 0, 0);
|
||||
component.type = 'workbaskets';
|
||||
component.numberOfItems = 0;
|
||||
expect(component.getPagesTextToShow()).toBe(component.numberOfItems.toString().concat(' of 0 workbaskets'));
|
||||
});
|
||||
});
|
|
@ -1,48 +0,0 @@
|
|||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { configureTests } from 'app/app.test.configuration';
|
||||
import { Direction } from 'app/shared/models/sorting';
|
||||
import { SortComponent } from './sort.component';
|
||||
|
||||
describe('SortComponent', () => {
|
||||
let component: SortComponent;
|
||||
let fixture: ComponentFixture<SortComponent>;
|
||||
let debugElement;
|
||||
|
||||
beforeEach((done) => {
|
||||
const configure = (testBed: TestBed) => {
|
||||
testBed.configureTestingModule({
|
||||
declarations: []
|
||||
});
|
||||
};
|
||||
configureTests(configure).then((testBed) => {
|
||||
fixture = TestBed.createComponent(SortComponent);
|
||||
component = fixture.componentInstance;
|
||||
debugElement = fixture.debugElement.nativeElement;
|
||||
fixture.detectChanges();
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
document.body.removeChild(debugElement);
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should change order when click on order ', () => {
|
||||
expect(component.sort.sortDirection).toBe(Direction.ASC);
|
||||
debugElement.querySelector('#sort-by-direction-desc').click();
|
||||
expect(component.sort.sortDirection).toBe(Direction.DESC);
|
||||
});
|
||||
|
||||
it('should change sort by when click on sort by ', () => {
|
||||
component.sortingFields = new Map<string, string>([['name', 'Name']]);
|
||||
fixture.detectChanges();
|
||||
expect(component.sort.sortBy).toBe('key');
|
||||
debugElement.querySelector('#sort-by-name-input').click();
|
||||
expect(component.sort.sortBy).toBe('name');
|
||||
});
|
||||
});
|
|
@ -1,39 +0,0 @@
|
|||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { AngularSvgIconModule } from 'angular-svg-icon';
|
||||
import { HttpClientModule } from '@angular/common/http';
|
||||
|
||||
import { configureTests } from 'app/app.test.configuration';
|
||||
import { MatSnackBar } from '@angular/material/snack-bar';
|
||||
import { Overlay } from '@angular/cdk/overlay';
|
||||
import { UserInformationComponent } from './user-information.component';
|
||||
|
||||
describe('UserInformationComponent', () => {
|
||||
let component: UserInformationComponent;
|
||||
let fixture: ComponentFixture<UserInformationComponent>;
|
||||
let debugElement;
|
||||
|
||||
beforeEach((done) => {
|
||||
const configure = (testBed: TestBed) => {
|
||||
testBed.configureTestingModule({
|
||||
imports: [AngularSvgIconModule, HttpClientModule],
|
||||
declarations: [UserInformationComponent],
|
||||
providers: [MatSnackBar, Overlay]
|
||||
});
|
||||
};
|
||||
configureTests(configure).then((testBed) => {
|
||||
fixture = TestBed.createComponent(UserInformationComponent);
|
||||
component = fixture.componentInstance;
|
||||
debugElement = fixture.debugElement.nativeElement;
|
||||
fixture.detectChanges();
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
document.body.removeChild(debugElement);
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
|
@ -4,7 +4,6 @@ import { Injectable } from '@angular/core';
|
|||
import { environment } from 'environments/environment';
|
||||
import { Observable } from 'rxjs';
|
||||
import { map } from 'rxjs/operators';
|
||||
import set from 'set-value';
|
||||
import { Customisation } from '../../models/customisation';
|
||||
|
||||
const customisationUrl = 'environments/data-sources/taskana-customization.json';
|
||||
|
@ -28,7 +27,15 @@ export class ClassificationCategoriesService {
|
|||
return this.httpClient.get<Customisation>(customisationUrl).pipe(
|
||||
map((customisation) => {
|
||||
Object.keys(customisation).forEach((lang) => {
|
||||
set(customisation[lang], 'classifications.categories.missing', missingIcon);
|
||||
if (customisation[lang]?.classifications?.categories) {
|
||||
customisation[lang].classifications.categories.missing = missingIcon;
|
||||
} else {
|
||||
if (customisation[lang]?.classifications) {
|
||||
customisation[lang].classifications.categories = { missing: missingIcon };
|
||||
} else {
|
||||
customisation[lang].classifications = { categories: { missing: missingIcon } };
|
||||
}
|
||||
}
|
||||
});
|
||||
return customisation;
|
||||
})
|
||||
|
|
|
@ -1,76 +0,0 @@
|
|||
import { ComponentFixture, async, TestBed } from '@angular/core/testing';
|
||||
import { FormsModule } from '@angular/forms';
|
||||
import { TypeaheadModule, ComponentLoaderFactory, PositioningService } from 'ngx-bootstrap';
|
||||
import { SortComponent } from 'app/shared/components/sort/sort.component';
|
||||
import { FilterComponent } from 'app/shared/components/filter/filter.component';
|
||||
import { MapValuesPipe } from 'app/shared/pipes/map-values.pipe';
|
||||
import { IconTypeComponent } from 'app/administration/components/type-icon/icon-type.component';
|
||||
import { SvgIconComponent } from 'angular-svg-icon';
|
||||
import { TaskService } from 'app/workplace/services/task.service';
|
||||
import { HttpClient, HttpClientModule } from '@angular/common/http';
|
||||
import { WorkbasketService } from 'app/shared/services/workbasket/workbasket.service';
|
||||
import { DomainService } from 'app/shared/services/domain/domain.service';
|
||||
import { RouterTestingModule } from '@angular/router/testing';
|
||||
import { Routes } from '@angular/router';
|
||||
import { Component } from '@angular/core';
|
||||
import { RequestInProgressService } from 'app/shared/services/request-in-progress/request-in-progress.service';
|
||||
import { SelectedRouteService } from 'app/shared/services/selected-route/selected-route';
|
||||
import { WorkplaceService } from 'app/workplace/services/workplace.service';
|
||||
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
|
||||
import { TaskListToolbarComponent } from './task-list-toolbar.component';
|
||||
|
||||
@Component({
|
||||
selector: 'taskana-dummy-detail',
|
||||
template: 'dummydetail'
|
||||
})
|
||||
export class DummyDetailComponent {}
|
||||
|
||||
// TODO: test pending to test. Failing random
|
||||
xdescribe('TasklistToolbarComponent', () => {
|
||||
let component: TaskListToolbarComponent;
|
||||
let fixture: ComponentFixture<TaskListToolbarComponent>;
|
||||
|
||||
const routes: Routes = [{ path: '*', component: DummyDetailComponent }];
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [
|
||||
TaskListToolbarComponent,
|
||||
SortComponent,
|
||||
FilterComponent,
|
||||
MapValuesPipe,
|
||||
IconTypeComponent,
|
||||
SvgIconComponent,
|
||||
DummyDetailComponent
|
||||
],
|
||||
imports: [
|
||||
FormsModule,
|
||||
TypeaheadModule,
|
||||
HttpClientModule,
|
||||
RouterTestingModule.withRoutes(routes),
|
||||
BrowserAnimationsModule
|
||||
],
|
||||
providers: [
|
||||
TaskService,
|
||||
HttpClient,
|
||||
WorkbasketService,
|
||||
DomainService,
|
||||
RequestInProgressService,
|
||||
SelectedRouteService,
|
||||
WorkplaceService,
|
||||
ComponentLoaderFactory,
|
||||
PositioningService
|
||||
]
|
||||
}).compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(TaskListToolbarComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should be created', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
|
@ -1,78 +0,0 @@
|
|||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { SvgIconComponent, SvgIconRegistryService } from 'angular-svg-icon';
|
||||
import { PaginationComponent } from 'app/shared/components/pagination/pagination.component';
|
||||
import { FormsModule } from '@angular/forms';
|
||||
import { TypeaheadModule, ComponentLoaderFactory, PositioningService } from 'ngx-bootstrap';
|
||||
import { SortComponent } from 'app/shared/components/sort/sort.component';
|
||||
import { FilterComponent } from 'app/shared/components/filter/filter.component';
|
||||
import { SpreadNumberPipe } from 'app/shared/pipes/spread-number.pipe';
|
||||
import { MapValuesPipe } from 'app/shared/pipes/map-values.pipe';
|
||||
import { IconTypeComponent } from 'app/administration/components/type-icon/icon-type.component';
|
||||
import { Component } from '@angular/core';
|
||||
import { HttpClient, HttpClientModule } from '@angular/common/http';
|
||||
import { OrientationService } from 'app/shared/services/orientation/orientation.service';
|
||||
import { WorkbasketService } from 'app/shared/services/workbasket/workbasket.service';
|
||||
import { DomainService } from 'app/shared/services/domain/domain.service';
|
||||
import { RequestInProgressService } from 'app/shared/services/request-in-progress/request-in-progress.service';
|
||||
import { SelectedRouteService } from 'app/shared/services/selected-route/selected-route';
|
||||
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
|
||||
import { WorkplaceService } from '../../services/workplace.service';
|
||||
import { TaskService } from '../../services/task.service';
|
||||
import { TaskListToolbarComponent } from '../task-list-toolbar/task-list-toolbar.component';
|
||||
import { TaskMasterComponent } from './task-master.component';
|
||||
import { NotificationService } from '../../../shared/services/notifications/notification.service';
|
||||
|
||||
@Component({
|
||||
selector: 'taskana-dummy-detail',
|
||||
template: 'dummydetail'
|
||||
})
|
||||
export class DummyDetailComponent {}
|
||||
|
||||
// TODO: test pending to test. Failing random
|
||||
xdescribe('TaskMasterComponent', () => {
|
||||
let component: TaskMasterComponent;
|
||||
let fixture: ComponentFixture<TaskMasterComponent>;
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [FormsModule, TypeaheadModule, HttpClientModule, BrowserAnimationsModule],
|
||||
declarations: [
|
||||
TaskMasterComponent,
|
||||
TaskListToolbarComponent,
|
||||
SvgIconComponent,
|
||||
PaginationComponent,
|
||||
SortComponent,
|
||||
FilterComponent,
|
||||
SpreadNumberPipe,
|
||||
MapValuesPipe,
|
||||
IconTypeComponent,
|
||||
DummyDetailComponent
|
||||
],
|
||||
providers: [
|
||||
TaskService,
|
||||
HttpClient,
|
||||
WorkplaceService,
|
||||
NotificationService,
|
||||
OrientationService,
|
||||
WorkbasketService,
|
||||
DomainService,
|
||||
RequestInProgressService,
|
||||
SelectedRouteService,
|
||||
ComponentLoaderFactory,
|
||||
PositioningService,
|
||||
SvgIconRegistryService
|
||||
]
|
||||
}).compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(TaskMasterComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should be created', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
|
@ -1,92 +0,0 @@
|
|||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { FormsModule } from '@angular/forms';
|
||||
import { ClassificationsService } from 'app/shared/services/classifications/classifications.service';
|
||||
import { HttpClient, HttpClientModule } from '@angular/common/http';
|
||||
import { ClassificationCategoriesService } from 'app/shared/services/classification-categories/classification-categories.service';
|
||||
import { DomainService } from 'app/shared/services/domain/domain.service';
|
||||
import { RouterTestingModule } from '@angular/router/testing';
|
||||
import { Routes } from '@angular/router';
|
||||
import { Component } from '@angular/core';
|
||||
import { RequestInProgressService } from 'app/shared/services/request-in-progress/request-in-progress.service';
|
||||
import { SelectedRouteService } from 'app/shared/services/selected-route/selected-route';
|
||||
import { configureTests } from 'app/app.test.configuration';
|
||||
import { ClassificationPagingList } from 'app/shared/models/classification-paging-list';
|
||||
import { TaskdetailsGeneralFieldsComponent } from './general-fields.component';
|
||||
|
||||
@Component({
|
||||
selector: 'taskana-dummy-detail',
|
||||
template: 'dummydetail'
|
||||
})
|
||||
export class DummyDetailComponent {}
|
||||
|
||||
// TODO: test pending to test. Failing random
|
||||
xdescribe('GeneralComponent', () => {
|
||||
let component: TaskdetailsGeneralFieldsComponent;
|
||||
let fixture: ComponentFixture<TaskdetailsGeneralFieldsComponent>;
|
||||
let classificationsService;
|
||||
|
||||
const routes: Routes = [{ path: '*', component: DummyDetailComponent }];
|
||||
|
||||
beforeEach((done) => {
|
||||
const configure = (testBed: TestBed) => {
|
||||
testBed.configureTestingModule({
|
||||
imports: [FormsModule, HttpClientModule, RouterTestingModule.withRoutes(routes)],
|
||||
declarations: [TaskdetailsGeneralFieldsComponent, DummyDetailComponent],
|
||||
providers: [
|
||||
HttpClient,
|
||||
ClassificationCategoriesService,
|
||||
DomainService,
|
||||
RequestInProgressService,
|
||||
SelectedRouteService,
|
||||
ClassificationsService
|
||||
]
|
||||
});
|
||||
};
|
||||
configureTests(configure).then((testBed) => {
|
||||
classificationsService = testBed.get(ClassificationsService);
|
||||
const resource: ClassificationPagingList = {
|
||||
classifications: [
|
||||
{
|
||||
classificationId: 'id1',
|
||||
key: 'key1',
|
||||
category: 'category',
|
||||
type: 'type',
|
||||
domain: 'DOMAIN_A',
|
||||
name: 'classification1',
|
||||
parentId: 'parentId',
|
||||
parentKey: 'parentKey'
|
||||
},
|
||||
{
|
||||
classificationId: 'id2',
|
||||
key: 'key2',
|
||||
category: 'category',
|
||||
type: 'type',
|
||||
domain: 'DOMAIN_A',
|
||||
name: 'classification1',
|
||||
parentId: 'parentId',
|
||||
parentKey: 'parentKey'
|
||||
}
|
||||
]
|
||||
};
|
||||
spyOn(classificationsService, 'getClassificationsByDomain').and.returnValue(resource);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(TaskdetailsGeneralFieldsComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should call to getClassificationsByDomain', (done) => {
|
||||
component.ngOnInit();
|
||||
expect(classificationsService.getClassificationsByDomain).toHaveBeenCalled();
|
||||
done();
|
||||
});
|
||||
});
|
|
@ -1,33 +1,23 @@
|
|||
// This file is required by karma.conf.js and loads recursively all the .spec and framework files
|
||||
import 'jest-preset-angular';
|
||||
|
||||
import 'zone.js/dist/long-stack-trace-zone';
|
||||
import 'zone.js/dist/proxy.js';
|
||||
import 'zone.js/dist/sync-test';
|
||||
import 'zone.js/dist/jasmine-patch';
|
||||
import 'zone.js/dist/async-test';
|
||||
import 'zone.js/dist/fake-async-test';
|
||||
import { getTestBed } from '@angular/core/testing';
|
||||
import { BrowserDynamicTestingModule, platformBrowserDynamicTesting } from '@angular/platform-browser-dynamic/testing';
|
||||
import 'rxjs';
|
||||
Object.defineProperty(window, 'CSS', { value: null });
|
||||
Object.defineProperty(window, 'getComputedStyle', {
|
||||
value: () => {
|
||||
return {
|
||||
display: 'none',
|
||||
appearance: ['-webkit-appearance']
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
// Unfortunately there's no typing for the `__karma__` variable. Just declare it as any.
|
||||
declare let __karma__: any;
|
||||
declare let require: any;
|
||||
|
||||
// Prevent Karma from running prematurely.
|
||||
__karma__.loaded = function noop() {};
|
||||
|
||||
// First, initialize the Angular testing environment.
|
||||
getTestBed().initTestEnvironment(BrowserDynamicTestingModule, platformBrowserDynamicTesting());
|
||||
// Then we find all the tests.
|
||||
const contextAdministration = require.context('./app/administration', true, /\.spec\.ts$/);
|
||||
const contextWorkplace = require.context('./app/workplace', true, /\.spec\.ts$/);
|
||||
// const contextMonitor = require.context('./app/monitor', true, /\.spec\.ts$/);
|
||||
const contextShared = require.context('./app/shared', true, /\.spec\.ts$/);
|
||||
// And load the modules.
|
||||
contextAdministration.keys().map(contextAdministration);
|
||||
contextWorkplace.keys().map(contextWorkplace);
|
||||
// contextMonitor.keys().map(contextMonitor);
|
||||
contextShared.keys().map(contextShared);
|
||||
// Finally, start Karma to run the tests.
|
||||
__karma__.start();
|
||||
Object.defineProperty(document, 'doctype', {
|
||||
value: '<!DOCTYPE html>'
|
||||
});
|
||||
Object.defineProperty(document.body.style, 'transform', {
|
||||
value: () => {
|
||||
return {
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
};
|
||||
}
|
||||
});
|
||||
|
|
|
@ -1,10 +0,0 @@
|
|||
{
|
||||
"extends": "../tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"outDir": "../out-tsc/spec",
|
||||
"baseUrl": "",
|
||||
"types": ["jasmine", "node"]
|
||||
},
|
||||
"files": ["test.ts", "polyfills.ts"],
|
||||
"include": ["**/*.spec.ts", "**/*.d.ts"]
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
{
|
||||
"extends": "./tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"outDir": "./out-tsc/spec",
|
||||
"types": [
|
||||
"jest",
|
||||
"node"
|
||||
],
|
||||
"esModuleInterop": true,
|
||||
"emitDecoratorMetadata": true
|
||||
},
|
||||
"files": [
|
||||
"src/test.ts",
|
||||
"src/polyfills.ts"
|
||||
],
|
||||
"include": [
|
||||
"src/**/*.spec.ts",
|
||||
"src/**/*.d.ts"
|
||||
]
|
||||
}
|
Loading…
Reference in New Issue