astro/packages/webapi/test/urlpattern.js
Nate Moore f18ee36dc0
Add @astrojs/webapi package (#2729)
* chore: add @astrojs/webapi

* chore: update package.json

* fix: update file case

* fix: remove lowercase file

* chore: update tests to use mocha

* chore: update LICENSE
2022-03-07 15:36:22 -06:00

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