Skip to content

Commit ba96fbe

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 <ansuelsmth@gmail.com>
1 parent b914eca commit ba96fbe

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
@@ -174,6 +174,45 @@ it("multiple paragraphs", () => {
174174
expect(core.setOutput.mock.calls.length).toBe(3)
175175
});
176176

177+
it("paragraph with confusing ####", () => {
178+
const expectedOutput = require("./fixtures/paragraph-confusing-####/expected.json");
179+
const expectedOutputJson = JSON.stringify(expectedOutput, null, 2);
180+
181+
// mock ENV
182+
const env = {
183+
HOME: "<home path>",
184+
};
185+
186+
// mock event payload
187+
const eventPayload = require("./fixtures/paragraph-confusing-####/issue");
188+
189+
// mock fs
190+
const fs = {
191+
readFileSync(path, encoding) {
192+
expect(path).toBe("<template-path>");
193+
expect(encoding).toBe("utf8");
194+
return readFileSync("fixtures/paragraph-confusing-####/form.yml", "utf-8");
195+
},
196+
writeFileSync(path, content) {
197+
expect(path).toBe("<home path>/issue-parser-result.json");
198+
expect(content).toBe(expectedOutputJson);
199+
},
200+
};
201+
202+
// mock core
203+
const core = {
204+
getInput: jest.fn(() => '<template-path>'),
205+
setOutput: jest.fn(),
206+
};
207+
208+
run(env, eventPayload, fs, core);
209+
210+
expect(core.getInput).toHaveBeenCalledWith('template-path')
211+
expect(core.setOutput).toHaveBeenCalledWith('jsonString', JSON.stringify(expectedOutput, null, 2))
212+
expect(core.setOutput).toHaveBeenCalledWith('issueparser_textarea-one', 'Textarea input text 1 ####')
213+
expect(core.setOutput.mock.calls.length).toBe(2)
214+
});
215+
177216
it("blank", () => {
178217
const expectedOutput = require("./fixtures/blank/expected.json");
179218
const expectedOutputJson = JSON.stringify(expectedOutput, null, 2);

0 commit comments

Comments
 (0)