Spaces:
Running
Running
File size: 809 Bytes
d4b85c0 |
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 32 |
/**
* @vitest-environment jsdom
*/
import { getAbsoluteWorkerUrl } from './getAbsoluteWorkerUrl'
const rawLocation = window.location
afterAll(() => {
Object.defineProperty(window, 'location', {
value: rawLocation,
})
})
it('returns absolute worker url relatively to the root', () => {
expect(getAbsoluteWorkerUrl('./worker.js')).toBe('http://localhost/worker.js')
})
it('returns an absolute worker url relatively to the current path', () => {
Object.defineProperty(window, 'location', {
value: {
href: 'http://localhost/path/to/page',
},
})
expect(getAbsoluteWorkerUrl('./worker.js')).toBe(
'http://localhost/path/to/worker.js',
)
// Leading slash must still resolve to the root.
expect(getAbsoluteWorkerUrl('/worker.js')).toBe('http://localhost/worker.js')
})
|