Skip to content

Commit 4a7eb3e

Browse files
committed
feat: add additional test for section with ####
Add additional test for section with #### to prevent and catch in future code change that would produce wrong parsing. Signed-off-by: Christian Marangi <[email protected]>
1 parent 66ffdc2 commit 4a7eb3e

File tree

5 files changed

+60
-0
lines changed

5 files changed

+60
-0
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"textarea-one": "Textarea input text 1 ####"
3+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
body:
2+
- type: textarea
3+
id: textarea-one
4+
attributes:
5+
label: My textarea input
6+
- type: textarea
7+
id: textarea-two
8+
attributes:
9+
label: Another textarea input
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
### My textarea input
2+
3+
Textarea input text 1 ####
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
const { resolve } = require("path");
2+
const { readFileSync } = require("fs");
3+
4+
const issueBodyPath = resolve(__dirname, "issue-body.md");
5+
6+
module.exports = readFileSync(issueBodyPath, "utf-8")

test.spec.js

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,45 @@ it("multiple paragraphs", () => {
130130
expect(core.setOutput.mock.calls.length).toBe(3)
131131
});
132132

133+
it("paragraph with confusing ####", () => {
134+
const expectedOutput = require("./fixtures/paragraph-confusing-####/expected.json");
135+
const expectedOutputJson = JSON.stringify(expectedOutput, null, 2);
136+
137+
// mock ENV
138+
const env = {
139+
HOME: "<home path>",
140+
};
141+
142+
// mock event payload
143+
const eventPayload = require("./fixtures/paragraph-confusing-####/issue");
144+
145+
// mock fs
146+
const fs = {
147+
readFileSync(path, encoding) {
148+
expect(path).toBe("<template-path>");
149+
expect(encoding).toBe("utf8");
150+
return readFileSync("fixtures/paragraph-confusing-####/form.yml", "utf-8");
151+
},
152+
writeFileSync(path, content) {
153+
expect(path).toBe("<home path>/issue-parser-result.json");
154+
expect(content).toBe(expectedOutputJson);
155+
},
156+
};
157+
158+
// mock core
159+
const core = {
160+
getInput: jest.fn(() => '<template-path>'),
161+
setOutput: jest.fn(),
162+
};
163+
164+
run(env, eventPayload, fs, core);
165+
166+
expect(core.getInput).toHaveBeenCalledWith('template-path')
167+
expect(core.setOutput).toHaveBeenCalledWith('jsonString', JSON.stringify(expectedOutput, null, 2))
168+
expect(core.setOutput).toHaveBeenCalledWith('issueparser_textarea-one', 'Textarea input text 1 ####')
169+
expect(core.setOutput.mock.calls.length).toBe(2)
170+
});
171+
133172
it("blank", () => {
134173
const expectedOutput = require("./fixtures/blank/expected.json");
135174
const expectedOutputJson = JSON.stringify(expectedOutput, null, 2);

0 commit comments

Comments
 (0)