Skip to content

Commit f978ff1

Browse files
committed
Add a test to assert escaped quotes
1 parent c99d654 commit f978ff1

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
title: This title "has quotes"
3+
---
4+
Goodbye!

tests/index.test.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,25 @@ describe('create-an-issue', () => {
176176
expect(params).toMatchSnapshot()
177177
expect(tools.exit.success).toHaveBeenCalled()
178178
})
179+
180+
it('escapes quotes in the search query', async () => {
181+
process.env.INPUT_FILENAME = '.github/quotes-in-title.md'
182+
183+
nock.cleanAll()
184+
nock('https://api.github.com')
185+
.get(/\/search\/issues.*/)
186+
.query(parsedQuery => {
187+
const q = parsedQuery['q'] as string
188+
return q.includes('"This title \\\"has quotes\\\""')
189+
})
190+
.reply(200, {
191+
items: [{ number: 1, title: 'Hello!' }]
192+
})
193+
.post(/\/repos\/.*\/.*\/issues/).reply(200, {})
194+
195+
await createAnIssue(tools)
196+
expect(tools.log.success).toHaveBeenCalled()
197+
})
179198

180199
it('checks the value of update_existing', async () => {
181200
process.env.INPUT_UPDATE_EXISTING = 'invalid'

0 commit comments

Comments
 (0)