debian-mirror-gitlab/spec/frontend/vue_shared/alert_details/router_spec.js

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

36 lines
1.1 KiB
JavaScript
Raw Normal View History

2023-01-13 00:05:48 +05:30
import createRouter from '~/vue_shared/alert_details/router';
import setWindowLocation from 'helpers/set_window_location_helper';
const BASE_PATH = '/-/alert_management/1/details';
const EMPTY_HASH = '';
const NOOP = () => {};
describe('AlertDetails router', () => {
const originalLocation = window.location.href;
let router;
beforeEach(() => {
setWindowLocation(originalLocation);
router = createRouter(BASE_PATH);
});
describe('redirects hash route mode URLs to history route mode', () => {
it.each`
hashPath | historyPath
${'/#/overview'} | ${'/overview'}
${'#/overview'} | ${'/overview'}
${'/#/'} | ${'/'}
${'#/'} | ${'/'}
${'/#'} | ${'/'}
${'#'} | ${'/'}
${'/'} | ${'/'}
${'/overview'} | ${'/overview'}
`('should redirect "$hashPath" to "$historyPath"', ({ hashPath, historyPath }) => {
router.push(hashPath, NOOP);
expect(window.location.hash).toBe(EMPTY_HASH);
expect(window.location.pathname).toBe(BASE_PATH + historyPath);
});
});
});