diff --git a/tests/fixtures/.github/quotes-in-title.md b/tests/fixtures/.github/quotes-in-title.md new file mode 100644 index 0000000..701e1d3 --- /dev/null +++ b/tests/fixtures/.github/quotes-in-title.md @@ -0,0 +1,4 @@ +--- +title: This title "has quotes" +--- +Goodbye! \ No newline at end of file diff --git a/tests/index.test.ts b/tests/index.test.ts index a8fe8a7..2e95f2a 100644 --- a/tests/index.test.ts +++ b/tests/index.test.ts @@ -176,6 +176,25 @@ describe('create-an-issue', () => { expect(params).toMatchSnapshot() expect(tools.exit.success).toHaveBeenCalled() }) + + it('escapes quotes in the search query', async () => { + process.env.INPUT_FILENAME = '.github/quotes-in-title.md' + + nock.cleanAll() + nock('https://api.github.com') + .get(/\/search\/issues.*/) + .query(parsedQuery => { + const q = parsedQuery['q'] as string + return q.includes('"This title \\\"has quotes\\\""') + }) + .reply(200, { + items: [{ number: 1, title: 'Hello!' }] + }) + .post(/\/repos\/.*\/.*\/issues/).reply(200, {}) + + await createAnIssue(tools) + expect(tools.log.success).toHaveBeenCalled() + }) it('checks the value of update_existing', async () => { process.env.INPUT_UPDATE_EXISTING = 'invalid'