2018-01-31 04:27:30 -05:00
|
|
|
import MockAdapter from 'axios-mock-adapter';
|
2021-02-14 13:09:20 -05:00
|
|
|
import $ from 'jquery';
|
2020-08-17 17:09:56 -04:00
|
|
|
import initMrPage from 'helpers/init_vue_mr_page_helper';
|
2018-01-30 12:23:27 -05:00
|
|
|
import axios from '~/lib/utils/axios_utils';
|
2017-12-15 04:31:58 -05:00
|
|
|
import MergeRequestTabs from '~/merge_request_tabs';
|
2017-05-16 17:01:51 -04:00
|
|
|
import '~/lib/utils/common_utils';
|
2018-06-21 08:22:40 -04:00
|
|
|
|
2020-06-08 05:08:23 -04:00
|
|
|
jest.mock('~/lib/utils/webpack', () => ({
|
|
|
|
resetServiceWorkersPublicPath: jest.fn(),
|
|
|
|
}));
|
|
|
|
|
|
|
|
describe('MergeRequestTabs', () => {
|
|
|
|
const testContext = {};
|
2019-11-14 13:06:15 -05:00
|
|
|
const stubLocation = {};
|
2020-12-23 16:10:24 -05:00
|
|
|
const setLocation = (stubs) => {
|
2019-11-14 13:06:15 -05:00
|
|
|
const defaults = {
|
2018-06-21 08:22:40 -04:00
|
|
|
pathname: '',
|
|
|
|
search: '',
|
|
|
|
hash: '',
|
2016-07-24 16:45:11 -04:00
|
|
|
};
|
2018-06-21 08:22:40 -04:00
|
|
|
$.extend(stubLocation, defaults, stubs || {});
|
|
|
|
};
|
2017-06-21 02:36:08 -04:00
|
|
|
|
2020-06-08 05:08:23 -04:00
|
|
|
beforeEach(() => {
|
|
|
|
initMrPage();
|
|
|
|
|
|
|
|
testContext.class = new MergeRequestTabs({ stubLocation });
|
2018-06-21 08:22:40 -04:00
|
|
|
setLocation();
|
2017-02-09 17:19:12 -05:00
|
|
|
|
2020-06-08 05:08:23 -04:00
|
|
|
testContext.spies = {
|
|
|
|
history: jest.spyOn(window.history, 'pushState').mockImplementation(() => {}),
|
2018-06-21 08:22:40 -04:00
|
|
|
};
|
2017-02-09 17:19:12 -05:00
|
|
|
|
2020-06-08 05:08:23 -04:00
|
|
|
gl.mrWidget = {};
|
2018-06-21 08:22:40 -04:00
|
|
|
});
|
2017-02-09 17:19:12 -05:00
|
|
|
|
2021-08-24 14:10:53 -04:00
|
|
|
describe('clickTab', () => {
|
|
|
|
let params;
|
|
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
document.documentElement.scrollTop = 100;
|
|
|
|
|
|
|
|
params = {
|
|
|
|
metaKey: false,
|
|
|
|
ctrlKey: false,
|
|
|
|
which: 1,
|
|
|
|
stopImmediatePropagation() {},
|
|
|
|
preventDefault() {},
|
|
|
|
currentTarget: {
|
|
|
|
getAttribute(attr) {
|
|
|
|
return attr === 'href' ? 'a/tab/url' : null;
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
});
|
|
|
|
|
|
|
|
it("stores the current scroll position if there's an active tab", () => {
|
|
|
|
testContext.class.currentTab = 'someTab';
|
|
|
|
|
|
|
|
testContext.class.clickTab(params);
|
|
|
|
|
|
|
|
expect(testContext.class.scrollPositions.someTab).toBe(100);
|
|
|
|
});
|
|
|
|
|
|
|
|
it("doesn't store a scroll position if there's no active tab", () => {
|
|
|
|
// this happens on first load, and we just don't want to store empty values in the `null` property
|
|
|
|
testContext.class.currentTab = null;
|
|
|
|
|
|
|
|
testContext.class.clickTab(params);
|
|
|
|
|
|
|
|
expect(testContext.class.scrollPositions).toEqual({});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2020-06-08 05:08:23 -04:00
|
|
|
describe('opensInNewTab', () => {
|
2019-11-14 13:06:15 -05:00
|
|
|
const windowTarget = '_blank';
|
2019-06-11 16:40:57 -04:00
|
|
|
let clickTabParams;
|
2019-11-14 13:06:15 -05:00
|
|
|
let tabUrl;
|
2017-02-09 17:19:12 -05:00
|
|
|
|
2020-06-08 05:08:23 -04:00
|
|
|
beforeEach(() => {
|
2019-03-26 12:03:28 -04:00
|
|
|
loadFixtures('merge_requests/merge_request_with_task_list.html');
|
2017-02-09 17:19:12 -05:00
|
|
|
|
2018-06-21 08:22:40 -04:00
|
|
|
tabUrl = $('.commits-tab a').attr('href');
|
2019-06-11 16:40:57 -04:00
|
|
|
|
|
|
|
clickTabParams = {
|
|
|
|
metaKey: false,
|
|
|
|
ctrlKey: false,
|
|
|
|
which: 1,
|
2019-09-18 10:02:45 -04:00
|
|
|
stopImmediatePropagation() {},
|
|
|
|
preventDefault() {},
|
2019-06-11 16:40:57 -04:00
|
|
|
currentTarget: {
|
2019-09-18 10:02:45 -04:00
|
|
|
getAttribute(attr) {
|
2019-06-11 16:40:57 -04:00
|
|
|
return attr === 'href' ? tabUrl : null;
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
2018-06-21 08:22:40 -04:00
|
|
|
});
|
2017-02-07 11:45:27 -05:00
|
|
|
|
2018-06-21 08:22:40 -04:00
|
|
|
describe('meta click', () => {
|
|
|
|
let metakeyEvent;
|
2019-06-11 16:40:57 -04:00
|
|
|
|
2020-06-08 05:08:23 -04:00
|
|
|
beforeEach(() => {
|
2018-06-21 08:22:40 -04:00
|
|
|
metakeyEvent = $.Event('click', { keyCode: 91, ctrlKey: true });
|
2017-02-06 05:06:57 -05:00
|
|
|
});
|
2017-04-07 00:19:30 -04:00
|
|
|
|
2020-06-08 05:08:23 -04:00
|
|
|
it('opens page when commits link is clicked', () => {
|
|
|
|
jest.spyOn(window, 'open').mockImplementation((url, name) => {
|
2017-02-07 11:45:27 -05:00
|
|
|
expect(url).toEqual(tabUrl);
|
2017-02-09 17:19:12 -05:00
|
|
|
expect(name).toEqual(windowTarget);
|
2017-02-07 11:45:27 -05:00
|
|
|
});
|
|
|
|
|
2020-06-08 05:08:23 -04:00
|
|
|
testContext.class.bindEvents();
|
2018-06-21 08:22:40 -04:00
|
|
|
$('.merge-request-tabs .commits-tab a').trigger(metakeyEvent);
|
2019-06-11 16:40:57 -04:00
|
|
|
|
|
|
|
expect(window.open).toHaveBeenCalled();
|
2017-02-06 05:06:57 -05:00
|
|
|
});
|
2017-04-07 00:19:30 -04:00
|
|
|
|
2020-06-08 05:08:23 -04:00
|
|
|
it('opens page when commits badge is clicked', () => {
|
|
|
|
jest.spyOn(window, 'open').mockImplementation((url, name) => {
|
2017-02-07 11:45:27 -05:00
|
|
|
expect(url).toEqual(tabUrl);
|
2017-02-09 17:19:12 -05:00
|
|
|
expect(name).toEqual(windowTarget);
|
2017-02-07 11:45:27 -05:00
|
|
|
});
|
|
|
|
|
2020-06-08 05:08:23 -04:00
|
|
|
testContext.class.bindEvents();
|
2018-06-21 08:22:40 -04:00
|
|
|
$('.merge-request-tabs .commits-tab a .badge').trigger(metakeyEvent);
|
2019-06-11 16:40:57 -04:00
|
|
|
|
|
|
|
expect(window.open).toHaveBeenCalled();
|
2017-02-07 01:04:42 -05:00
|
|
|
});
|
2017-02-06 05:06:57 -05:00
|
|
|
});
|
2016-10-27 16:32:30 -04:00
|
|
|
|
2020-06-08 05:08:23 -04:00
|
|
|
it('opens page tab in a new browser tab with Ctrl+Click - Windows/Linux', () => {
|
|
|
|
jest.spyOn(window, 'open').mockImplementation((url, name) => {
|
2018-06-21 08:22:40 -04:00
|
|
|
expect(url).toEqual(tabUrl);
|
|
|
|
expect(name).toEqual(windowTarget);
|
2016-07-24 16:45:11 -04:00
|
|
|
});
|
2017-04-07 00:19:30 -04:00
|
|
|
|
2020-06-08 05:08:23 -04:00
|
|
|
testContext.class.clickTab({ ...clickTabParams, metaKey: true });
|
2019-06-11 16:40:57 -04:00
|
|
|
|
|
|
|
expect(window.open).toHaveBeenCalled();
|
2018-06-21 08:22:40 -04:00
|
|
|
});
|
2017-04-07 00:19:30 -04:00
|
|
|
|
2020-06-08 05:08:23 -04:00
|
|
|
it('opens page tab in a new browser tab with Cmd+Click - Mac', () => {
|
|
|
|
jest.spyOn(window, 'open').mockImplementation((url, name) => {
|
2018-06-21 08:22:40 -04:00
|
|
|
expect(url).toEqual(tabUrl);
|
|
|
|
expect(name).toEqual(windowTarget);
|
2016-07-24 16:45:11 -04:00
|
|
|
});
|
2017-04-07 00:19:30 -04:00
|
|
|
|
2020-06-08 05:08:23 -04:00
|
|
|
testContext.class.clickTab({ ...clickTabParams, ctrlKey: true });
|
2019-06-11 16:40:57 -04:00
|
|
|
|
|
|
|
expect(window.open).toHaveBeenCalled();
|
2018-06-21 08:22:40 -04:00
|
|
|
});
|
2017-04-07 00:19:30 -04:00
|
|
|
|
2020-06-08 05:08:23 -04:00
|
|
|
it('opens page tab in a new browser tab with Middle-click - Mac/PC', () => {
|
|
|
|
jest.spyOn(window, 'open').mockImplementation((url, name) => {
|
2018-06-21 08:22:40 -04:00
|
|
|
expect(url).toEqual(tabUrl);
|
|
|
|
expect(name).toEqual(windowTarget);
|
2016-07-24 16:45:11 -04:00
|
|
|
});
|
2017-04-07 00:19:30 -04:00
|
|
|
|
2020-06-08 05:08:23 -04:00
|
|
|
testContext.class.clickTab({ ...clickTabParams, which: 2 });
|
2019-06-11 16:40:57 -04:00
|
|
|
|
|
|
|
expect(window.open).toHaveBeenCalled();
|
2016-07-24 16:45:11 -04:00
|
|
|
});
|
2018-06-21 08:22:40 -04:00
|
|
|
});
|
2017-03-22 22:39:09 -04:00
|
|
|
|
2020-06-08 05:08:23 -04:00
|
|
|
describe('setCurrentAction', () => {
|
2018-06-21 08:22:40 -04:00
|
|
|
let mock;
|
2018-01-30 12:23:27 -05:00
|
|
|
|
2020-06-08 05:08:23 -04:00
|
|
|
beforeEach(() => {
|
2018-06-21 08:22:40 -04:00
|
|
|
mock = new MockAdapter(axios);
|
|
|
|
mock.onAny().reply({ data: {} });
|
2020-06-08 05:08:23 -04:00
|
|
|
testContext.subject = testContext.class.setCurrentAction;
|
2018-06-21 08:22:40 -04:00
|
|
|
});
|
2018-01-30 12:23:27 -05:00
|
|
|
|
2018-06-21 08:22:40 -04:00
|
|
|
afterEach(() => {
|
|
|
|
mock.restore();
|
2020-06-02 08:08:33 -04:00
|
|
|
window.history.replaceState({}, '', '/');
|
2018-06-21 08:22:40 -04:00
|
|
|
});
|
2017-03-22 22:39:09 -04:00
|
|
|
|
2020-06-08 05:08:23 -04:00
|
|
|
it('changes from commits', () => {
|
2018-06-21 08:22:40 -04:00
|
|
|
setLocation({
|
2020-01-20 19:08:46 -05:00
|
|
|
pathname: '/foo/bar/-/merge_requests/1/commits',
|
2018-01-30 12:23:27 -05:00
|
|
|
});
|
|
|
|
|
2020-06-08 05:08:23 -04:00
|
|
|
expect(testContext.subject('show')).toBe('/foo/bar/-/merge_requests/1');
|
|
|
|
expect(testContext.subject('diffs')).toBe('/foo/bar/-/merge_requests/1/diffs');
|
2017-03-22 22:39:09 -04:00
|
|
|
});
|
|
|
|
|
2020-06-08 05:08:23 -04:00
|
|
|
it('changes from diffs', () => {
|
2018-06-21 08:22:40 -04:00
|
|
|
setLocation({
|
2020-01-20 19:08:46 -05:00
|
|
|
pathname: '/foo/bar/-/merge_requests/1/diffs',
|
2017-06-21 02:36:08 -04:00
|
|
|
});
|
|
|
|
|
2020-06-08 05:08:23 -04:00
|
|
|
expect(testContext.subject('show')).toBe('/foo/bar/-/merge_requests/1');
|
|
|
|
expect(testContext.subject('commits')).toBe('/foo/bar/-/merge_requests/1/commits');
|
2018-06-21 08:22:40 -04:00
|
|
|
});
|
2017-10-06 16:36:15 -04:00
|
|
|
|
2020-06-08 05:08:23 -04:00
|
|
|
it('changes from diffs.html', () => {
|
2018-06-21 08:22:40 -04:00
|
|
|
setLocation({
|
2020-01-20 19:08:46 -05:00
|
|
|
pathname: '/foo/bar/-/merge_requests/1/diffs.html',
|
2017-06-21 02:36:08 -04:00
|
|
|
});
|
|
|
|
|
2020-06-08 05:08:23 -04:00
|
|
|
expect(testContext.subject('show')).toBe('/foo/bar/-/merge_requests/1');
|
|
|
|
expect(testContext.subject('commits')).toBe('/foo/bar/-/merge_requests/1/commits');
|
2018-06-21 08:22:40 -04:00
|
|
|
});
|
2017-05-24 21:41:41 -04:00
|
|
|
|
2020-06-08 05:08:23 -04:00
|
|
|
it('changes from notes', () => {
|
2018-06-21 08:22:40 -04:00
|
|
|
setLocation({
|
2020-01-20 19:08:46 -05:00
|
|
|
pathname: '/foo/bar/-/merge_requests/1',
|
2016-11-17 07:05:32 -05:00
|
|
|
});
|
2017-08-29 08:34:12 -04:00
|
|
|
|
2020-06-08 05:08:23 -04:00
|
|
|
expect(testContext.subject('diffs')).toBe('/foo/bar/-/merge_requests/1/diffs');
|
|
|
|
expect(testContext.subject('commits')).toBe('/foo/bar/-/merge_requests/1/commits');
|
2018-06-21 08:22:40 -04:00
|
|
|
});
|
2017-08-29 08:34:12 -04:00
|
|
|
|
2020-06-08 05:08:23 -04:00
|
|
|
it('includes search parameters and hash string', () => {
|
2018-06-21 08:22:40 -04:00
|
|
|
setLocation({
|
2020-01-20 19:08:46 -05:00
|
|
|
pathname: '/foo/bar/-/merge_requests/1/diffs',
|
2018-06-21 08:22:40 -04:00
|
|
|
search: '?view=parallel',
|
|
|
|
hash: '#L15-35',
|
2017-08-29 08:34:12 -04:00
|
|
|
});
|
2017-05-24 21:41:41 -04:00
|
|
|
|
2020-06-08 05:08:23 -04:00
|
|
|
expect(testContext.subject('show')).toBe('/foo/bar/-/merge_requests/1?view=parallel#L15-35');
|
2018-06-21 08:22:40 -04:00
|
|
|
});
|
2017-06-21 02:36:08 -04:00
|
|
|
|
2020-06-08 05:08:23 -04:00
|
|
|
it('replaces the current history state', () => {
|
2018-06-21 08:22:40 -04:00
|
|
|
setLocation({
|
2020-01-20 19:08:46 -05:00
|
|
|
pathname: '/foo/bar/-/merge_requests/1',
|
2017-06-21 02:36:08 -04:00
|
|
|
});
|
2020-06-02 08:08:33 -04:00
|
|
|
window.history.replaceState(
|
|
|
|
{
|
|
|
|
url: window.location.href,
|
|
|
|
action: 'show',
|
|
|
|
},
|
|
|
|
document.title,
|
|
|
|
window.location.href,
|
|
|
|
);
|
|
|
|
|
2020-06-08 05:08:23 -04:00
|
|
|
const newState = testContext.subject('commits');
|
2017-06-21 02:36:08 -04:00
|
|
|
|
2020-06-08 05:08:23 -04:00
|
|
|
expect(testContext.spies.history).toHaveBeenCalledWith(
|
2018-06-21 08:22:40 -04:00
|
|
|
{
|
|
|
|
url: newState,
|
2020-06-02 08:08:33 -04:00
|
|
|
action: 'commits',
|
2018-06-21 08:22:40 -04:00
|
|
|
},
|
|
|
|
document.title,
|
|
|
|
newState,
|
|
|
|
);
|
|
|
|
});
|
2017-06-21 02:36:08 -04:00
|
|
|
|
2020-06-08 05:08:23 -04:00
|
|
|
it('treats "show" like "notes"', () => {
|
2018-06-21 08:22:40 -04:00
|
|
|
setLocation({
|
2020-01-20 19:08:46 -05:00
|
|
|
pathname: '/foo/bar/-/merge_requests/1/commits',
|
2017-05-24 21:41:41 -04:00
|
|
|
});
|
2018-06-21 08:22:40 -04:00
|
|
|
|
2020-06-08 05:08:23 -04:00
|
|
|
expect(testContext.subject('show')).toBe('/foo/bar/-/merge_requests/1');
|
2016-11-17 07:05:32 -05:00
|
|
|
});
|
2018-06-21 08:22:40 -04:00
|
|
|
});
|
2017-09-22 12:53:34 -04:00
|
|
|
|
2020-06-08 05:08:23 -04:00
|
|
|
describe('expandViewContainer', () => {
|
2018-06-21 08:22:40 -04:00
|
|
|
beforeEach(() => {
|
|
|
|
$('body').append(
|
|
|
|
'<div class="content-wrapper"><div class="container-fluid container-limited"></div></div>',
|
|
|
|
);
|
|
|
|
});
|
2017-09-22 12:53:34 -04:00
|
|
|
|
2018-06-21 08:22:40 -04:00
|
|
|
afterEach(() => {
|
|
|
|
$('.content-wrapper').remove();
|
|
|
|
});
|
2017-09-22 12:53:34 -04:00
|
|
|
|
2020-06-08 05:08:23 -04:00
|
|
|
it('removes container-limited from containers', () => {
|
|
|
|
testContext.class.expandViewContainer();
|
2017-09-22 12:53:34 -04:00
|
|
|
|
2020-06-08 05:08:23 -04:00
|
|
|
expect($('.content-wrapper .container-limited')).toHaveLength(0);
|
2018-06-21 08:22:40 -04:00
|
|
|
});
|
2017-09-22 12:53:34 -04:00
|
|
|
|
2020-06-08 05:08:23 -04:00
|
|
|
it('does not add container-limited when fluid layout is prefered', () => {
|
2018-10-19 05:37:42 -04:00
|
|
|
$('.content-wrapper .container-fluid').removeClass('container-limited');
|
|
|
|
|
2020-06-08 05:08:23 -04:00
|
|
|
testContext.class.expandViewContainer(false);
|
2018-10-19 05:37:42 -04:00
|
|
|
|
2020-06-08 05:08:23 -04:00
|
|
|
expect($('.content-wrapper .container-limited')).toHaveLength(0);
|
2018-10-19 05:37:42 -04:00
|
|
|
});
|
|
|
|
|
2020-06-08 05:08:23 -04:00
|
|
|
it('does remove container-limited from breadcrumbs', () => {
|
2018-06-21 08:22:40 -04:00
|
|
|
$('.container-limited').addClass('breadcrumbs');
|
2020-06-08 05:08:23 -04:00
|
|
|
testContext.class.expandViewContainer();
|
2017-09-22 12:53:34 -04:00
|
|
|
|
2020-06-08 05:08:23 -04:00
|
|
|
expect($('.content-wrapper .container-limited')).toHaveLength(1);
|
2017-09-22 12:53:34 -04:00
|
|
|
});
|
2016-07-24 16:45:11 -04:00
|
|
|
});
|
2018-11-27 13:05:16 -05:00
|
|
|
|
2020-06-08 05:08:23 -04:00
|
|
|
describe('tabShown', () => {
|
2018-11-27 13:05:16 -05:00
|
|
|
const mainContent = document.createElement('div');
|
|
|
|
const tabContent = document.createElement('div');
|
|
|
|
|
2020-06-08 05:08:23 -04:00
|
|
|
beforeEach(() => {
|
|
|
|
jest.spyOn(mainContent, 'getBoundingClientRect').mockReturnValue({ top: 10 });
|
|
|
|
jest.spyOn(tabContent, 'getBoundingClientRect').mockReturnValue({ top: 100 });
|
2021-08-24 14:10:53 -04:00
|
|
|
jest.spyOn(window, 'scrollTo').mockImplementation(() => {});
|
2020-12-23 16:10:24 -05:00
|
|
|
jest.spyOn(document, 'querySelector').mockImplementation((selector) => {
|
2018-11-27 13:05:16 -05:00
|
|
|
return selector === '.content-wrapper' ? mainContent : tabContent;
|
|
|
|
});
|
2020-06-08 05:08:23 -04:00
|
|
|
testContext.class.currentAction = 'commits';
|
2018-11-27 13:05:16 -05:00
|
|
|
});
|
|
|
|
|
2020-06-08 05:08:23 -04:00
|
|
|
it('calls window scrollTo with options if document has scrollBehavior', () => {
|
2018-11-27 13:05:16 -05:00
|
|
|
document.documentElement.style.scrollBehavior = '';
|
|
|
|
|
2020-06-08 05:08:23 -04:00
|
|
|
testContext.class.tabShown('commits', 'foobar');
|
2018-11-27 13:05:16 -05:00
|
|
|
|
2020-06-08 05:08:23 -04:00
|
|
|
expect(window.scrollTo.mock.calls[0][0]).toEqual({ top: 39, behavior: 'smooth' });
|
2018-11-27 13:05:16 -05:00
|
|
|
});
|
|
|
|
|
2020-06-08 05:08:23 -04:00
|
|
|
it('calls window scrollTo with two args if document does not have scrollBehavior', () => {
|
|
|
|
jest.spyOn(document.documentElement, 'style', 'get').mockReturnValue({});
|
2018-11-27 13:05:16 -05:00
|
|
|
|
2020-06-08 05:08:23 -04:00
|
|
|
testContext.class.tabShown('commits', 'foobar');
|
2018-11-27 13:05:16 -05:00
|
|
|
|
2020-06-08 05:08:23 -04:00
|
|
|
expect(window.scrollTo.mock.calls[0]).toEqual([0, 39]);
|
2018-11-27 13:05:16 -05:00
|
|
|
});
|
2021-08-24 14:10:53 -04:00
|
|
|
|
|
|
|
describe('when switching tabs', () => {
|
|
|
|
const SCROLL_TOP = 100;
|
|
|
|
|
|
|
|
beforeAll(() => {
|
|
|
|
jest.useFakeTimers();
|
|
|
|
});
|
|
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
jest.spyOn(window, 'scrollTo').mockImplementation(() => {});
|
|
|
|
testContext.class.mergeRequestTabs = document.createElement('div');
|
|
|
|
testContext.class.mergeRequestTabPanes = document.createElement('div');
|
|
|
|
testContext.class.currentTab = 'tab';
|
|
|
|
testContext.class.scrollPositions = { newTab: SCROLL_TOP };
|
|
|
|
});
|
|
|
|
|
|
|
|
afterAll(() => {
|
|
|
|
jest.useRealTimers();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('scrolls to the stored position, if one is stored', () => {
|
|
|
|
testContext.class.tabShown('newTab');
|
|
|
|
|
|
|
|
jest.advanceTimersByTime(250);
|
|
|
|
|
|
|
|
expect(window.scrollTo.mock.calls[0][0]).toEqual({
|
|
|
|
top: SCROLL_TOP,
|
|
|
|
left: 0,
|
|
|
|
behavior: 'auto',
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('scrolls to 0, if no position is stored', () => {
|
|
|
|
testContext.class.tabShown('unknownTab');
|
|
|
|
|
|
|
|
jest.advanceTimersByTime(250);
|
|
|
|
|
|
|
|
expect(window.scrollTo.mock.calls[0][0]).toEqual({ top: 0, left: 0, behavior: 'auto' });
|
|
|
|
});
|
|
|
|
});
|
2018-11-27 13:05:16 -05:00
|
|
|
});
|
2018-06-21 08:22:40 -04:00
|
|
|
});
|