Skip to content

Commit

Permalink
Add a test to assert escaped quotes
Browse files Browse the repository at this point in the history
  • Loading branch information
JasonEtco committed Dec 13, 2022
1 parent c99d654 commit f978ff1
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
4 changes: 4 additions & 0 deletions tests/fixtures/.github/quotes-in-title.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
title: This title "has quotes"
---
Goodbye!
19 changes: 19 additions & 0 deletions tests/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down

0 comments on commit f978ff1

Please sign in to comment.