mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-27 23:27:31 +00:00
test(pdf): read the export's note cards without non-null assertions
The markdown test for the day notes reached its cards with three non-null assertions, which the client lint counts against the tests' baseline. A small lookup that fails with the missing selector reads them instead.
This commit is contained in:
@@ -474,15 +474,20 @@ describe('downloadTripPDF', () => {
|
||||
await downloadTripPDF(md)
|
||||
const html = getIframe()?.srcdoc ?? ''
|
||||
const doc = new DOMParser().parseFromString(html, 'text/html')
|
||||
const intro = doc.querySelector('.day-intro')!
|
||||
const card = (selector: string) => {
|
||||
const found = doc.querySelector(selector)
|
||||
if (!found) throw new Error(`${selector} is not in the export`)
|
||||
return found
|
||||
}
|
||||
const intro = card('.day-intro')
|
||||
expect(intro.querySelector('strong')?.textContent).toBe('Intro')
|
||||
expect([...intro.querySelectorAll('li')].map(li => li.textContent)).toEqual(['museum', 'lunch'])
|
||||
const noteLine = doc.querySelector('.tl-note .note-time')!
|
||||
const noteLine = card('.tl-note .note-time')
|
||||
expect(noteLine.querySelector('em')?.textContent).toBe('Bring')
|
||||
expect(noteLine.querySelector('hr')).not.toBeNull()
|
||||
expect(noteLine.querySelector('script')).toBeNull()
|
||||
expect(noteLine.textContent).toContain('<script>alert(1)</script>')
|
||||
const transportNote = doc.querySelector('.transport-note')!
|
||||
const transportNote = card('.transport-note')
|
||||
expect(transportNote.querySelector('strong')?.textContent).toBe('14A')
|
||||
expect([...transportNote.querySelectorAll('ol li')].map(li => li.textContent)).toEqual(['check in', 'board'])
|
||||
expect(html).not.toContain('**')
|
||||
|
||||
Reference in New Issue
Block a user