Add Flow component unit test

This commit is contained in:
mauriziovitale84
2016-11-02 10:41:35 +00:00
parent 7037fb6932
commit f92ab024ce
4 changed files with 428 additions and 0 deletions

View File

@@ -0,0 +1,24 @@
/*!
* @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 flow = {
id: 'sid-5BA99724-A3BD-4F8E-B69F-222F9FF66335',
sourceRef: 'startEvent1',
targetRef: 'sid-811B9223-E72E-4991-AAA5-4E1A01095D08',
type: 'sequenceFlow',
waypoints: [{x: 165, y: 122}, {x: 210, y: 122}]
};

View File

@@ -32,6 +32,7 @@ import * as boundaryEventMock from '../assets/diagramBoundary.mock';
import * as throwEventMock from '../assets/diagramThrow.mock';
import * as structuralMock from '../assets/diagramStructural.mock';
import * as swimLanesMock from '../assets/diagramSwimlanes.mock';
import * as flowsMock from '../assets/diagramFlows.mock';
declare let jasmine: any;
@@ -1218,4 +1219,34 @@ describe('Test ng2-activiti-diagrams ', () => {
});
}));
});
describe('Diagrams component Flows: ', () => {
beforeEach(() => {
jasmine.Ajax.install();
component.processDefinitionId = 'fakeprocess:24:38399';
component.metricPercentages = {startEvent: 0};
});
afterEach(() => {
jasmine.Ajax.uninstall();
});
it('Should render the flow', async(() => {
component.onSuccess.subscribe((res) => {
fixture.detectChanges();
fixture.whenStable().then(() => {
expect(res).not.toBeNull();
let shape: any = element.querySelector('diagram-sequence-flow > raphael-flow-arrow');
expect(shape).not.toBeNull();
});
});
component.ngOnChanges();
let resp = {flows: [flowsMock.flow]};
jasmine.Ajax.requests.mostRecent().respondWith({
status: 200,
contentType: 'json',
responseText: resp
});
}));
});
});