diff options
Diffstat (limited to 'spec/frontend/profile/utils_spec.js')
-rw-r--r-- | spec/frontend/profile/utils_spec.js | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/spec/frontend/profile/utils_spec.js b/spec/frontend/profile/utils_spec.js new file mode 100644 index 00000000000..43537afe169 --- /dev/null +++ b/spec/frontend/profile/utils_spec.js @@ -0,0 +1,15 @@ +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); + }); +}); |