summaryrefslogtreecommitdiff
path: root/packages/webapi/test/urlpattern.js
blob: cc74d7738f9f0c04a0b568309da50c7f081b291d (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' })
			},
		},
	]
})