debian-mirror-gitlab/spec/frontend/profile/utils_spec.js
2023-05-27 22:25:52 +05:30

15 lines
610 B
JavaScript

import { getVisibleCalendarPeriod } from '~/profile/utils';
import { CALENDAR_PERIOD_12_MONTHS, CALENDAR_PERIOD_6_MONTHS } from '~/profile/constants';
describe('getVisibleCalendarPeriod', () => {
it.each`
width | expected
${1000} | ${CALENDAR_PERIOD_12_MONTHS}
${900} | ${CALENDAR_PERIOD_6_MONTHS}
`('returns $expected when container width is $width', ({ width, expected }) => {
const container = document.createElement('div');
jest.spyOn(container, 'getBoundingClientRect').mockReturnValueOnce({ width });
expect(getVisibleCalendarPeriod(container)).toBe(expected);
});
});