TSK-1221: Fixed problem with action and added test

This commit is contained in:
Tristan Eisermann 2020-06-24 08:42:33 +02:00 committed by Tristan2357
parent 7abb9b4c2f
commit d07b11953d
3 changed files with 12 additions and 8 deletions

View File

@ -7,9 +7,6 @@ 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 { ClassificationDefinition } from 'app/shared/models/classification-definition';
import { LinksClassification } from 'app/shared/models/links-classfication';
import { MasterAndDetailService } from 'app/shared/services/master-and-detail/master-and-detail.service';
@ -21,6 +18,7 @@ import { EngineConfigurationSelectors } from 'app/shared/store/engine-configurat
import { ClassificationSelectors } from 'app/shared/store/classification-store/classification.selectors';
import { ClassificationDetailsComponent } from './classification-details.component';
import { NotificationService } from '../../../shared/services/notifications/notification.service';
import { ACTION } from '../../../shared/models/action';
@Component({
@ -36,8 +34,6 @@ describe('ClassificationDetailsComponent', () => {
const treeNodes: Array<TreeNodeModel> = new Array(new TreeNodeModel());
let classificationsService;
let removeConfirmationService;
const locationSpy: jasmine.SpyObj<Location> = jasmine.createSpyObj('Location', ['go']);
const storeSpy: jasmine.SpyObj<Store> = jasmine.createSpyObj('Store', ['select', 'dispatch']);
const configure = (testBed: TestBed) => {
@ -119,4 +115,11 @@ describe('ClassificationDetailsComponent', () => {
expect(fixture.debugElement.nativeElement.querySelector('#classification-key').disabled).toEqual(false);
done();
});
it('should enable editing of key on create', async done => {
component.action = ACTION.CREATE;
await fixture.detectChanges();
expect(fixture.debugElement.nativeElement.querySelector('#classification-key').disabled).toEqual(false);
done();
});
});

View File

@ -1,5 +1,6 @@
export enum ACTION {
DEFAULT,
CREATE,
COPY
}

View File

@ -51,7 +51,7 @@ export class ClassificationState implements NgxsAfterBootstrap {
selectedClassification => {
ctx.patchState({
selectedClassification,
action: null
action: ACTION.DEFAULT
});
}
));
@ -63,7 +63,7 @@ export class ClassificationState implements NgxsAfterBootstrap {
deselectClassification(ctx: StateContext<ClassificationStateModel>): Observable<null> {
ctx.patchState({
selectedClassification: undefined,
action: null
action: ACTION.DEFAULT
});
return of(null);
}
@ -105,7 +105,7 @@ export class ClassificationState implements NgxsAfterBootstrap {
{
classifications: [...ctx.getState().classifications, classification],
selectedClassification: classification,
action: null
action: ACTION.DEFAULT
}
);
})