mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-05-19 17:14:57 +00:00
[ADF-5357] - Convert process name manual tests to unit tests (#6792)
* Convert process name manual tests to unit tests * Add more checks for the name controller
This commit is contained in:
parent
d6def4491d
commit
1ca7ebfeb1
@ -41,6 +41,8 @@ import { By } from '@angular/platform-browser';
|
||||
import { ProcessPayloadCloud } from '../models/process-payload-cloud.model';
|
||||
import { ProcessServiceCloudTestingModule } from '../../../testing/process-service-cloud.testing.module';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
import { ProcessNameCloudPipe } from '../../../pipes/process-name-cloud.pipe';
|
||||
import { ProcessInstanceCloud } from '../models/process-instance-cloud.model';
|
||||
|
||||
describe('StartProcessCloudComponent', () => {
|
||||
|
||||
@ -795,5 +797,23 @@ describe('StartProcessCloudComponent', () => {
|
||||
noProcessElement = fixture.nativeElement.querySelector('#no-process-message');
|
||||
expect(noProcessElement).not.toBeNull();
|
||||
});
|
||||
|
||||
it('should set the process name using the processName cloud pipe when a process definition gets selected', () => {
|
||||
const processNameCloudPipe = TestBed.inject(ProcessNameCloudPipe);
|
||||
const processNamePipeTransformSpy = spyOn(processNameCloudPipe, 'transform').and.returnValue('fake-transformed-name');
|
||||
const expectedProcessInstanceDetails: ProcessInstanceCloud = { processDefinitionName: fakeProcessDefinitions[0].name};
|
||||
getDefinitionsSpy = getDefinitionsSpy.and.returnValue(of(fakeProcessDefinitions));
|
||||
|
||||
component.appName = 'myApp';
|
||||
component.ngOnChanges({ appName: firstChange });
|
||||
fixture.detectChanges();
|
||||
|
||||
selectOptionByName(fakeProcessDefinitions[0].name);
|
||||
|
||||
expect(processNamePipeTransformSpy).toHaveBeenCalledWith(component.name, expectedProcessInstanceDetails);
|
||||
expect(component.processInstanceName.dirty).toBe(true);
|
||||
expect(component.processInstanceName.touched).toBe(true);
|
||||
expect(component.processInstanceName.value).toEqual('fake-transformed-name');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -35,6 +35,8 @@ import { ProcessTestingModule } from '../../testing/process.testing.module';
|
||||
import { By } from '@angular/platform-browser';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
import { deployedApps } from '../../mock/apps-list.mock';
|
||||
import { ProcessNamePipe } from '../../pipes/process-name.pipe';
|
||||
import { ProcessInstance } from '../models/process-instance.model';
|
||||
|
||||
describe('StartFormComponent', () => {
|
||||
|
||||
@ -514,6 +516,25 @@ describe('StartFormComponent', () => {
|
||||
selectOptionByName(testProcessDef.name);
|
||||
});
|
||||
|
||||
it('should set the process name using the processName pipe when a process definition gets selected', () => {
|
||||
const processNamePipe = TestBed.inject(ProcessNamePipe);
|
||||
const processNamePipeTransformSpy = spyOn(processNamePipe, 'transform').and.returnValue('fake-transformed-name');
|
||||
const expectedProcessInstanceDetails = new ProcessInstance({ processDefinitionName: testProcessDef.name });
|
||||
getDefinitionsSpy = getDefinitionsSpy.and.returnValue(of(testMultipleProcessDefs));
|
||||
|
||||
component.appId = 123;
|
||||
const appIdChange = new SimpleChange(null, 123, true);
|
||||
component.ngOnChanges({ 'appId': appIdChange });
|
||||
fixture.detectChanges();
|
||||
|
||||
selectOptionByName(testProcessDef.name);
|
||||
|
||||
expect(processNamePipeTransformSpy).toHaveBeenCalledWith(component.name, expectedProcessInstanceDetails);
|
||||
expect(component.nameController.dirty).toBe(true);
|
||||
expect(component.nameController.touched).toBe(true);
|
||||
expect(component.nameController.value).toEqual('fake-transformed-name');
|
||||
});
|
||||
|
||||
it('should not emit start event when start the process without select a process and name', () => {
|
||||
component.name = null;
|
||||
component.selectedProcessDef = null;
|
||||
|
Loading…
x
Reference in New Issue
Block a user