-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvalidation.test.ts
27 lines (23 loc) · 987 Bytes
/
validation.test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import { data } from './config'
import { navigate, fillWith } from './utils'
test('errors if the csrfToken is not found in memory', async () => {
await navigate('/', { code: data.goodCode, state: 'x' })
await expect(page).toHaveText('"error": "unknown \\"state\\""')
})
test('errors if the missing csrfToken', async () => {
await navigate('/', { code: data.goodCode })
await expect(page).toHaveText('"error": "invalid query string"')
})
test('errors if the missing code', async () => {
await navigate('/', { state: 'x' })
await expect(page).toHaveText('"error": "invalid query string"')
})
test.each([['clientId'], ['clientSecret']])(
'errors if submitted with missing "%s" field',
async (field) => {
// disable validation so we can actually submit
await page.$eval('form', (e) => (e.noValidate = true))
await Promise.all([page.waitForNavigation(), fillWith({ [field]: '' })])
await expect(page).toHaveText('body', '"error": "invalid values"')
},
)