v1.0 with SW PWA enabled
This commit is contained in:
55
frontend/node_modules/react-day-picker/src/contexts/Navigation/utils/getPreviousMonth.test.ts
generated
vendored
Normal file
55
frontend/node_modules/react-day-picker/src/contexts/Navigation/utils/getPreviousMonth.test.ts
generated
vendored
Normal file
@ -0,0 +1,55 @@
|
||||
import { addMonths, isSameMonth } from 'date-fns';
|
||||
|
||||
import { getPreviousMonth } from './getPreviousMonth';
|
||||
|
||||
const startingMonth = new Date(2020, 4, 31);
|
||||
|
||||
describe('when number of months is 1', () => {
|
||||
describe('when the navigation is disabled', () => {
|
||||
const disableNavigation = true;
|
||||
it('the previous month is undefined', () => {
|
||||
const result = getPreviousMonth(startingMonth, { disableNavigation });
|
||||
expect(result).toBe(undefined);
|
||||
});
|
||||
});
|
||||
describe('when in the navigable range', () => {
|
||||
const fromDate = addMonths(startingMonth, -3);
|
||||
it('the previous month is not undefined', () => {
|
||||
const result = getPreviousMonth(startingMonth, { fromDate });
|
||||
const expectedPrevMonth = addMonths(startingMonth, -1);
|
||||
expect(result && isSameMonth(result, expectedPrevMonth)).toBeTruthy();
|
||||
});
|
||||
});
|
||||
describe('when not in the navigable range', () => {
|
||||
const fromDate = startingMonth;
|
||||
it('the previous month is undefined', () => {
|
||||
const result = getPreviousMonth(startingMonth, { fromDate });
|
||||
expect(result).toBe(undefined);
|
||||
});
|
||||
});
|
||||
});
|
||||
describe('when displaying 3 months', () => {
|
||||
const numberOfMonths = 3;
|
||||
describe('when the navigation is paged', () => {
|
||||
const pagedNavigation = true;
|
||||
it('the previous month is 3 months back', () => {
|
||||
const result = getPreviousMonth(startingMonth, {
|
||||
numberOfMonths,
|
||||
pagedNavigation
|
||||
});
|
||||
const expectedPrevMonth = addMonths(startingMonth, -numberOfMonths);
|
||||
expect(result && isSameMonth(result, expectedPrevMonth)).toBeTruthy();
|
||||
});
|
||||
});
|
||||
describe('when the navigation is not paged', () => {
|
||||
const pagedNavigation = false;
|
||||
it('the previous month is 1 months back', () => {
|
||||
const result = getPreviousMonth(startingMonth, {
|
||||
numberOfMonths,
|
||||
pagedNavigation
|
||||
});
|
||||
const expectedPrevMonth = addMonths(startingMonth, -1);
|
||||
expect(result && isSameMonth(result, expectedPrevMonth)).toBeTruthy();
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user