import getBasename from './getBasename'; function setLocationTo(path: string) { // @ts-expect-error legacy, reason unknown delete window.location; // @ts-expect-error legacy, reason unknown window.location = new URL(`https://www.example.com${path}`); } describe('getBasename', () => { it.each([ ['/', '/'], ['/shell', '/shell'], ['/inventory', '/'], ['/shell/inventory', '/shell'], ['/inventory/foo/bar/baz', '/'], ['/shell/inventory/foo/bar/baz', '/shell'], ])( 'gets the basename for location %s correctly', (path, expectedBasename) => { setLocationTo(path); expect(getBasename()).toEqual(expectedBasename); }, ); });