Skip to content

Commit 2809d5f

Browse files
committed
Add Prettier to codebase
1 parent f360ade commit 2809d5f

15 files changed

+1224
-1039
lines changed

.editorconfig

+15-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,22 @@
11
root = true
22

33
[*]
4+
charset = utf-8
5+
end_of_line = lf
6+
7+
[*.{ts,js,json}]
8+
indent_style = tab
9+
trim_trailing_whitespace = true
10+
insert_final_newline = true
11+
12+
[*.{py,md,markdown}]
413
indent_style = space
514
indent_size = 4
6-
charset = utf-8
15+
trim_trailing_whitespace = true
16+
insert_final_newline = true
17+
18+
[*.{yml,yaml}]
19+
indent_style = space
20+
indent_size = 2
721
trim_trailing_whitespace = true
822
insert_final_newline = true

prettier.config.js

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
module.exports = {
2+
endOfLine: "lf",
3+
useTabs: true,
4+
tabWidth: 4,
5+
6+
trailingComma: "es5",
7+
semi: false,
8+
singleQuote: true,
9+
jsxSingleQuote: true,
10+
overrides: [
11+
{
12+
files: ["*.yaml", "*.yml"],
13+
options: {
14+
useTabs: false,
15+
tabWidth: 2,
16+
singleQuote: false
17+
}
18+
}
19+
]
20+
};

src/__mocks__/node-grpc-client.ts

+87-82
Original file line numberDiff line numberDiff line change
@@ -1,83 +1,88 @@
11
export = class GRPCClient {
2-
public protoFilePath: string;
3-
public protocolName: string;
4-
public serviceName: string;
5-
public grpcServeraddress: string;
6-
7-
public deployedWorkflows: string[] = [];
8-
9-
constructor(protoFilePath: string, protocolName: string, serviceName: string, grpcServeraddress: string) {
10-
this.protoFilePath = protoFilePath;
11-
this.protocolName = protocolName;
12-
this.serviceName = serviceName;
13-
this.grpcServeraddress = grpcServeraddress;
14-
}
15-
16-
public activateJobsStream() {
17-
return null;
18-
}
19-
20-
public cancelWorkflowInstanceSync() {
21-
return null;
22-
}
23-
24-
public completeJobSync() {
25-
return null;
26-
}
27-
28-
public createWorkflowInstanceSync() {
29-
return null;
30-
}
31-
32-
public deployWorkflowSync(wfr: any) {
33-
// @TODO: Parse out processId and pass back
34-
const res = wfr.workflows.map((wf: any) => ({
35-
bpmnProcessId: "hello-world",
36-
resourceName: wf.name,
37-
version: 1,
38-
workflowKey: "381010",
39-
}));
40-
return { workflows: res };
41-
}
42-
43-
public failJobSync() {
44-
return null;
45-
}
46-
47-
public getWorkflowSync() {
48-
return null;
49-
}
50-
51-
public listWorkflowsSync() {
52-
return {
53-
workflows:
54-
[{
55-
bpmnProcessId: "hello-world",
56-
resourceName: "hello-world.bpmn",
57-
version: 1,
58-
workflowKey: "1",
59-
}],
60-
};
61-
}
62-
63-
public publishMessageSync() {
64-
return null;
65-
}
66-
67-
public resolveIncidentSync() {
68-
return null;
69-
}
70-
71-
public topologySync() {
72-
return null;
73-
}
74-
75-
public updateJobRetriesSync() {
76-
return null;
77-
}
78-
79-
public updateWorkflowInstancePayloadRequestSync() {
80-
return null;
81-
}
82-
83-
};
2+
public protoFilePath: string
3+
public protocolName: string
4+
public serviceName: string
5+
public grpcServeraddress: string
6+
7+
public deployedWorkflows: string[] = []
8+
9+
constructor(
10+
protoFilePath: string,
11+
protocolName: string,
12+
serviceName: string,
13+
grpcServeraddress: string
14+
) {
15+
this.protoFilePath = protoFilePath
16+
this.protocolName = protocolName
17+
this.serviceName = serviceName
18+
this.grpcServeraddress = grpcServeraddress
19+
}
20+
21+
public activateJobsStream() {
22+
return null
23+
}
24+
25+
public cancelWorkflowInstanceSync() {
26+
return null
27+
}
28+
29+
public completeJobSync() {
30+
return null
31+
}
32+
33+
public createWorkflowInstanceSync() {
34+
return null
35+
}
36+
37+
public deployWorkflowSync(wfr: any) {
38+
// @TODO: Parse out processId and pass back
39+
const res = wfr.workflows.map((wf: any) => ({
40+
bpmnProcessId: 'hello-world',
41+
resourceName: wf.name,
42+
version: 1,
43+
workflowKey: '381010',
44+
}))
45+
return { workflows: res }
46+
}
47+
48+
public failJobSync() {
49+
return null
50+
}
51+
52+
public getWorkflowSync() {
53+
return null
54+
}
55+
56+
public listWorkflowsSync() {
57+
return {
58+
workflows: [
59+
{
60+
bpmnProcessId: 'hello-world',
61+
resourceName: 'hello-world.bpmn',
62+
version: 1,
63+
workflowKey: '1',
64+
},
65+
],
66+
}
67+
}
68+
69+
public publishMessageSync() {
70+
return null
71+
}
72+
73+
public resolveIncidentSync() {
74+
return null
75+
}
76+
77+
public topologySync() {
78+
return null
79+
}
80+
81+
public updateJobRetriesSync() {
82+
return null
83+
}
84+
85+
public updateWorkflowInstancePayloadRequestSync() {
86+
return null
87+
}
88+
}

src/__tests__/BpmnParser.spec.ts

+63-49
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,65 @@
1-
import { BpmnParser } from "..";
1+
import { BpmnParser } from '..'
22

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'
55

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

Comments
 (0)