Skip to content

Commit

Permalink
fix: Revert "test: set RUNNER_TEMP instead of HOME" (#75)
Browse files Browse the repository at this point in the history
This reverts commit 3c890f0.
  • Loading branch information
gr2m committed May 31, 2024
1 parent 3c890f0 commit 4c1d1d7
Showing 1 changed file with 35 additions and 95 deletions.
130 changes: 35 additions & 95 deletions test.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,25 +34,16 @@ it("readme example", () => {

// mock core
const core = {
getInput: jest.fn(() => "<template-path>"),
getInput: jest.fn(() => '<template-path>'),
setOutput: jest.fn(),
};

run(env, eventPayload, fs, core);
expect(core.getInput).toHaveBeenCalledWith("template-path");
expect(core.setOutput).toHaveBeenCalledWith(
"jsonString",
JSON.stringify(expectedOutput, null, 2)
);
expect(core.setOutput).toHaveBeenCalledWith(
"issueparser_favorite_dish",
"Pizza"
);
expect(core.setOutput).toHaveBeenCalledWith(
"issueparser_favorite_color",
"Red,Blue"
);
expect(core.setOutput.mock.calls.length).toBe(3);
expect(core.getInput).toHaveBeenCalledWith('template-path')
expect(core.setOutput).toHaveBeenCalledWith('jsonString', JSON.stringify(expectedOutput, null, 2))
expect(core.setOutput).toHaveBeenCalledWith('issueparser_favorite_dish', 'Pizza')
expect(core.setOutput).toHaveBeenCalledWith('issueparser_favorite_color', 'Red,Blue')
expect(core.setOutput.mock.calls.length).toBe(3)
});

it("full example", () => {
Expand Down Expand Up @@ -82,42 +73,21 @@ it("full example", () => {

// mock core
const core = {
getInput: jest.fn(() => "<template-path>"),
getInput: jest.fn(() => '<template-path>'),
setOutput: jest.fn(),
};

run(env, eventPayload, fs, core);
expect(core.getInput).toHaveBeenCalledWith("template-path");
expect(core.setOutput).toHaveBeenCalledWith(
"jsonString",
JSON.stringify(expectedOutput, null, 2)
);
expect(core.setOutput).toHaveBeenCalledWith(
"issueparser_contact",
"me@me.com"
);
expect(core.setOutput).toHaveBeenCalledWith(
"issueparser_what_happened",
"A bug happened!"
);
expect(core.setOutput).toHaveBeenCalledWith("issueparser_version", "1.0.0");
expect(core.setOutput).toHaveBeenCalledWith(
"issueparser_browsers",
"Chrome, Safari"
);
expect(core.setOutput).toHaveBeenCalledWith(
"issueparser_anything_else",
"Never give up"
);
expect(core.setOutput).toHaveBeenCalledWith(
"issueparser_second_anything_else",
"Hot Dog is a Sandwich,Another item"
);
expect(core.setOutput).toHaveBeenCalledWith(
"issueparser_checkbox_without_an_id",
""
);
expect(core.setOutput.mock.calls.length).toBe(8);
expect(core.getInput).toHaveBeenCalledWith('template-path')
expect(core.setOutput).toHaveBeenCalledWith('jsonString', JSON.stringify(expectedOutput, null, 2))
expect(core.setOutput).toHaveBeenCalledWith('issueparser_contact', 'me@me.com')
expect(core.setOutput).toHaveBeenCalledWith('issueparser_what_happened', 'A bug happened!')
expect(core.setOutput).toHaveBeenCalledWith('issueparser_version', '1.0.0')
expect(core.setOutput).toHaveBeenCalledWith('issueparser_browsers', 'Chrome, Safari')
expect(core.setOutput).toHaveBeenCalledWith('issueparser_anything_else', 'Never give up')
expect(core.setOutput).toHaveBeenCalledWith('issueparser_second_anything_else', 'Hot Dog is a Sandwich,Another item')
expect(core.setOutput).toHaveBeenCalledWith('issueparser_checkbox_without_an_id', '')
expect(core.setOutput.mock.calls.length).toBe(8)
});

it("mismatched parsing", () => {
Expand All @@ -126,7 +96,7 @@ it("mismatched parsing", () => {

// mock ENV
const env = {
RUNNER_TEMP: "<home path>",
HOME: "<home path>",
};

// mock event payload
Expand All @@ -147,42 +117,21 @@ it("mismatched parsing", () => {

// mock core
const core = {
getInput: jest.fn(() => "<template-path>"),
getInput: jest.fn(() => '<template-path>'),
setOutput: jest.fn(),
};

run(env, eventPayload, fs, core);
expect(core.getInput).toHaveBeenCalledWith("template-path");
expect(core.setOutput).toHaveBeenCalledWith(
"jsonString",
JSON.stringify(expectedOutput, null, 2)
);
expect(core.setOutput).toHaveBeenCalledWith(
"issueparser_your_contact_details",
"me@me.com"
);
expect(core.setOutput).toHaveBeenCalledWith(
"issueparser_what_happened",
"A bug happened!"
);
expect(core.setOutput).toHaveBeenCalledWith("issueparser_version", "1.0.0");
expect(core.setOutput).toHaveBeenCalledWith(
"issueparser_what_browsers_are_you_seeing_the_problem_on",
"Chrome, Safari"
);
expect(core.setOutput).toHaveBeenCalledWith(
"issueparser_what_else",
"Never give up"
);
expect(core.setOutput).toHaveBeenCalledWith(
"issueparser_and_with_that",
"Hot Dog is a Sandwich,Another item"
);
expect(core.setOutput).toHaveBeenCalledWith(
"issueparser_checkbox_without_an_id",
""
);
expect(core.setOutput.mock.calls.length).toBe(8);
expect(core.getInput).toHaveBeenCalledWith('template-path')
expect(core.setOutput).toHaveBeenCalledWith('jsonString', JSON.stringify(expectedOutput, null, 2))
expect(core.setOutput).toHaveBeenCalledWith('issueparser_your_contact_details', 'me@me.com')
expect(core.setOutput).toHaveBeenCalledWith('issueparser_what_happened', 'A bug happened!')
expect(core.setOutput).toHaveBeenCalledWith('issueparser_version', '1.0.0')
expect(core.setOutput).toHaveBeenCalledWith('issueparser_what_browsers_are_you_seeing_the_problem_on', 'Chrome, Safari')
expect(core.setOutput).toHaveBeenCalledWith('issueparser_what_else', 'Never give up')
expect(core.setOutput).toHaveBeenCalledWith('issueparser_and_with_that', 'Hot Dog is a Sandwich,Another item')
expect(core.setOutput).toHaveBeenCalledWith('issueparser_checkbox_without_an_id', '')
expect(core.setOutput.mock.calls.length).toBe(8)
});

it("multiple paragraphs", () => {
Expand Down Expand Up @@ -212,26 +161,17 @@ it("multiple paragraphs", () => {

// mock core
const core = {
getInput: jest.fn(() => "<template-path>"),
getInput: jest.fn(() => '<template-path>'),
setOutput: jest.fn(),
};

run(env, eventPayload, fs, core);

expect(core.getInput).toHaveBeenCalledWith("template-path");
expect(core.setOutput).toHaveBeenCalledWith(
"jsonString",
JSON.stringify(expectedOutput, null, 2)
);
expect(core.setOutput).toHaveBeenCalledWith(
"issueparser_textarea-one",
"1st paragraph\n\n2nd paragraph"
);
expect(core.setOutput).toHaveBeenCalledWith(
"issueparser_textarea-two",
"1st paragraph\n2nd paragraph"
);
expect(core.setOutput.mock.calls.length).toBe(3);
expect(core.getInput).toHaveBeenCalledWith('template-path')
expect(core.setOutput).toHaveBeenCalledWith('jsonString', JSON.stringify(expectedOutput, null, 2))
expect(core.setOutput).toHaveBeenCalledWith('issueparser_textarea-one', '1st paragraph\n\n2nd paragraph')
expect(core.setOutput).toHaveBeenCalledWith('issueparser_textarea-two', '1st paragraph\n2nd paragraph')
expect(core.setOutput.mock.calls.length).toBe(3)
});

it("blank", () => {
Expand Down

0 comments on commit 4c1d1d7

Please sign in to comment.