diff --git a/ng2-components/ng2-activiti-diagrams/src/assets/diagramStructural.mock.ts b/ng2-components/ng2-activiti-diagrams/src/assets/diagramStructural.mock.ts new file mode 100644 index 0000000000..4dace0d7e3 --- /dev/null +++ b/ng2-components/ng2-activiti-diagrams/src/assets/diagramStructural.mock.ts @@ -0,0 +1,36 @@ +/*! + * @license + * Copyright 2016 Alfresco Software, Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export let subProcess = { + id: 'sid-C05B7CB7-1CFD-4AE4-9E01-C2C91E35E5A7', + type: 'SubProcess', + width: 300, + height: 200, + x: 40, + y: 30, + properties: [{}] +}; + +export let eventSubProcess = { + id: 'sid-C05B7CB7-1CFD-4AE4-9E01-C2C91E35E5A7', + type: 'EventSubProcess', + width: 300, + height: 200, + x: 40, + y: 30, + properties: [{}] +}; diff --git a/ng2-components/ng2-activiti-diagrams/src/components/diagram.component.spec.ts b/ng2-components/ng2-activiti-diagrams/src/components/diagram.component.spec.ts index cce61fd583..1cfac45436 100644 --- a/ng2-components/ng2-activiti-diagrams/src/components/diagram.component.spec.ts +++ b/ng2-components/ng2-activiti-diagrams/src/components/diagram.component.spec.ts @@ -30,6 +30,7 @@ import * as diagramsGatewaysMock from '../assets/diagramGateways.mock'; import * as intermediateCatchingMock from '../assets/diagramIntermediate.mock'; import * as boundaryEventMock from '../assets/diagramBoundary.mock'; import * as throwEventMock from '../assets/diagramThrow.mock'; +import * as structuralMock from '../assets/diagramStructural.mock'; declare let jasmine: any; @@ -1109,4 +1110,52 @@ describe('Test ng2-activiti-diagrams ', () => { }); })); }); + + describe('Diagrams component Structural: ', () => { + beforeEach(() => { + jasmine.Ajax.install(); + component.processDefinitionId = 'fakeprocess:24:38399'; + component.metricPercentages = {startEvent: 0}; + }); + + afterEach(() => { + jasmine.Ajax.uninstall(); + }); + + it('Should render the Subprocess', async(() => { + component.onSuccess.subscribe((res) => { + fixture.detectChanges(); + fixture.whenStable().then(() => { + expect(res).not.toBeNull(); + let shape: any = element.querySelector('diagram-subprocess > raphael-rect'); + expect(shape).not.toBeNull(); + }); + }); + component.ngOnChanges(); + let resp = {elements: [structuralMock.subProcess]}; + jasmine.Ajax.requests.mostRecent().respondWith({ + status: 200, + contentType: 'json', + responseText: resp + }); + })); + + it('Should render the Event Subprocess', async(() => { + component.onSuccess.subscribe((res) => { + fixture.detectChanges(); + fixture.whenStable().then(() => { + expect(res).not.toBeNull(); + let shape: any = element.querySelector('diagram-event-subprocess > raphael-rect'); + expect(shape).not.toBeNull(); + }); + }); + component.ngOnChanges(); + let resp = {elements: [structuralMock.eventSubProcess]}; + jasmine.Ajax.requests.mostRecent().respondWith({ + status: 200, + contentType: 'json', + responseText: resp + }); + })); + }); });