|
1 |
| -import { BpmnParser } from ".."; |
| 1 | +import { BpmnParser } from '..' |
2 | 2 |
|
3 |
| -const testBpmnFile = __dirname + "/testdata/msg-start.bpmn"; |
4 |
| -const simpleTestBpmnFile = __dirname + "/testdata/msg-start-simple.bpmn"; |
| 3 | +const testBpmnFile = __dirname + '/testdata/msg-start.bpmn' |
| 4 | +const simpleTestBpmnFile = __dirname + '/testdata/msg-start-simple.bpmn' |
5 | 5 |
|
6 |
| -describe("parseBpmn", () => { |
7 |
| - const parsed = BpmnParser.parseBpmn(testBpmnFile); |
8 |
| - const parsedSimple = BpmnParser.parseBpmn(simpleTestBpmnFile); |
9 |
| - describe("parseBpmn", () => { |
10 |
| - it("parses a bpmn file to an Object", () => { |
11 |
| - expect(typeof parsed).toBe("object"); |
12 |
| - expect(typeof parsedSimple).toBe("object"); |
13 |
| - }); |
14 |
| - }); |
15 |
| - describe("getTaskTypes", () => { |
16 |
| - it("gets a unique list of task types when passed an object", async () => { |
17 |
| - const taskTypes = await BpmnParser.getTaskTypes(parsed); |
18 |
| - expect(taskTypes.length).toBe(1); |
19 |
| - }); |
20 |
| - it("gets a list of unique task types when passed an array", async () => { |
21 |
| - const taskTypes = await BpmnParser.getTaskTypes([parsed, parsedSimple]); |
22 |
| - expect(taskTypes.length).toBe(2); |
23 |
| - }); |
24 |
| - }); |
25 |
| - describe("getMessageNames", () => { |
26 |
| - it("gets a list of unique message names when passed an object", async () => { |
27 |
| - const messageNames = await BpmnParser.getMessageNames(parsed); |
28 |
| - expect(messageNames.length).toBe(2); |
29 |
| - }); |
30 |
| - it("gets a list of unique message names when passed an array", async () => { |
31 |
| - const messageNames = await BpmnParser.getMessageNames([parsed, parsedSimple]); |
32 |
| - expect(messageNames.length).toBe(3); |
33 |
| - }); |
34 |
| - }); |
35 |
| - describe("generateConstantsForBpmnFiles", () => { |
36 |
| - it("Returns a constants file for a single Bpmn file", async () => { |
37 |
| - const constants = await BpmnParser.generateConstantsForBpmnFiles(testBpmnFile); |
38 |
| - expect(constants.indexOf("console-log")).not.toBe(-1); |
39 |
| - }); |
40 |
| - it("Returns a constants file for an array of Bpmn files", async () => { |
41 |
| - const constants = await BpmnParser.generateConstantsForBpmnFiles([testBpmnFile, simpleTestBpmnFile]); |
42 |
| - expect(constants |
43 |
| - .split(" ").join("") |
44 |
| - .split("\n").join("") |
45 |
| - .indexOf(`exportenumMessageName{MSG_EMIT_FRAME="MSG-EMIT_FRAME",MSG_EMIT_FRAME_1="MSG-EMIT_FRAME`)) |
46 |
| - .not |
47 |
| - .toBe(-1); |
48 |
| - }); |
49 |
| - }); |
50 |
| - |
51 |
| -}); |
| 6 | +describe('parseBpmn', () => { |
| 7 | + const parsed = BpmnParser.parseBpmn(testBpmnFile) |
| 8 | + const parsedSimple = BpmnParser.parseBpmn(simpleTestBpmnFile) |
| 9 | + describe('parseBpmn', () => { |
| 10 | + it('parses a bpmn file to an Object', () => { |
| 11 | + expect(typeof parsed).toBe('object') |
| 12 | + expect(typeof parsedSimple).toBe('object') |
| 13 | + }) |
| 14 | + }) |
| 15 | + describe('getTaskTypes', () => { |
| 16 | + it('gets a unique list of task types when passed an object', async () => { |
| 17 | + const taskTypes = await BpmnParser.getTaskTypes(parsed) |
| 18 | + expect(taskTypes.length).toBe(1) |
| 19 | + }) |
| 20 | + it('gets a list of unique task types when passed an array', async () => { |
| 21 | + const taskTypes = await BpmnParser.getTaskTypes([ |
| 22 | + parsed, |
| 23 | + parsedSimple, |
| 24 | + ]) |
| 25 | + expect(taskTypes.length).toBe(2) |
| 26 | + }) |
| 27 | + }) |
| 28 | + describe('getMessageNames', () => { |
| 29 | + it('gets a list of unique message names when passed an object', async () => { |
| 30 | + const messageNames = await BpmnParser.getMessageNames(parsed) |
| 31 | + expect(messageNames.length).toBe(2) |
| 32 | + }) |
| 33 | + it('gets a list of unique message names when passed an array', async () => { |
| 34 | + const messageNames = await BpmnParser.getMessageNames([ |
| 35 | + parsed, |
| 36 | + parsedSimple, |
| 37 | + ]) |
| 38 | + expect(messageNames.length).toBe(3) |
| 39 | + }) |
| 40 | + }) |
| 41 | + describe('generateConstantsForBpmnFiles', () => { |
| 42 | + it('Returns a constants file for a single Bpmn file', async () => { |
| 43 | + const constants = await BpmnParser.generateConstantsForBpmnFiles( |
| 44 | + testBpmnFile |
| 45 | + ) |
| 46 | + expect(constants.indexOf('console-log')).not.toBe(-1) |
| 47 | + }) |
| 48 | + it('Returns a constants file for an array of Bpmn files', async () => { |
| 49 | + const constants = await BpmnParser.generateConstantsForBpmnFiles([ |
| 50 | + testBpmnFile, |
| 51 | + simpleTestBpmnFile, |
| 52 | + ]) |
| 53 | + expect( |
| 54 | + constants |
| 55 | + .split(' ') |
| 56 | + .join('') |
| 57 | + .split('\n') |
| 58 | + .join('') |
| 59 | + .indexOf( |
| 60 | + `exportenumMessageName{MSG_EMIT_FRAME="MSG-EMIT_FRAME",MSG_EMIT_FRAME_1="MSG-EMIT_FRAME` |
| 61 | + ) |
| 62 | + ).not.toBe(-1) |
| 63 | + }) |
| 64 | + }) |
| 65 | +}) |
0 commit comments