debian-mirror-gitlab/spec/frontend/lib/utils/is_navigating_away_spec.js

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

24 lines
692 B
JavaScript
Raw Normal View History

2021-11-18 22:05:49 +05:30
import { isNavigatingAway, setNavigatingForTestsOnly } from '~/lib/utils/is_navigating_away';
describe('isNavigatingAway', () => {
beforeEach(() => {
// Make sure each test starts with the same state
setNavigatingForTestsOnly(false);
});
it.each([false, true])('it returns the navigation flag with value %s', (flag) => {
setNavigatingForTestsOnly(flag);
expect(isNavigatingAway()).toEqual(flag);
});
describe('when the browser starts navigating away', () => {
it('returns true', () => {
expect(isNavigatingAway()).toEqual(false);
window.dispatchEvent(new Event('beforeunload'));
expect(isNavigatingAway()).toEqual(true);
});
});
});