Commit 71e0fb5d authored by Phil Hughes's avatar Phil Hughes

Merge branch 'mw-remove-breakpoints' into 'master'

Remove breakpoints utils

Closes #38327

See merge request gitlab-org/gitlab!22383
parents 430a2ccd f49a15b9
export const breakpoints = {
lg: 1200,
md: 992,
sm: 768,
xs: 0,
};
const BreakpointInstance = {
windowWidth: () => window.innerWidth,
getBreakpointSize() {
const windowWidth = this.windowWidth();
const breakpoint = Object.keys(breakpoints).find(key => windowWidth > breakpoints[key]);
return breakpoint;
},
isDesktop() {
return ['lg', 'md'].includes(this.getBreakpointSize());
},
};
export default BreakpointInstance;
import bp, { breakpoints } from '~/breakpoints';
describe('breakpoints', () => {
Object.keys(breakpoints).forEach(key => {
const size = breakpoints[key];
it(`returns ${key} when larger than ${size}`, () => {
jest.spyOn(bp, 'windowWidth').mockReturnValue(size + 10);
expect(bp.getBreakpointSize()).toBe(key);
});
});
describe('isDesktop', () => {
it('returns true when screen size is medium', () => {
jest.spyOn(bp, 'windowWidth').mockReturnValue(breakpoints.md + 10);
expect(bp.isDesktop()).toBe(true);
});
it('returns false when screen size is small', () => {
jest.spyOn(bp, 'windowWidth').mockReturnValue(breakpoints.sm + 10);
expect(bp.isDesktop()).toBe(false);
});
});
});
......@@ -3,7 +3,6 @@ import MockAdapter from 'axios-mock-adapter';
import axios from '~/lib/utils/axios_utils';
import MergeRequestTabs from '~/merge_request_tabs';
import '~/commit/pipelines/pipelines_bundle';
import '~/breakpoints';
import '~/lib/utils/common_utils';
import 'vendor/jquery.scrollTo';
import initMrPage from './helpers/init_vue_mr_page_helper';
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment