2022-04-10 20:29:46 -05:00
|
|
|
import { expect } from 'chai'
|
2022-03-07 16:36:22 -05:00
|
|
|
import { polyfill } from '../mod.js'
|
|
|
|
|
2022-04-10 20:29:46 -05:00
|
|
|
describe('URLPattern', () => {
|
|
|
|
const target = {}
|
2022-03-07 16:36:22 -05:00
|
|
|
|
2022-04-10 20:29:46 -05:00
|
|
|
before(() => polyfill(target))
|
2022-03-07 16:37:50 -05:00
|
|
|
|
2022-04-10 20:29:46 -05:00
|
|
|
it('Includes URLPattern', () => {
|
|
|
|
expect(target).to.have.property('URLPattern').that.is.a('function')
|
|
|
|
})
|
2022-03-07 16:36:22 -05:00
|
|
|
|
2022-04-10 20:29:46 -05:00
|
|
|
it('Supports URLPattern usage', () => {
|
|
|
|
const pattern = new target.URLPattern({ pathname: '/hello/:name' })
|
|
|
|
const match = pattern.exec('https://example.com/hello/Deno')
|
2022-03-07 16:36:22 -05:00
|
|
|
|
2022-04-10 20:29:46 -05:00
|
|
|
expect(match.pathname.groups).to.deep.equal({ name: 'Deno' })
|
|
|
|
})
|
2022-03-07 16:36:22 -05:00
|
|
|
})
|