debian-mirror-gitlab/spec/frontend/vue_shared/alert_details/router_spec.js
2023-01-13 15:02:22 +05:30

35 lines
1.1 KiB
JavaScript

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);
});
});
});