deno.land / x / oauth4webapi@v1.2.2 / test / issue-13.test.ts

issue-13.test.ts
View Documentation
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
28
29
30
31
32
33
34
35
36
// see https://github.com/panva/oauth4webapi/issues/13
import anyTest, { type TestFn } from 'ava'import setup, { type Context, teardown, issuer, UA } from './_setup.js'
const test = anyTest as TestFn<Context>
test.before(setup)test.after(teardown)
test('when in browser does not set custom user-agent', async (t) => { // All browser navigator user-agent strings start with Mozilla/5.0 // It is unlikely to ever change too // @ts-expect-error globalThis.navigator = { userAgent: 'Mozilla/5.0 foo' }
const lib = await import('../src/index.js') const data = { ...issuer } t.context .intercept({ path: '/.well-known/openid-configuration', method: 'GET', headers(headers) { if (UA.test(headers['user-agent'])) { t.fail() } else { t.pass() } return true }, }) .reply(200, data)
await lib.discoveryRequest(new URL(issuer.issuer))})
oauth4webapi

Version Info

Tagged at
2 years ago