0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2024-12-23 21:53:55 -05:00
astro/packages/webapi/test/urlpattern.js
2022-03-07 21:37:50 +00:00

31 lines
646 B
JavaScript

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' })
},
},
]
})