cronofy-elements 1.42.0 → 1.42.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.yaml +31 -30
- package/build/CronofyElements.v1.42.1.js +2 -0
- package/build/{CronofyElements.v1.42.0.js.LICENSE.txt → CronofyElements.v1.42.1.js.LICENSE.txt} +0 -0
- package/build/npm/CronofyElements.js +2 -2
- package/package.json +1 -1
- package/src/js/components/DateTimePicker/contexts/status-reducer.js +6 -1
- package/src/js/components/DateTimePicker/utils/slots.js +1 -1
- package/tests/DateTimePicker/contexts/status-reducer.test.js +39 -0
- package/tests/DateTimePicker/utils.test.js +46 -0
- package/build/CronofyElements.v1.42.0.js +0 -2
package/package.json
CHANGED
|
@@ -91,7 +91,12 @@ export const statusReducer = (state, action) => {
|
|
|
91
91
|
|
|
92
92
|
case "SET_SLOTS": {
|
|
93
93
|
if (!action.slots.length > 0) {
|
|
94
|
-
|
|
94
|
+
const monthsLoading = removeMonthFromLoading(state.monthsLoading, action.month);
|
|
95
|
+
return {
|
|
96
|
+
...state,
|
|
97
|
+
monthsLoading,
|
|
98
|
+
slotFetchCount: state.slotFetchCount + 1,
|
|
99
|
+
};
|
|
95
100
|
}
|
|
96
101
|
|
|
97
102
|
const slotsObject = addSlotsToObject(state.slots, action.slots);
|
|
@@ -77,7 +77,7 @@ export const getMonthObjectsFromQuery = (query, tzid, current = false) => {
|
|
|
77
77
|
const endMonth = moment(monthStrings[monthStrings.length - 1], "YYYY-MM");
|
|
78
78
|
|
|
79
79
|
const currentMonth =
|
|
80
|
-
current && moment(current, "YYYY-MM").isBetween(startMonth, endMonth)
|
|
80
|
+
current && moment(current, "YYYY-MM").isBetween(startMonth, endMonth, "month", "[]")
|
|
81
81
|
? current
|
|
82
82
|
: monthStrings[0];
|
|
83
83
|
|
|
@@ -340,6 +340,45 @@ describe("Date Time Picker status reducer", () => {
|
|
|
340
340
|
expect(newState).toStrictEqual(oldState);
|
|
341
341
|
});
|
|
342
342
|
|
|
343
|
+
it("sets slots when there are no slots", () => {
|
|
344
|
+
const oldState = {
|
|
345
|
+
...startingState,
|
|
346
|
+
slots: {},
|
|
347
|
+
availableDays: [],
|
|
348
|
+
slotFetchCount: 0,
|
|
349
|
+
slotInjectionPoint: undefined,
|
|
350
|
+
};
|
|
351
|
+
|
|
352
|
+
const result = statusReducer(oldState, {
|
|
353
|
+
type: "SET_SLOTS",
|
|
354
|
+
slots: [],
|
|
355
|
+
month: "2021-09",
|
|
356
|
+
tzid: "Europe/London",
|
|
357
|
+
});
|
|
358
|
+
|
|
359
|
+
delete oldState.slots;
|
|
360
|
+
delete oldState.availableDays;
|
|
361
|
+
delete oldState.slotFetchCount;
|
|
362
|
+
delete oldState.slotInjectionPoint;
|
|
363
|
+
|
|
364
|
+
const {
|
|
365
|
+
slots,
|
|
366
|
+
availableDays,
|
|
367
|
+
slotFetchCount,
|
|
368
|
+
slotInjectionPoint,
|
|
369
|
+
...newState
|
|
370
|
+
} = result;
|
|
371
|
+
|
|
372
|
+
// These values have been updated
|
|
373
|
+
expect(slots).toStrictEqual({});
|
|
374
|
+
expect(availableDays).toStrictEqual([]);
|
|
375
|
+
expect(slotFetchCount).toBe(1);
|
|
376
|
+
expect(slotInjectionPoint).toBe(undefined);
|
|
377
|
+
|
|
378
|
+
// All other values are unchanged
|
|
379
|
+
expect(newState).toStrictEqual(oldState);
|
|
380
|
+
});
|
|
381
|
+
|
|
343
382
|
it("sets additional slots", () => {
|
|
344
383
|
const oldState = {
|
|
345
384
|
...startingState,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as utils from "../../src/js/components/DateTimePicker/utils/slots";
|
|
2
2
|
import { rawSlots } from "./dummy-data";
|
|
3
|
+
import moment from "moment-timezone";
|
|
3
4
|
|
|
4
5
|
describe("DateTimePicker utils", () => {
|
|
5
6
|
it("Gets months from single period", () => {
|
|
@@ -429,6 +430,51 @@ describe("DateTimePicker utils", () => {
|
|
|
429
430
|
|
|
430
431
|
expect(actual).toEqual(expected);
|
|
431
432
|
});
|
|
433
|
+
|
|
434
|
+
it("returns with the correct month set to current when selectedDay is set", () => {
|
|
435
|
+
const selectedDay = "2021-07";
|
|
436
|
+
|
|
437
|
+
const query = {
|
|
438
|
+
query_periods,
|
|
439
|
+
};
|
|
440
|
+
|
|
441
|
+
const expected = [
|
|
442
|
+
{
|
|
443
|
+
month: "2021-06",
|
|
444
|
+
current: false,
|
|
445
|
+
query: {
|
|
446
|
+
query_periods: [
|
|
447
|
+
{
|
|
448
|
+
end: "2021-06-12T23:00:00Z",
|
|
449
|
+
start: "2021-06-11T00:00:00Z",
|
|
450
|
+
},
|
|
451
|
+
{
|
|
452
|
+
end: "2021-06-30T23:59:00Z",
|
|
453
|
+
start: "2021-06-13T00:00:00Z",
|
|
454
|
+
},
|
|
455
|
+
],
|
|
456
|
+
max_results: 512,
|
|
457
|
+
},
|
|
458
|
+
},
|
|
459
|
+
{
|
|
460
|
+
month: "2021-07",
|
|
461
|
+
current: true,
|
|
462
|
+
query: {
|
|
463
|
+
query_periods: [
|
|
464
|
+
{
|
|
465
|
+
end: "2021-07-14T23:00:00Z",
|
|
466
|
+
start: "2021-07-01T00:00:00Z",
|
|
467
|
+
},
|
|
468
|
+
],
|
|
469
|
+
max_results: 512,
|
|
470
|
+
},
|
|
471
|
+
},
|
|
472
|
+
];
|
|
473
|
+
|
|
474
|
+
const actual = utils.getMonthObjectsFromQuery(query, tzid, selectedDay);
|
|
475
|
+
|
|
476
|
+
expect(actual).toEqual(expected);
|
|
477
|
+
});
|
|
432
478
|
});
|
|
433
479
|
});
|
|
434
480
|
});
|