summaryrefslogtreecommitdiff
path: root/packages/webapi/test/urlpattern.js
blob: aac7f9d4eb71e0454626b977c99f1c126557c134 (plain) (blame)
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
import { assert, test } from '../run/test.setup.js'
import { polyfill } from '../mod.js'

test(() => {
	return [
		{
			name: 'Includes URLPattern',
			test() {
				const target = {}

				polyfill(target)

				assert.equal(Reflect.has(target, 'URLPattern'), true)
				assert.equal(typeof target.URLPattern, 'function')
			},
		},
		{
			name: 'Supports URLPattern usage',
			test() {
				const target = {}

				polyfill(target)

				const pattern = new target.URLPattern({ pathname: '/hello/:name' })
				const match = pattern.exec('https://example.com/hello/Deno')

				assert.deepEqual(match.pathname.groups, { name: 'Deno' })
			},
		},
	]
})