2022-04-11 01:29:46 +00:00
|
|
|
import { expect } from 'chai'
|
2022-03-07 21:36:22 +00:00
|
|
|
import { polyfill } from '../mod.js'
|
|
|
|
|
2022-04-11 01:29:46 +00:00
|
|
|
describe('URLPattern', () => {
|
|
|
|
const target = {}
|
2022-03-07 21:36:22 +00:00
|
|
|
|
2022-04-11 01:29:46 +00:00
|
|
|
before(() => polyfill(target))
|
2022-03-07 21:37:50 +00:00
|
|
|
|
2022-04-11 01:29:46 +00:00
|
|
|
it('Includes URLPattern', () => {
|
|
|
|
expect(target).to.have.property('URLPattern').that.is.a('function')
|
|
|
|
})
|
2022-03-07 21:36:22 +00:00
|
|
|
|
2022-04-11 01:29:46 +00: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 21:36:22 +00:00
|
|
|
|
2022-04-11 01:29:46 +00:00
|
|
|
expect(match.pathname.groups).to.deep.equal({ name: 'Deno' })
|
|
|
|
})
|
2022-03-07 21:36:22 +00:00
|
|
|
})
|