Skip to content

Commit 48ade79

Browse files
Ansuelgr2m
authored andcommitted
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 8cb771a commit 48ade79

5 files changed

Lines changed: 60 additions & 0 deletions

File tree

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

187+
it("paragraph with confusing ####", () => {
188+
const expectedOutput = require("./fixtures/paragraph-confusing-####/expected.json");
189+
const expectedOutputJson = JSON.stringify(expectedOutput, null, 2);
190+
191+
// mock ENV
192+
const env = {
193+
HOME: "<home path>",
194+
};
195+
196+
// mock event payload
197+
const eventPayload = require("./fixtures/paragraph-confusing-####/issue");
198+
199+
// mock fs
200+
const fs = {
201+
readFileSync(path, encoding) {
202+
expect(path).toBe("<template-path>");
203+
expect(encoding).toBe("utf8");
204+
return readFileSync("fixtures/paragraph-confusing-####/form.yml", "utf-8");
205+
},
206+
writeFileSync(path, content) {
207+
expect(path).toBe("<home path>/issue-parser-result.json");
208+
expect(content).toBe(expectedOutputJson);
209+
},
210+
};
211+
212+
// mock core
213+
const core = {
214+
getInput: jest.fn(() => '<template-path>'),
215+
setOutput: jest.fn(),
216+
};
217+
218+
run(env, eventPayload, fs, core);
219+
220+
expect(core.getInput).toHaveBeenCalledWith('template-path')
221+
expect(core.setOutput).toHaveBeenCalledWith('jsonString', JSON.stringify(expectedOutput, null, 2))
222+
expect(core.setOutput).toHaveBeenCalledWith('issueparser_textarea-one', 'Textarea input text 1 ####')
223+
expect(core.setOutput.mock.calls.length).toBe(2)
224+
});
225+
187226
it("blank", () => {
188227
const expectedOutput = loadJson("./fixtures/blank/expected.json");
189228
const expectedOutputJson = JSON.stringify(expectedOutput, null, 2);

0 commit comments

Comments
 (0)