cronofy-elements 1.48.2 → 1.49.2
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/dist/.gitkeep +0 -0
- package/dist/CronofyElements.js +2 -0
- package/{build/CronofyElements.v1.48.2.js.LICENSE.txt → dist/CronofyElements.js.LICENSE.txt} +0 -0
- package/package.json +10 -7
- package/.babelrc +0 -20
- package/.eslintrc.yaml +0 -43
- package/.prettierignore +0 -4
- package/.prettierrc +0 -7
- package/Makefile +0 -92
- package/brainstorm.md +0 -76
- package/build/CronofyElements.v1.48.2.js +0 -2
- package/build/npm/CronofyElements.js +0 -2
- package/compat.config.js +0 -25
- package/demo/agenda.ejs +0 -71
- package/demo/availability-viewer.ejs +0 -322
- package/demo/calendar-sync.ejs +0 -149
- package/demo/crossbrowser.ejs +0 -228
- package/demo/date-time-picker.ejs +0 -213
- package/demo/demo-styles.css +0 -134
- package/demo/index.ejs +0 -249
- package/demo/integration.ejs +0 -482
- package/demo/load-elements.ejs +0 -12
- package/demo/nav.ejs +0 -14
- package/demo/rules.ejs +0 -121
- package/demo/server.js +0 -425
- package/demo/slot-picker.ejs +0 -197
- package/git.README.md +0 -71
- package/notes.style.md +0 -197
- package/postcss.config.js +0 -3
- package/script/i18n-export +0 -11
- package/script/i18n-helpers/split_write.rb +0 -25
- package/script/i18n-import +0 -22
- package/script/i18n-reference-update +0 -241
- package/src/js/components/Agenda/Agenda.js +0 -243
- package/src/js/components/Agenda/AllDayEventsList.js +0 -37
- package/src/js/components/Agenda/Calendar.js +0 -100
- package/src/js/components/Agenda/CalendarHeader.js +0 -187
- package/src/js/components/Agenda/Event.js +0 -34
- package/src/js/components/Agenda/EventAllDay.js +0 -76
- package/src/js/components/Agenda/EventAttendees.js +0 -30
- package/src/js/components/Agenda/EventDetail.js +0 -111
- package/src/js/components/Agenda/EventMessages.js +0 -24
- package/src/js/components/Agenda/EventMeta.js +0 -48
- package/src/js/components/Agenda/EventTime.js +0 -34
- package/src/js/components/Agenda/EventWrapper.js +0 -271
- package/src/js/components/Agenda/Location.js +0 -29
- package/src/js/components/Agenda/Message.js +0 -22
- package/src/js/components/Agenda/TimedEventsList.js +0 -29
- package/src/js/components/AvailabilityRules/AddButton.js +0 -60
- package/src/js/components/AvailabilityRules/AvailabilityRules.js +0 -45
- package/src/js/components/AvailabilityRules/Calendar.js +0 -31
- package/src/js/components/AvailabilityRules/CalendarListItem.js +0 -53
- package/src/js/components/AvailabilityRules/CalendarProfiles.js +0 -67
- package/src/js/components/AvailabilityRules/CalendarSelector.js +0 -104
- package/src/js/components/AvailabilityRules/Calendars.js +0 -145
- package/src/js/components/AvailabilityRules/Checkmark.js +0 -51
- package/src/js/components/AvailabilityRules/DayLabels.js +0 -91
- package/src/js/components/AvailabilityRules/Footer.js +0 -109
- package/src/js/components/AvailabilityRules/Legend.js +0 -57
- package/src/js/components/AvailabilityRules/Loading.js +0 -53
- package/src/js/components/AvailabilityRules/RemoveButton.js +0 -57
- package/src/js/components/AvailabilityRules/Slot.js +0 -195
- package/src/js/components/AvailabilityRules/SlotDisplay.js +0 -27
- package/src/js/components/AvailabilityRules/Slots.js +0 -81
- package/src/js/components/AvailabilityRules/SlotsDisplay.js +0 -68
- package/src/js/components/AvailabilityRules/TimeExpander.js +0 -119
- package/src/js/components/AvailabilityRules/TimeLabels.js +0 -89
- package/src/js/components/AvailabilityRules/TimeZoneDisplay.js +0 -41
- package/src/js/components/AvailabilityRules/ToggleIcon.js +0 -41
- package/src/js/components/AvailabilityRules/Tooltip.js +0 -63
- package/src/js/components/AvailabilityRules/UnknownCalendar.js +0 -33
- package/src/js/components/AvailabilityRules/Week.js +0 -115
- package/src/js/components/AvailabilityRules/WeekGrid.js +0 -80
- package/src/js/components/AvailabilityRules/Wrapper.js +0 -423
- package/src/js/components/AvailabilityRules/contexts/drag-context.js +0 -15
- package/src/js/components/AvailabilityRules/scss/_base.buttons.scss +0 -58
- package/src/js/components/AvailabilityRules/scss/_base.theme.scss +0 -4
- package/src/js/components/AvailabilityRules/scss/_components.timezoneselector.scss +0 -74
- package/src/js/components/AvailabilityRules/scss/_generic.reset.scss +0 -13
- package/src/js/components/AvailabilityRules/scss/_settings.colours.scss +0 -12
- package/src/js/components/AvailabilityRules/scss/availabilityrules.scss +0 -5
- package/src/js/components/AvailabilityRules/utils/tz-utils.js +0 -61
- package/src/js/components/AvailabilityViewer/AvailabilityViewer.js +0 -524
- package/src/js/components/AvailabilityViewer/ColumnHeader.js +0 -35
- package/src/js/components/AvailabilityViewer/DayColumn.js +0 -36
- package/src/js/components/AvailabilityViewer/DayColumnDisplay.js +0 -33
- package/src/js/components/AvailabilityViewer/DayColumnWrapper.js +0 -29
- package/src/js/components/AvailabilityViewer/DayLabels.js +0 -41
- package/src/js/components/AvailabilityViewer/EmptyColumn.js +0 -29
- package/src/js/components/AvailabilityViewer/Footer.js +0 -36
- package/src/js/components/AvailabilityViewer/GridFreeSelect.js +0 -33
- package/src/js/components/AvailabilityViewer/HoverSlot.js +0 -35
- package/src/js/components/AvailabilityViewer/HoverTooltip.js +0 -34
- package/src/js/components/AvailabilityViewer/LabelColumn.js +0 -53
- package/src/js/components/AvailabilityViewer/LabelItem.js +0 -73
- package/src/js/components/AvailabilityViewer/Legend.js +0 -79
- package/src/js/components/AvailabilityViewer/Loading.js +0 -57
- package/src/js/components/AvailabilityViewer/MonthLabels.js +0 -43
- package/src/js/components/AvailabilityViewer/Navigation.js +0 -138
- package/src/js/components/AvailabilityViewer/Overlay.js +0 -60
- package/src/js/components/AvailabilityViewer/Preloading.js +0 -66
- package/src/js/components/AvailabilityViewer/SelectedSlot.js +0 -106
- package/src/js/components/AvailabilityViewer/SelectedSlots.js +0 -72
- package/src/js/components/AvailabilityViewer/SelectionMask.js +0 -44
- package/src/js/components/AvailabilityViewer/Slot.js +0 -237
- package/src/js/components/AvailabilityViewer/SlotFreeSelect.js +0 -115
- package/src/js/components/AvailabilityViewer/Slots.js +0 -57
- package/src/js/components/AvailabilityViewer/TimeExpander.js +0 -93
- package/src/js/components/AvailabilityViewer/TimeLines.js +0 -74
- package/src/js/components/AvailabilityViewer/TimeSelector.js +0 -243
- package/src/js/components/AvailabilityViewer/TimeSelectorTrigger.js +0 -42
- package/src/js/components/AvailabilityViewer/TimeZoneDisplay.js +0 -28
- package/src/js/components/AvailabilityViewer/ToggleIcon.js +0 -41
- package/src/js/components/AvailabilityViewer/Tooltip.js +0 -65
- package/src/js/components/AvailabilityViewer/Week.js +0 -255
- package/src/js/components/AvailabilityViewer/WeekWrapper.js +0 -132
- package/src/js/components/AvailabilityViewer/contexts/page-context.js +0 -17
- package/src/js/components/AvailabilityViewer/contexts/page-reducer.js +0 -28
- package/src/js/components/AvailabilityViewer/contexts/selection-context.js +0 -25
- package/src/js/components/AvailabilityViewer/contexts/selection-reducer.js +0 -18
- package/src/js/components/CalendarSync/Active.js +0 -57
- package/src/js/components/CalendarSync/AddToggle.js +0 -72
- package/src/js/components/CalendarSync/CalendarSync.js +0 -215
- package/src/js/components/CalendarSync/EditToggle.js +0 -71
- package/src/js/components/CalendarSync/Footer.js +0 -31
- package/src/js/components/CalendarSync/Inactive.js +0 -66
- package/src/js/components/CalendarSync/Loading.js +0 -52
- package/src/js/components/CalendarSync/Pending.js +0 -74
- package/src/js/components/CalendarSync/ProfileStatus.js +0 -33
- package/src/js/components/CalendarSync/Profiles.js +0 -109
- package/src/js/components/CalendarSync/ProviderLogo.js +0 -28
- package/src/js/components/CalendarSync/Providers.js +0 -80
- package/src/js/components/CalendarSync/RemoveLink.js +0 -96
- package/src/js/components/CalendarSync/SelectProvider.js +0 -25
- package/src/js/components/CalendarSync/contexts/status-reducer.js +0 -74
- package/src/js/components/DateTimePicker/Calendar.js +0 -127
- package/src/js/components/DateTimePicker/CalendarHeader.js +0 -80
- package/src/js/components/DateTimePicker/Confirm.js +0 -106
- package/src/js/components/DateTimePicker/DateTimePicker.js +0 -131
- package/src/js/components/DateTimePicker/DayButton.js +0 -38
- package/src/js/components/DateTimePicker/DayHeadings.js +0 -33
- package/src/js/components/DateTimePicker/Details.js +0 -33
- package/src/js/components/DateTimePicker/Error.js +0 -39
- package/src/js/components/DateTimePicker/Loading.js +0 -20
- package/src/js/components/DateTimePicker/LoadingCalendar.js +0 -21
- package/src/js/components/DateTimePicker/NoSlotsFound.js +0 -16
- package/src/js/components/DateTimePicker/SequencedSlotButton.js +0 -97
- package/src/js/components/DateTimePicker/SlotButton.js +0 -55
- package/src/js/components/DateTimePicker/SlotsList.js +0 -45
- package/src/js/components/DateTimePicker/Wrapper.js +0 -281
- package/src/js/components/DateTimePicker/contexts/status-context.js +0 -19
- package/src/js/components/DateTimePicker/contexts/status-reducer.js +0 -276
- package/src/js/components/DateTimePicker/contexts/theme-context.js +0 -33
- package/src/js/components/DateTimePicker/helpers/theming.js +0 -49
- package/src/js/components/DateTimePicker/scss/_base.buttons.scss +0 -58
- package/src/js/components/DateTimePicker/scss/_base.layout.scss +0 -28
- package/src/js/components/DateTimePicker/scss/_base.theme.scss +0 -17
- package/src/js/components/DateTimePicker/scss/_components.calendargrid.scss +0 -78
- package/src/js/components/DateTimePicker/scss/_components.calendarheader.scss +0 -71
- package/src/js/components/DateTimePicker/scss/_components.confirm.scss +0 -40
- package/src/js/components/DateTimePicker/scss/_components.details.scss +0 -20
- package/src/js/components/DateTimePicker/scss/_components.error.scss +0 -34
- package/src/js/components/DateTimePicker/scss/_components.loading.scss +0 -36
- package/src/js/components/DateTimePicker/scss/_components.slotslist.scss +0 -43
- package/src/js/components/DateTimePicker/scss/_components.timezoneselector.scss +0 -73
- package/src/js/components/DateTimePicker/scss/_generic.reset.scss +0 -18
- package/src/js/components/DateTimePicker/scss/_settings.colours.scss +0 -17
- package/src/js/components/DateTimePicker/scss/datetimepicker.scss +0 -5
- package/src/js/components/DateTimePicker/utils/calendar-keyboard.js +0 -109
- package/src/js/components/DateTimePicker/utils/calendar.js +0 -125
- package/src/js/components/DateTimePicker/utils/slots.js +0 -288
- package/src/js/components/SlotPicker/Confirm.js +0 -160
- package/src/js/components/SlotPicker/Days.js +0 -58
- package/src/js/components/SlotPicker/Slot.js +0 -72
- package/src/js/components/SlotPicker/SlotPicker.js +0 -292
- package/src/js/components/SlotPicker/Slots.js +0 -66
- package/src/js/components/SlotPicker/TimeSlots.js +0 -91
- package/src/js/components/generic/Button.js +0 -26
- package/src/js/components/generic/Container.js +0 -33
- package/src/js/components/generic/Error.js +0 -77
- package/src/js/components/generic/Loading.js +0 -51
- package/src/js/components/generic/LoadingSpinner.js +0 -30
- package/src/js/components/generic/ShadowScrollbars.js +0 -70
- package/src/js/components/generic/TimeZoneSelector.js +0 -158
- package/src/js/components/generic/TransitionSlide.js +0 -72
- package/src/js/contexts/i18n-context.js +0 -25
- package/src/js/contexts/log-context.js +0 -18
- package/src/js/contexts/tz-context.js +0 -18
- package/src/js/env.example.js +0 -8
- package/src/js/helpers/colors.js +0 -33
- package/src/js/helpers/comparators.AvailabilityViewer.js +0 -27
- package/src/js/helpers/connections.js +0 -370
- package/src/js/helpers/events.js +0 -166
- package/src/js/helpers/functional.js +0 -4
- package/src/js/helpers/generator.js +0 -107
- package/src/js/helpers/i18n.js +0 -153
- package/src/js/helpers/init.Agenda.js +0 -55
- package/src/js/helpers/init.AvailabilityRules.js +0 -195
- package/src/js/helpers/init.AvailabilityViewer.js +0 -215
- package/src/js/helpers/init.CalendarSync.js +0 -83
- package/src/js/helpers/init.DateTimePicker.js +0 -219
- package/src/js/helpers/init.SlotPicker.js +0 -89
- package/src/js/helpers/init.js +0 -308
- package/src/js/helpers/logging.js +0 -78
- package/src/js/helpers/mocks.js +0 -871
- package/src/js/helpers/slots.js +0 -340
- package/src/js/helpers/slots.rules.js +0 -220
- package/src/js/helpers/theming.js +0 -93
- package/src/js/helpers/translations.js +0 -42
- package/src/js/helpers/tz-list.js +0 -136
- package/src/js/helpers/utils.AvailabilityRules.js +0 -110
- package/src/js/helpers/utils.AvailabilityViewer.js +0 -789
- package/src/js/helpers/utils.CalendarSync.js +0 -199
- package/src/js/helpers/utils.js +0 -76
- package/src/js/hooks/useWindowSize.js +0 -20
- package/src/js/main.js +0 -133
- package/src/js/next.js +0 -37
- package/src/js/styles/_settings.utils.scss +0 -82
- package/src/js/styles/colors.js +0 -13
- package/src/js/styles/global.js +0 -49
- package/src/js/styles/utils.js +0 -81
- package/src/js/translations/de/agenda.json +0 -12
- package/src/js/translations/de/availability_rules.json +0 -18
- package/src/js/translations/de/availability_viewer.json +0 -14
- package/src/js/translations/de/calendar_sync.json +0 -14
- package/src/js/translations/de/core.json +0 -15
- package/src/js/translations/de/date_time_picker.json +0 -14
- package/src/js/translations/de/slot_picker.json +0 -9
- package/src/js/translations/de/time_zones.json +0 -135
- package/src/js/translations/en/agenda.json +0 -12
- package/src/js/translations/en/availability_rules.json +0 -18
- package/src/js/translations/en/availability_viewer.json +0 -14
- package/src/js/translations/en/calendar_sync.json +0 -14
- package/src/js/translations/en/core.json +0 -23
- package/src/js/translations/en/date_time_picker.json +0 -15
- package/src/js/translations/en/slot_picker.json +0 -9
- package/src/js/translations/en/time_zones.json +0 -17
- package/src/js/translations/es/agenda.json +0 -12
- package/src/js/translations/es/availability_rules.json +0 -18
- package/src/js/translations/es/availability_viewer.json +0 -14
- package/src/js/translations/es/calendar_sync.json +0 -14
- package/src/js/translations/es/core.json +0 -15
- package/src/js/translations/es/date_time_picker.json +0 -14
- package/src/js/translations/es/slot_picker.json +0 -9
- package/src/js/translations/es/time_zones.json +0 -203
- package/src/js/translations/fr/agenda.json +0 -12
- package/src/js/translations/fr/availability_rules.json +0 -18
- package/src/js/translations/fr/availability_viewer.json +0 -14
- package/src/js/translations/fr/calendar_sync.json +0 -14
- package/src/js/translations/fr/core.json +0 -15
- package/src/js/translations/fr/date_time_picker.json +0 -14
- package/src/js/translations/fr/slot_picker.json +0 -9
- package/src/js/translations/fr/time_zones.json +0 -161
- package/src/js/translations/fr-CA/agenda.json +0 -12
- package/src/js/translations/fr-CA/availability_rules.json +0 -18
- package/src/js/translations/fr-CA/availability_viewer.json +0 -14
- package/src/js/translations/fr-CA/calendar_sync.json +0 -14
- package/src/js/translations/fr-CA/core.json +0 -23
- package/src/js/translations/fr-CA/date_time_picker.json +0 -14
- package/src/js/translations/fr-CA/slot_picker.json +0 -9
- package/src/js/translations/fr-CA/time_zones.json +0 -163
- package/src/js/translations/it/agenda.json +0 -12
- package/src/js/translations/it/availability_rules.json +0 -18
- package/src/js/translations/it/availability_viewer.json +0 -14
- package/src/js/translations/it/calendar_sync.json +0 -14
- package/src/js/translations/it/core.json +0 -15
- package/src/js/translations/it/date_time_picker.json +0 -14
- package/src/js/translations/it/slot_picker.json +0 -9
- package/src/js/translations/it/time_zones.json +0 -126
- package/src/js/translations/ja/agenda.json +0 -12
- package/src/js/translations/ja/availability_rules.json +0 -18
- package/src/js/translations/ja/availability_viewer.json +0 -14
- package/src/js/translations/ja/calendar_sync.json +0 -14
- package/src/js/translations/ja/core.json +0 -15
- package/src/js/translations/ja/date_formats.json +0 -5
- package/src/js/translations/ja/date_time_picker.json +0 -14
- package/src/js/translations/ja/slot_picker.json +0 -9
- package/src/js/translations/ja/time_zones.json +0 -435
- package/src/js/translations/nl/agenda.json +0 -12
- package/src/js/translations/nl/availability_rules.json +0 -18
- package/src/js/translations/nl/availability_viewer.json +0 -14
- package/src/js/translations/nl/calendar_sync.json +0 -14
- package/src/js/translations/nl/core.json +0 -15
- package/src/js/translations/nl/date_time_picker.json +0 -14
- package/src/js/translations/nl/slot_picker.json +0 -9
- package/src/js/translations/nl/time_zones.json +0 -118
- package/src/js/translations/ru/agenda.json +0 -12
- package/src/js/translations/ru/availability_rules.json +0 -18
- package/src/js/translations/ru/availability_viewer.json +0 -14
- package/src/js/translations/ru/calendar_sync.json +0 -14
- package/src/js/translations/ru/core.json +0 -15
- package/src/js/translations/ru/date_time_picker.json +0 -14
- package/src/js/translations/ru/slot_picker.json +0 -9
- package/src/js/translations/ru/time_zones.json +0 -435
- package/src/js/translations/sv/agenda.json +0 -12
- package/src/js/translations/sv/availability_rules.json +0 -18
- package/src/js/translations/sv/availability_viewer.json +0 -14
- package/src/js/translations/sv/calendar_sync.json +0 -14
- package/src/js/translations/sv/core.json +0 -15
- package/src/js/translations/sv/date_time_picker.json +0 -14
- package/src/js/translations/sv/slot_picker.json +0 -9
- package/src/js/translations/sv/time_zones.json +0 -136
- package/tests/AvailabilityRules/AvailabilityRules.test.js +0 -39
- package/tests/AvailabilityRules/__snapshots__/AvailabilityRules.test.js.snap +0 -1045
- package/tests/AvailabilityViewer/Navigation.test.js +0 -130
- package/tests/AvailabilityViewer/contexts/page-reducer.test.js +0 -87
- package/tests/AvailabilityViewer/reducer.test.js +0 -73
- package/tests/CalendarSync/Active.test.js +0 -25
- package/tests/CalendarSync/AddToggle.test.js +0 -57
- package/tests/CalendarSync/EditToggle.test.js +0 -57
- package/tests/CalendarSync/Inactive.test.js +0 -26
- package/tests/CalendarSync/Pending.test.js +0 -25
- package/tests/CalendarSync/ProviderLogo.test.js +0 -95
- package/tests/CalendarSync/__snapshots__/Active.test.js.snap +0 -61
- package/tests/CalendarSync/__snapshots__/Inactive.test.js.snap +0 -78
- package/tests/CalendarSync/__snapshots__/Pending.test.js.snap +0 -90
- package/tests/CalendarSync/__snapshots__/ProviderLogo.test.js.snap +0 -267
- package/tests/CalendarSync/init.CalendarSync.test.js +0 -302
- package/tests/CalendarSync/mocks/theme.js +0 -14
- package/tests/CalendarSync/status-reducer.test.js +0 -435
- package/tests/DateTimePicker/SequencedSlotButton.test.js +0 -157
- package/tests/DateTimePicker/SlotButton.test.js +0 -118
- package/tests/DateTimePicker/contexts/status-reducer.test.js +0 -1036
- package/tests/DateTimePicker/dummy-data.js +0 -883
- package/tests/DateTimePicker/utils.test.js +0 -515
- package/tests/colors.test.js +0 -70
- package/tests/components/TimezoneSelector.test.js +0 -124
- package/tests/components/main.test.js +0 -203
- package/tests/components/rtl-utils.js +0 -32
- package/tests/connections.test.js +0 -684
- package/tests/events.test.js +0 -472
- package/tests/generator.test.js +0 -74
- package/tests/i18n.test.js +0 -255
- package/tests/init.Agenda.test.js +0 -122
- package/tests/init.AvailabilityRules.test.js +0 -279
- package/tests/init.AvailabilityViewer.test.js +0 -740
- package/tests/init.SlotPicker.test.js +0 -166
- package/tests/init.test.js +0 -231
- package/tests/logging.test.js +0 -235
- package/tests/mocks/i18n.js +0 -3
- package/tests/mocks/theme.js +0 -3
- package/tests/setupJest.js +0 -8
- package/tests/slots.rules.test.js +0 -195
- package/tests/slots.test.js +0 -278
- package/tests/utils.AvailabilityRules.test.js +0 -221
- package/tests/utils.AvailabilityViewer.test.js +0 -1800
- package/tests/utils.CalendarSync.test.js +0 -277
- package/tests/utils.test.js +0 -119
- package/webpack.config.js +0 -114
|
@@ -1,1800 +0,0 @@
|
|
|
1
|
-
import * as utils from "../src/js/helpers/utils.AvailabilityViewer";
|
|
2
|
-
|
|
3
|
-
describe("Utilities: AvailabilityViewer", () => {
|
|
4
|
-
// addKeysToSlots
|
|
5
|
-
it("turns an array of slots into an object, using the start date as a key", () => {
|
|
6
|
-
const input = [
|
|
7
|
-
{
|
|
8
|
-
end: "2019-04-06T09:00:00Z",
|
|
9
|
-
participants: [{ sub: "EXAMPLE_SUB" }],
|
|
10
|
-
start: "2019-04-06T08:00:00Z",
|
|
11
|
-
},
|
|
12
|
-
{
|
|
13
|
-
end: "2019-05-06T09:00:00Z",
|
|
14
|
-
participants: [{ sub: "EXAMPLE_SUB" }],
|
|
15
|
-
start: "2019-05-06T08:00:00Z",
|
|
16
|
-
},
|
|
17
|
-
{
|
|
18
|
-
end: "2019-05-07T09:00:00Z",
|
|
19
|
-
start: "2019-05-07T08:00:00Z",
|
|
20
|
-
},
|
|
21
|
-
];
|
|
22
|
-
|
|
23
|
-
const expectedOutput = {
|
|
24
|
-
"2019-04-06T08:00:00Z": {
|
|
25
|
-
end: "2019-04-06T09:00:00Z",
|
|
26
|
-
participants: [{ sub: "EXAMPLE_SUB" }],
|
|
27
|
-
start: "2019-04-06T08:00:00Z",
|
|
28
|
-
},
|
|
29
|
-
"2019-05-06T08:00:00Z": {
|
|
30
|
-
end: "2019-05-06T09:00:00Z",
|
|
31
|
-
participants: [{ sub: "EXAMPLE_SUB" }],
|
|
32
|
-
start: "2019-05-06T08:00:00Z",
|
|
33
|
-
},
|
|
34
|
-
"2019-05-07T08:00:00Z": {
|
|
35
|
-
end: "2019-05-07T09:00:00Z",
|
|
36
|
-
start: "2019-05-07T08:00:00Z",
|
|
37
|
-
},
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
expect(utils.addKeysToSlots(input)).toEqual(expectedOutput);
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
// sortKeys
|
|
44
|
-
it("sorts array of date-keys into ascending order", () => {
|
|
45
|
-
const input = [
|
|
46
|
-
"2019-05-06T08:00:00Z",
|
|
47
|
-
"2019-04-06T08:00:00Z",
|
|
48
|
-
"2019-05-07T08:00:00Z",
|
|
49
|
-
"2018-05-07T08:00:00Z",
|
|
50
|
-
"2018-05-07T10:00:00Z",
|
|
51
|
-
"2018-05-07T09:00:00Z",
|
|
52
|
-
"2020-05-07T08:00:00Z",
|
|
53
|
-
];
|
|
54
|
-
|
|
55
|
-
const expectedOutput = [
|
|
56
|
-
"2018-05-07T08:00:00Z",
|
|
57
|
-
"2018-05-07T09:00:00Z",
|
|
58
|
-
"2018-05-07T10:00:00Z",
|
|
59
|
-
"2019-04-06T08:00:00Z",
|
|
60
|
-
"2019-05-06T08:00:00Z",
|
|
61
|
-
"2019-05-07T08:00:00Z",
|
|
62
|
-
"2020-05-07T08:00:00Z",
|
|
63
|
-
];
|
|
64
|
-
|
|
65
|
-
expect(utils.sortKeys(input)).toEqual(expectedOutput);
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
// getMinMaxDates
|
|
69
|
-
it("gets the first and last start-dates for a given set of slots", () => {
|
|
70
|
-
const input = {
|
|
71
|
-
"2019-04-06T08:00:00Z": {
|
|
72
|
-
end: "2019-04-06T09:00:00Z",
|
|
73
|
-
participants: [{ sub: "EXAMPLE_SUB" }],
|
|
74
|
-
start: "2019-04-06T08:00:00Z",
|
|
75
|
-
},
|
|
76
|
-
"2019-05-06T08:00:00Z": {
|
|
77
|
-
end: "2019-05-06T09:00:00Z",
|
|
78
|
-
participants: [{ sub: "EXAMPLE_SUB" }],
|
|
79
|
-
start: "2019-05-06T08:00:00Z",
|
|
80
|
-
},
|
|
81
|
-
"2019-05-07T08:00:00Z": {
|
|
82
|
-
end: "2019-05-07T09:00:00Z",
|
|
83
|
-
start: "2019-05-07T08:00:00Z",
|
|
84
|
-
},
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
const expectedOutput = {
|
|
88
|
-
max: moment
|
|
89
|
-
.utc("2019-05-07T08:00:00Z", "YYYY-MM-DDTHH:mm:00Z")
|
|
90
|
-
.local()
|
|
91
|
-
.format("YYYY-MM-DD"),
|
|
92
|
-
min: moment
|
|
93
|
-
.utc("2019-04-06T08:00:00Z", "YYYY-MM-DDTHH:mm:00Z")
|
|
94
|
-
.local()
|
|
95
|
-
.format("YYYY-MM-DD"),
|
|
96
|
-
};
|
|
97
|
-
|
|
98
|
-
expect(utils.getMinMaxDates(input)).toEqual(expectedOutput);
|
|
99
|
-
});
|
|
100
|
-
|
|
101
|
-
it("provides sensible fallbacks for min/max when there's no data", () => {
|
|
102
|
-
const expectedOutput = {
|
|
103
|
-
min: moment.utc().format("YYYY-MM-DD"),
|
|
104
|
-
max: moment.utc().add(1, "days").format("YYYY-MM-DD"),
|
|
105
|
-
};
|
|
106
|
-
expect(utils.getMinMaxDates()).toEqual(expectedOutput);
|
|
107
|
-
});
|
|
108
|
-
|
|
109
|
-
describe("getAllWeekDays", () => {
|
|
110
|
-
it("gets all the week days for a given period", () => {
|
|
111
|
-
const input = {
|
|
112
|
-
startDate: "2019-04-02", // Tue
|
|
113
|
-
endDate: "2019-04-04", // Thu
|
|
114
|
-
};
|
|
115
|
-
|
|
116
|
-
const out = [
|
|
117
|
-
"2019-03-31", // Sun
|
|
118
|
-
"2019-04-01", // Mon
|
|
119
|
-
"2019-04-02", // Tue
|
|
120
|
-
"2019-04-03", // Wed
|
|
121
|
-
"2019-04-04", // Thu
|
|
122
|
-
"2019-04-05", // Fri
|
|
123
|
-
"2019-04-06", // Sat
|
|
124
|
-
];
|
|
125
|
-
expect(utils.getAllWeekDays(input)).toEqual(out);
|
|
126
|
-
});
|
|
127
|
-
|
|
128
|
-
it("gets all the week days for a given period with a specific start day", () => {
|
|
129
|
-
const input = {
|
|
130
|
-
startDate: "2019-04-02", // Tue
|
|
131
|
-
endDate: "2019-04-04", // Thu
|
|
132
|
-
startDay: "wednesday",
|
|
133
|
-
};
|
|
134
|
-
|
|
135
|
-
const out = [
|
|
136
|
-
"2019-03-27", // Wed
|
|
137
|
-
"2019-03-28", // Thu
|
|
138
|
-
"2019-03-29", // Fri
|
|
139
|
-
"2019-03-30", // Sat
|
|
140
|
-
"2019-03-31", // Sun
|
|
141
|
-
"2019-04-01", // Mon
|
|
142
|
-
"2019-04-02", // Tue
|
|
143
|
-
"2019-04-03", // Wed
|
|
144
|
-
"2019-04-04", // Thu
|
|
145
|
-
"2019-04-05", // Fri
|
|
146
|
-
"2019-04-06", // Sat
|
|
147
|
-
"2019-04-07", // Sun
|
|
148
|
-
"2019-04-08", // Mon
|
|
149
|
-
"2019-04-09", // Tue
|
|
150
|
-
];
|
|
151
|
-
expect(utils.getAllWeekDays(input)).toEqual(out);
|
|
152
|
-
});
|
|
153
|
-
|
|
154
|
-
it("gets all the week days for a given period that spans two weeks", () => {
|
|
155
|
-
const input = {
|
|
156
|
-
startDate: "2019-04-02", // Tue 1
|
|
157
|
-
endDate: "2019-04-10", // Wed 2
|
|
158
|
-
};
|
|
159
|
-
|
|
160
|
-
const out = [
|
|
161
|
-
"2019-03-31", // Sun
|
|
162
|
-
"2019-04-01", // Mon
|
|
163
|
-
"2019-04-02", // Tue
|
|
164
|
-
"2019-04-03", // Wed
|
|
165
|
-
"2019-04-04", // Thu
|
|
166
|
-
"2019-04-05", // Fri
|
|
167
|
-
"2019-04-06", // Sat
|
|
168
|
-
"2019-04-07", // Sun 2
|
|
169
|
-
"2019-04-08", // Mon 2
|
|
170
|
-
"2019-04-09", // Tue 2
|
|
171
|
-
"2019-04-10", // Wed 2
|
|
172
|
-
"2019-04-11", // Thu 2
|
|
173
|
-
"2019-04-12", // Fri 2
|
|
174
|
-
"2019-04-13", // Sat 2
|
|
175
|
-
];
|
|
176
|
-
|
|
177
|
-
expect(utils.getAllWeekDays(input)).toEqual(out);
|
|
178
|
-
});
|
|
179
|
-
|
|
180
|
-
it("gets all the week days for a given period that spans two weeks with a specific start day", () => {
|
|
181
|
-
const input = {
|
|
182
|
-
startDate: "2019-04-04", // Thu 1
|
|
183
|
-
endDate: "2019-04-10", // Wed 2
|
|
184
|
-
startDay: "wednesday",
|
|
185
|
-
};
|
|
186
|
-
|
|
187
|
-
const out = [
|
|
188
|
-
"2019-04-03", // Wed
|
|
189
|
-
"2019-04-04", // Thu
|
|
190
|
-
"2019-04-05", // Fri
|
|
191
|
-
"2019-04-06", // Sat
|
|
192
|
-
"2019-04-07", // Sun
|
|
193
|
-
"2019-04-08", // Mon
|
|
194
|
-
"2019-04-09", // Tue
|
|
195
|
-
"2019-04-10", // Wed 2
|
|
196
|
-
"2019-04-11", // Thu 2
|
|
197
|
-
"2019-04-12", // Fri 2
|
|
198
|
-
"2019-04-13", // Sat 2
|
|
199
|
-
"2019-04-14", // Sun 2
|
|
200
|
-
"2019-04-15", // Mon 2
|
|
201
|
-
"2019-04-16", // Tue 2
|
|
202
|
-
];
|
|
203
|
-
|
|
204
|
-
expect(utils.getAllWeekDays(input)).toEqual(out);
|
|
205
|
-
});
|
|
206
|
-
|
|
207
|
-
it("gets all the week days for a given period that spans three weeks", () => {
|
|
208
|
-
const input = {
|
|
209
|
-
startDate: "2019-04-02", // Tue 1
|
|
210
|
-
endDate: "2019-04-16", // Tue 3
|
|
211
|
-
};
|
|
212
|
-
|
|
213
|
-
const out = [
|
|
214
|
-
"2019-03-31", // Sun
|
|
215
|
-
"2019-04-01", // Mon
|
|
216
|
-
"2019-04-02", // Tue
|
|
217
|
-
"2019-04-03", // Wed
|
|
218
|
-
"2019-04-04", // Thu
|
|
219
|
-
"2019-04-05", // Fri
|
|
220
|
-
"2019-04-06", // Sat
|
|
221
|
-
"2019-04-07", // Sun 2
|
|
222
|
-
"2019-04-08", // Mon 2
|
|
223
|
-
"2019-04-09", // Tue 2
|
|
224
|
-
"2019-04-10", // Wed 2
|
|
225
|
-
"2019-04-11", // Thu 2
|
|
226
|
-
"2019-04-12", // Fri 2
|
|
227
|
-
"2019-04-13", // Sat 2
|
|
228
|
-
"2019-04-14", // Sun 3
|
|
229
|
-
"2019-04-15", // Mon 3
|
|
230
|
-
"2019-04-16", // Tue 3
|
|
231
|
-
"2019-04-17", // Wed 3
|
|
232
|
-
"2019-04-18", // Thu 3
|
|
233
|
-
"2019-04-19", // Fri 3
|
|
234
|
-
"2019-04-20", // Sat 3
|
|
235
|
-
];
|
|
236
|
-
|
|
237
|
-
expect(utils.getAllWeekDays(input)).toEqual(out);
|
|
238
|
-
});
|
|
239
|
-
|
|
240
|
-
it("gets all the week days for a given period that spans three weeks with a specific start day", () => {
|
|
241
|
-
const input = {
|
|
242
|
-
startDate: "2019-04-04", // Thu 1
|
|
243
|
-
endDate: "2019-04-18", // Thu 3
|
|
244
|
-
startDay: "wednesday",
|
|
245
|
-
};
|
|
246
|
-
|
|
247
|
-
const out = [
|
|
248
|
-
"2019-04-03", // Wed
|
|
249
|
-
"2019-04-04", // Thu
|
|
250
|
-
"2019-04-05", // Fri
|
|
251
|
-
"2019-04-06", // Sat
|
|
252
|
-
"2019-04-07", // Sun
|
|
253
|
-
"2019-04-08", // Mon
|
|
254
|
-
"2019-04-09", // Tue
|
|
255
|
-
"2019-04-10", // Wed 2
|
|
256
|
-
"2019-04-11", // Thu 2
|
|
257
|
-
"2019-04-12", // Fri 2
|
|
258
|
-
"2019-04-13", // Sat 2
|
|
259
|
-
"2019-04-14", // Sun 2
|
|
260
|
-
"2019-04-15", // Mon 2
|
|
261
|
-
"2019-04-16", // Tue 2
|
|
262
|
-
"2019-04-17", // Wed 3
|
|
263
|
-
"2019-04-18", // Thu 3
|
|
264
|
-
"2019-04-19", // Fri 3
|
|
265
|
-
"2019-04-20", // Sat 3
|
|
266
|
-
"2019-04-21", // Sun 3
|
|
267
|
-
"2019-04-22", // Mon 3
|
|
268
|
-
"2019-04-23", // Tue 3
|
|
269
|
-
];
|
|
270
|
-
|
|
271
|
-
expect(utils.getAllWeekDays(input)).toEqual(out);
|
|
272
|
-
});
|
|
273
|
-
|
|
274
|
-
it("gets all the week days for a given period that starts on a Sunday", () => {
|
|
275
|
-
const input = {
|
|
276
|
-
startDate: "2020-06-07", // Sun
|
|
277
|
-
endDate: "2020-06-10", // Wed
|
|
278
|
-
};
|
|
279
|
-
|
|
280
|
-
const out = [
|
|
281
|
-
"2020-06-07", // Sun
|
|
282
|
-
"2020-06-08", // Mon
|
|
283
|
-
"2020-06-09", // Tue
|
|
284
|
-
"2020-06-10", // Wed
|
|
285
|
-
"2020-06-11", // Thu
|
|
286
|
-
"2020-06-12", // Fri
|
|
287
|
-
"2020-06-13", // Sat
|
|
288
|
-
];
|
|
289
|
-
|
|
290
|
-
expect(utils.getAllWeekDays(input)).toEqual(out);
|
|
291
|
-
});
|
|
292
|
-
|
|
293
|
-
it("gets all the week days for a given period that starts on a Saturday", () => {
|
|
294
|
-
const input = {
|
|
295
|
-
startDate: "2020-06-06", // Sat
|
|
296
|
-
endDate: "2020-06-10", // Wed
|
|
297
|
-
};
|
|
298
|
-
|
|
299
|
-
const out = [
|
|
300
|
-
"2020-05-31", // Sun
|
|
301
|
-
"2020-06-01", // Mon
|
|
302
|
-
"2020-06-02", // Tue
|
|
303
|
-
"2020-06-03", // Wed
|
|
304
|
-
"2020-06-04", // Thu
|
|
305
|
-
"2020-06-05", // Fri
|
|
306
|
-
"2020-06-06", // Sat
|
|
307
|
-
"2020-06-07", // Sun
|
|
308
|
-
"2020-06-08", // Mon
|
|
309
|
-
"2020-06-09", // Tue
|
|
310
|
-
"2020-06-10", // Wed
|
|
311
|
-
"2020-06-11", // Thu
|
|
312
|
-
"2020-06-12", // Fri
|
|
313
|
-
"2020-06-13", // Sat
|
|
314
|
-
];
|
|
315
|
-
|
|
316
|
-
expect(utils.getAllWeekDays(input)).toEqual(out);
|
|
317
|
-
});
|
|
318
|
-
|
|
319
|
-
it("gets all the week days for a given period that starts on the same day as provided as a week_start_day", () => {
|
|
320
|
-
const input = {
|
|
321
|
-
startDate: "2020-06-09", // Tue
|
|
322
|
-
endDate: "2020-06-12", // Fri
|
|
323
|
-
startDay: "tuesday",
|
|
324
|
-
};
|
|
325
|
-
|
|
326
|
-
const out = [
|
|
327
|
-
"2020-06-09", // Tue
|
|
328
|
-
"2020-06-10", // Wed
|
|
329
|
-
"2020-06-11", // Thu
|
|
330
|
-
"2020-06-12", // Fri
|
|
331
|
-
"2020-06-13", // Sat
|
|
332
|
-
"2020-06-14", // Sun
|
|
333
|
-
"2020-06-15", // Mon
|
|
334
|
-
];
|
|
335
|
-
|
|
336
|
-
expect(utils.getAllWeekDays(input)).toEqual(out);
|
|
337
|
-
});
|
|
338
|
-
});
|
|
339
|
-
|
|
340
|
-
describe("cropQuery", () => {
|
|
341
|
-
const cropExtent = {
|
|
342
|
-
startTime: "09:00",
|
|
343
|
-
endTime: "17:00",
|
|
344
|
-
days: [
|
|
345
|
-
"2020-11-06",
|
|
346
|
-
"2020-11-07",
|
|
347
|
-
"2020-11-08",
|
|
348
|
-
"2020-11-09",
|
|
349
|
-
"2020-11-10",
|
|
350
|
-
"2020-11-11",
|
|
351
|
-
"2020-11-12",
|
|
352
|
-
],
|
|
353
|
-
currentPage: 1,
|
|
354
|
-
};
|
|
355
|
-
|
|
356
|
-
const query = {
|
|
357
|
-
participants: [
|
|
358
|
-
{
|
|
359
|
-
required: "all",
|
|
360
|
-
members: [{ sub: "SUB" }],
|
|
361
|
-
},
|
|
362
|
-
],
|
|
363
|
-
required_duration: { minutes: 60 },
|
|
364
|
-
};
|
|
365
|
-
|
|
366
|
-
it("correctly crops a single overlapping period", () => {
|
|
367
|
-
const input = {
|
|
368
|
-
...query,
|
|
369
|
-
query_periods: [
|
|
370
|
-
{
|
|
371
|
-
start: "2020-11-09T06:00:00Z",
|
|
372
|
-
end: "2020-11-09T19:00:00Z",
|
|
373
|
-
},
|
|
374
|
-
],
|
|
375
|
-
};
|
|
376
|
-
const out = [{ start: "2020-11-09T09:00:00Z", end: "2020-11-09T17:00:00Z" }];
|
|
377
|
-
expect(utils.cropQuery(input, cropExtent).query_periods).toEqual(out);
|
|
378
|
-
});
|
|
379
|
-
|
|
380
|
-
it("correctly crops multiple overlapping periods", () => {
|
|
381
|
-
const input = {
|
|
382
|
-
...query,
|
|
383
|
-
query_periods: [
|
|
384
|
-
{
|
|
385
|
-
start: "2020-11-09T06:00:00Z",
|
|
386
|
-
end: "2020-11-09T19:00:00Z",
|
|
387
|
-
},
|
|
388
|
-
{
|
|
389
|
-
start: "2020-11-10T06:00:00Z",
|
|
390
|
-
end: "2020-11-10T12:00:00Z",
|
|
391
|
-
},
|
|
392
|
-
{
|
|
393
|
-
start: "2020-11-11T06:00:00Z",
|
|
394
|
-
end: "2020-11-11T19:00:00Z",
|
|
395
|
-
},
|
|
396
|
-
],
|
|
397
|
-
};
|
|
398
|
-
const out = [
|
|
399
|
-
{ start: "2020-11-09T09:00:00Z", end: "2020-11-09T17:00:00Z" },
|
|
400
|
-
{ start: "2020-11-10T09:00:00Z", end: "2020-11-10T12:00:00Z" },
|
|
401
|
-
{ start: "2020-11-11T09:00:00Z", end: "2020-11-11T17:00:00Z" },
|
|
402
|
-
];
|
|
403
|
-
expect(utils.cropQuery(input, cropExtent).query_periods).toEqual(out);
|
|
404
|
-
});
|
|
405
|
-
|
|
406
|
-
it("correctly crops huge overlapping periods", () => {
|
|
407
|
-
const input = {
|
|
408
|
-
...query,
|
|
409
|
-
query_periods: [
|
|
410
|
-
{
|
|
411
|
-
start: "2020-10-09T06:00:00Z",
|
|
412
|
-
end: "2020-12-09T19:00:00Z",
|
|
413
|
-
},
|
|
414
|
-
],
|
|
415
|
-
};
|
|
416
|
-
const out = [
|
|
417
|
-
{ start: "2020-11-06T09:00:00Z", end: "2020-11-06T17:00:00Z" },
|
|
418
|
-
{ start: "2020-11-07T09:00:00Z", end: "2020-11-07T17:00:00Z" },
|
|
419
|
-
{ start: "2020-11-08T09:00:00Z", end: "2020-11-08T17:00:00Z" },
|
|
420
|
-
{ start: "2020-11-09T09:00:00Z", end: "2020-11-09T17:00:00Z" },
|
|
421
|
-
{ start: "2020-11-10T09:00:00Z", end: "2020-11-10T17:00:00Z" },
|
|
422
|
-
{ start: "2020-11-11T09:00:00Z", end: "2020-11-11T17:00:00Z" },
|
|
423
|
-
{ start: "2020-11-12T09:00:00Z", end: "2020-11-12T17:00:00Z" },
|
|
424
|
-
];
|
|
425
|
-
expect(utils.cropQuery(input, cropExtent).query_periods).toEqual(out);
|
|
426
|
-
});
|
|
427
|
-
|
|
428
|
-
it("correctly crops tiny overlapping periods", () => {
|
|
429
|
-
const input = {
|
|
430
|
-
...query,
|
|
431
|
-
query_periods: [
|
|
432
|
-
{
|
|
433
|
-
start: "2020-11-09T07:00:00Z",
|
|
434
|
-
end: "2020-11-09T10:00:00Z",
|
|
435
|
-
},
|
|
436
|
-
{
|
|
437
|
-
start: "2020-11-09T12:00:00Z",
|
|
438
|
-
end: "2020-11-09T14:00:00Z",
|
|
439
|
-
},
|
|
440
|
-
{
|
|
441
|
-
start: "2020-11-09T16:00:00Z",
|
|
442
|
-
end: "2020-11-09T22:00:00Z",
|
|
443
|
-
},
|
|
444
|
-
],
|
|
445
|
-
};
|
|
446
|
-
const out = [
|
|
447
|
-
{ start: "2020-11-09T09:00:00Z", end: "2020-11-09T10:00:00Z" },
|
|
448
|
-
{ start: "2020-11-09T12:00:00Z", end: "2020-11-09T14:00:00Z" },
|
|
449
|
-
{ start: "2020-11-09T16:00:00Z", end: "2020-11-09T17:00:00Z" },
|
|
450
|
-
];
|
|
451
|
-
expect(utils.cropQuery(input, cropExtent).query_periods).toEqual(out);
|
|
452
|
-
});
|
|
453
|
-
|
|
454
|
-
it("correctly crops non-overlapping periods", () => {
|
|
455
|
-
const input = {
|
|
456
|
-
...query,
|
|
457
|
-
query_periods: [
|
|
458
|
-
{
|
|
459
|
-
start: "2020-11-09T07:00:00Z",
|
|
460
|
-
end: "2020-11-09T12:00:00Z",
|
|
461
|
-
},
|
|
462
|
-
{
|
|
463
|
-
start: "2020-11-10T12:00:00Z",
|
|
464
|
-
end: "2020-11-10T14:00:00Z",
|
|
465
|
-
},
|
|
466
|
-
{
|
|
467
|
-
start: "2020-11-11T16:00:00Z",
|
|
468
|
-
end: "2020-11-11T13:00:00Z",
|
|
469
|
-
},
|
|
470
|
-
],
|
|
471
|
-
};
|
|
472
|
-
const offsetCropExtent = {
|
|
473
|
-
...cropExtent,
|
|
474
|
-
startTime: "15:00",
|
|
475
|
-
endTime: "17:00",
|
|
476
|
-
};
|
|
477
|
-
expect(utils.cropQuery(input, offsetCropExtent).query_periods).toEqual([]);
|
|
478
|
-
});
|
|
479
|
-
|
|
480
|
-
it("correctly crops non-overlapping but abutting periods", () => {
|
|
481
|
-
const input = {
|
|
482
|
-
...query,
|
|
483
|
-
query_periods: [
|
|
484
|
-
{
|
|
485
|
-
start: "2020-11-09T07:00:00Z",
|
|
486
|
-
end: "2020-11-09T15:00:00Z",
|
|
487
|
-
},
|
|
488
|
-
],
|
|
489
|
-
};
|
|
490
|
-
const offsetCropExtent = {
|
|
491
|
-
...cropExtent,
|
|
492
|
-
startTime: "15:00",
|
|
493
|
-
endTime: "17:00",
|
|
494
|
-
};
|
|
495
|
-
expect(utils.cropQuery(input, offsetCropExtent).query_periods).toEqual([]);
|
|
496
|
-
});
|
|
497
|
-
|
|
498
|
-
//TODO: Correctly test this scenario - has to be a 26 day query with no available slots and the query end time for the last day needs to be before the startTime
|
|
499
|
-
it.skip("correctly crops 26 day query that has no availability at all", () => {
|
|
500
|
-
const input = {
|
|
501
|
-
...query,
|
|
502
|
-
query_periods: [
|
|
503
|
-
{
|
|
504
|
-
start: "2020-11-26T07:00:00Z",
|
|
505
|
-
end: "2020-12-01T15:00:00Z",
|
|
506
|
-
},
|
|
507
|
-
],
|
|
508
|
-
};
|
|
509
|
-
const offsetCropExtent = {
|
|
510
|
-
...cropExtent,
|
|
511
|
-
days: [
|
|
512
|
-
"2020-11-06",
|
|
513
|
-
"2020-11-07",
|
|
514
|
-
"2020-11-08",
|
|
515
|
-
"2020-11-09",
|
|
516
|
-
"2020-11-10",
|
|
517
|
-
"2020-11-11",
|
|
518
|
-
"2020-11-12",
|
|
519
|
-
"2020-11-13",
|
|
520
|
-
"2020-11-14",
|
|
521
|
-
"2020-11-15",
|
|
522
|
-
"2020-11-16",
|
|
523
|
-
"2020-11-17",
|
|
524
|
-
"2020-11-18",
|
|
525
|
-
"2020-11-19",
|
|
526
|
-
"2020-11-20",
|
|
527
|
-
"2020-11-21",
|
|
528
|
-
"2020-11-22",
|
|
529
|
-
"2020-11-23",
|
|
530
|
-
"2020-11-24",
|
|
531
|
-
"2020-11-25",
|
|
532
|
-
"2020-11-26",
|
|
533
|
-
"2020-11-27",
|
|
534
|
-
"2020-11-28",
|
|
535
|
-
"2020-11-29",
|
|
536
|
-
"2020-11-30",
|
|
537
|
-
"2020-12-01",
|
|
538
|
-
],
|
|
539
|
-
startTime: "08:00",
|
|
540
|
-
endTime: "17:00",
|
|
541
|
-
};
|
|
542
|
-
expect(utils.cropQuery(input, offsetCropExtent).query_periods).toEqual([]);
|
|
543
|
-
});
|
|
544
|
-
});
|
|
545
|
-
|
|
546
|
-
// periodOverlap
|
|
547
|
-
it("correctly detects overlaps", () => {
|
|
548
|
-
const period_1 = {
|
|
549
|
-
start: moment.utc("2020-11-09T09:00:00Z"),
|
|
550
|
-
end: moment.utc("2020-11-09T12:00:00Z"),
|
|
551
|
-
};
|
|
552
|
-
const period_2 = {
|
|
553
|
-
start: moment.utc("2020-11-09T11:00:00Z"),
|
|
554
|
-
end: moment.utc("2020-11-09T17:00:00Z"),
|
|
555
|
-
};
|
|
556
|
-
const out = {
|
|
557
|
-
start: "2020-11-09T11:00:00Z",
|
|
558
|
-
end: "2020-11-09T12:00:00Z",
|
|
559
|
-
};
|
|
560
|
-
expect(utils.periodOverlap(period_1, period_2)).toEqual(out);
|
|
561
|
-
});
|
|
562
|
-
|
|
563
|
-
it("correctly detects internal overlaps", () => {
|
|
564
|
-
const period_1 = {
|
|
565
|
-
start: moment.utc("2020-11-09T09:00:00Z"),
|
|
566
|
-
end: moment.utc("2020-11-09T17:00:00Z"),
|
|
567
|
-
};
|
|
568
|
-
const period_2 = {
|
|
569
|
-
start: moment.utc("2020-11-09T11:00:00Z"),
|
|
570
|
-
end: moment.utc("2020-11-09T13:00:00Z"),
|
|
571
|
-
};
|
|
572
|
-
const out = {
|
|
573
|
-
start: "2020-11-09T11:00:00Z",
|
|
574
|
-
end: "2020-11-09T13:00:00Z",
|
|
575
|
-
};
|
|
576
|
-
expect(utils.periodOverlap(period_1, period_2)).toEqual(out);
|
|
577
|
-
});
|
|
578
|
-
|
|
579
|
-
// divideDaysIntoWeeks
|
|
580
|
-
it("correctly divides days into weeks", () => {
|
|
581
|
-
const days = [
|
|
582
|
-
"2020-11-06",
|
|
583
|
-
"2020-11-07",
|
|
584
|
-
"2020-11-08",
|
|
585
|
-
"2020-11-09",
|
|
586
|
-
"2020-11-10",
|
|
587
|
-
"2020-11-11",
|
|
588
|
-
"2020-11-12",
|
|
589
|
-
"2020-11-13",
|
|
590
|
-
"2020-11-14",
|
|
591
|
-
"2020-11-15",
|
|
592
|
-
"2020-11-16",
|
|
593
|
-
"2020-11-17",
|
|
594
|
-
"2020-11-18",
|
|
595
|
-
"2020-11-19",
|
|
596
|
-
"2020-11-20",
|
|
597
|
-
"2020-11-21",
|
|
598
|
-
"2020-11-22",
|
|
599
|
-
"2020-11-23",
|
|
600
|
-
"2020-11-24",
|
|
601
|
-
"2020-11-25",
|
|
602
|
-
"2020-11-26",
|
|
603
|
-
];
|
|
604
|
-
const week_1 = [
|
|
605
|
-
"2020-11-06",
|
|
606
|
-
"2020-11-07",
|
|
607
|
-
"2020-11-08",
|
|
608
|
-
"2020-11-09",
|
|
609
|
-
"2020-11-10",
|
|
610
|
-
"2020-11-11",
|
|
611
|
-
"2020-11-12",
|
|
612
|
-
];
|
|
613
|
-
const week_2 = [
|
|
614
|
-
"2020-11-13",
|
|
615
|
-
"2020-11-14",
|
|
616
|
-
"2020-11-15",
|
|
617
|
-
"2020-11-16",
|
|
618
|
-
"2020-11-17",
|
|
619
|
-
"2020-11-18",
|
|
620
|
-
"2020-11-19",
|
|
621
|
-
];
|
|
622
|
-
const week_3 = [
|
|
623
|
-
"2020-11-20",
|
|
624
|
-
"2020-11-21",
|
|
625
|
-
"2020-11-22",
|
|
626
|
-
"2020-11-23",
|
|
627
|
-
"2020-11-24",
|
|
628
|
-
"2020-11-25",
|
|
629
|
-
"2020-11-26",
|
|
630
|
-
];
|
|
631
|
-
expect(utils.divideDaysIntoWeeks(days, 1)).toEqual(week_1);
|
|
632
|
-
expect(utils.divideDaysIntoWeeks(days, 2)).toEqual(week_2);
|
|
633
|
-
expect(utils.divideDaysIntoWeeks(days, 3)).toEqual(week_3);
|
|
634
|
-
});
|
|
635
|
-
|
|
636
|
-
// generateStaticPages
|
|
637
|
-
it("correctly generates static weeks", () => {
|
|
638
|
-
const input = [
|
|
639
|
-
{ start: "2020-11-09T06:00:00Z", end: "2020-11-09T19:00:00Z" },
|
|
640
|
-
{ start: "2020-11-10T06:00:00Z", end: "2020-11-10T12:00:00Z" },
|
|
641
|
-
{ start: "2020-11-11T06:00:00Z", end: "2020-11-11T19:00:00Z" },
|
|
642
|
-
];
|
|
643
|
-
const out = {
|
|
644
|
-
current: 1,
|
|
645
|
-
days: [
|
|
646
|
-
"2020-11-08",
|
|
647
|
-
"2020-11-09",
|
|
648
|
-
"2020-11-10",
|
|
649
|
-
"2020-11-11",
|
|
650
|
-
"2020-11-12",
|
|
651
|
-
"2020-11-13",
|
|
652
|
-
"2020-11-14",
|
|
653
|
-
],
|
|
654
|
-
set: true,
|
|
655
|
-
total: 1,
|
|
656
|
-
hasNext: false,
|
|
657
|
-
hasPrev: false,
|
|
658
|
-
};
|
|
659
|
-
expect(utils.generateStaticPages(input)).toEqual(out);
|
|
660
|
-
});
|
|
661
|
-
|
|
662
|
-
it("correctly generates multiple static weeks", () => {
|
|
663
|
-
const input = [
|
|
664
|
-
{ start: "2020-11-09T06:00:00Z", end: "2020-11-09T19:00:00Z" },
|
|
665
|
-
{ start: "2020-11-10T06:00:00Z", end: "2020-11-10T12:00:00Z" },
|
|
666
|
-
{ start: "2020-11-11T06:00:00Z", end: "2020-11-11T19:00:00Z" },
|
|
667
|
-
{ start: "2020-11-22T06:00:00Z", end: "2020-11-23T19:00:00Z" },
|
|
668
|
-
];
|
|
669
|
-
const out = {
|
|
670
|
-
current: 1,
|
|
671
|
-
days: [
|
|
672
|
-
"2020-11-08",
|
|
673
|
-
"2020-11-09",
|
|
674
|
-
"2020-11-10",
|
|
675
|
-
"2020-11-11",
|
|
676
|
-
"2020-11-12",
|
|
677
|
-
"2020-11-13",
|
|
678
|
-
"2020-11-14",
|
|
679
|
-
"2020-11-15",
|
|
680
|
-
"2020-11-16",
|
|
681
|
-
"2020-11-17",
|
|
682
|
-
"2020-11-18",
|
|
683
|
-
"2020-11-19",
|
|
684
|
-
"2020-11-20",
|
|
685
|
-
"2020-11-21",
|
|
686
|
-
"2020-11-22",
|
|
687
|
-
"2020-11-23",
|
|
688
|
-
"2020-11-24",
|
|
689
|
-
"2020-11-25",
|
|
690
|
-
"2020-11-26",
|
|
691
|
-
"2020-11-27",
|
|
692
|
-
"2020-11-28",
|
|
693
|
-
],
|
|
694
|
-
set: true,
|
|
695
|
-
total: 3,
|
|
696
|
-
hasNext: true,
|
|
697
|
-
hasPrev: false,
|
|
698
|
-
};
|
|
699
|
-
expect(utils.generateStaticPages(input)).toEqual(out);
|
|
700
|
-
});
|
|
701
|
-
|
|
702
|
-
it("correctly generates static week from same-day start", () => {
|
|
703
|
-
const input = [
|
|
704
|
-
{ start: "2019-11-11T06:00:00Z", end: "2019-11-11T19:00:00Z" },
|
|
705
|
-
{ start: "2019-11-12T06:00:00Z", end: "2019-11-12T19:00:00Z" },
|
|
706
|
-
{ start: "2019-11-13T06:00:00Z", end: "2019-11-13T19:00:00Z" },
|
|
707
|
-
{ start: "2019-11-14T06:00:00Z", end: "2019-11-14T19:00:00Z" },
|
|
708
|
-
];
|
|
709
|
-
const out = {
|
|
710
|
-
current: 1,
|
|
711
|
-
days: [
|
|
712
|
-
"2019-11-10",
|
|
713
|
-
"2019-11-11",
|
|
714
|
-
"2019-11-12",
|
|
715
|
-
"2019-11-13",
|
|
716
|
-
"2019-11-14",
|
|
717
|
-
"2019-11-15",
|
|
718
|
-
"2019-11-16",
|
|
719
|
-
],
|
|
720
|
-
set: true,
|
|
721
|
-
total: 1,
|
|
722
|
-
hasNext: false,
|
|
723
|
-
hasPrev: false,
|
|
724
|
-
};
|
|
725
|
-
expect(moment().utcOffset()).toEqual(0);
|
|
726
|
-
expect(utils.generateStaticPages(input)).toEqual(out);
|
|
727
|
-
});
|
|
728
|
-
|
|
729
|
-
// getAllWeekDays
|
|
730
|
-
it("gets all days between 2 dates", () => {
|
|
731
|
-
const out = [
|
|
732
|
-
"2020-03-01",
|
|
733
|
-
"2020-03-02",
|
|
734
|
-
"2020-03-03",
|
|
735
|
-
"2020-03-04",
|
|
736
|
-
"2020-03-05",
|
|
737
|
-
"2020-03-06",
|
|
738
|
-
"2020-03-07",
|
|
739
|
-
];
|
|
740
|
-
expect(
|
|
741
|
-
utils.getAllWeekDays({
|
|
742
|
-
startDate: "2020-03-01",
|
|
743
|
-
endDate: "2020-03-05",
|
|
744
|
-
})
|
|
745
|
-
).toEqual(out);
|
|
746
|
-
});
|
|
747
|
-
|
|
748
|
-
// getWeeksInfo
|
|
749
|
-
it("gets week's info", () => {
|
|
750
|
-
const input = [
|
|
751
|
-
"2020-03-01",
|
|
752
|
-
"2020-03-02",
|
|
753
|
-
"2020-03-03",
|
|
754
|
-
"2020-03-04",
|
|
755
|
-
"2020-03-05",
|
|
756
|
-
"2020-03-06",
|
|
757
|
-
"2020-03-07",
|
|
758
|
-
];
|
|
759
|
-
const out = {
|
|
760
|
-
current: 1,
|
|
761
|
-
days: [
|
|
762
|
-
"2020-03-01",
|
|
763
|
-
"2020-03-02",
|
|
764
|
-
"2020-03-03",
|
|
765
|
-
"2020-03-04",
|
|
766
|
-
"2020-03-05",
|
|
767
|
-
"2020-03-06",
|
|
768
|
-
"2020-03-07",
|
|
769
|
-
],
|
|
770
|
-
set: true,
|
|
771
|
-
total: 1,
|
|
772
|
-
hasNext: false,
|
|
773
|
-
hasPrev: false,
|
|
774
|
-
};
|
|
775
|
-
expect(utils.getWeeksInfo(input)).toEqual(out);
|
|
776
|
-
});
|
|
777
|
-
|
|
778
|
-
// getDaysForWeek
|
|
779
|
-
it("correctly generates a week of days from a single date", () => {
|
|
780
|
-
const input = moment.utc("2020-05-12");
|
|
781
|
-
const out = [
|
|
782
|
-
"2020-05-12",
|
|
783
|
-
"2020-05-13",
|
|
784
|
-
"2020-05-14",
|
|
785
|
-
"2020-05-15",
|
|
786
|
-
"2020-05-16",
|
|
787
|
-
"2020-05-17",
|
|
788
|
-
"2020-05-18",
|
|
789
|
-
];
|
|
790
|
-
expect(utils.getDaysForWeek(input)).toEqual(out);
|
|
791
|
-
});
|
|
792
|
-
|
|
793
|
-
// buildDayPeriod = (startTime, endTime, day)
|
|
794
|
-
it("builds a day period", () => {
|
|
795
|
-
const input = ["09:00", "17:00", "2020-03-20", "Etc/UTC"];
|
|
796
|
-
const out = {
|
|
797
|
-
start: "2020-03-20T09:00:00Z",
|
|
798
|
-
end: "2020-03-20T17:00:00Z",
|
|
799
|
-
};
|
|
800
|
-
expect(moment().utcOffset()).toEqual(0);
|
|
801
|
-
expect(utils.buildDayPeriod(...input)).toEqual(out);
|
|
802
|
-
});
|
|
803
|
-
|
|
804
|
-
// getMinMaxDates
|
|
805
|
-
it("gets min/max dates from a query", () => {
|
|
806
|
-
const input = {
|
|
807
|
-
"2020-11-06T09:00:00Z": {
|
|
808
|
-
start: "2020-11-06T09:00:00Z",
|
|
809
|
-
end: "2020-11-06T17:00:00Z",
|
|
810
|
-
},
|
|
811
|
-
"2020-11-07T09:00:00Z": {
|
|
812
|
-
start: "2020-11-07T09:00:00Z",
|
|
813
|
-
end: "2020-11-07T17:00:00Z",
|
|
814
|
-
},
|
|
815
|
-
"2020-11-08T09:00:00Z": {
|
|
816
|
-
start: "2020-11-08T09:00:00Z",
|
|
817
|
-
end: "2020-11-08T17:00:00Z",
|
|
818
|
-
},
|
|
819
|
-
"2020-11-09T09:00:00Z": {
|
|
820
|
-
start: "2020-11-09T09:00:00Z",
|
|
821
|
-
end: "2020-11-09T17:00:00Z",
|
|
822
|
-
},
|
|
823
|
-
"2020-11-10T09:00:00Z": {
|
|
824
|
-
start: "2020-11-10T09:00:00Z",
|
|
825
|
-
end: "2020-11-10T17:00:00Z",
|
|
826
|
-
},
|
|
827
|
-
"2020-11-11T09:00:00Z": {
|
|
828
|
-
start: "2020-11-11T09:00:00Z",
|
|
829
|
-
end: "2020-11-11T17:00:00Z",
|
|
830
|
-
},
|
|
831
|
-
"2020-11-12T09:00:00Z": {
|
|
832
|
-
start: "2020-11-12T09:00:00Z",
|
|
833
|
-
end: "2020-11-12T17:00:00Z",
|
|
834
|
-
},
|
|
835
|
-
};
|
|
836
|
-
const out = {
|
|
837
|
-
min: moment.utc("2020-11-06T09:00:00Z").local().format("YYYY-MM-DD"),
|
|
838
|
-
max: moment.utc("2020-11-12T17:00:00Z").local().format("YYYY-MM-DD"),
|
|
839
|
-
};
|
|
840
|
-
expect(utils.getMinMaxDates(input)).toEqual(out);
|
|
841
|
-
});
|
|
842
|
-
|
|
843
|
-
it("gets min/max dates from an empty query", () => {
|
|
844
|
-
const out = {
|
|
845
|
-
min: moment().format("YYYY-MM-DD"),
|
|
846
|
-
max: moment().add(1, "days").format("YYYY-MM-DD"),
|
|
847
|
-
};
|
|
848
|
-
expect(utils.getMinMaxDates()).toEqual(out);
|
|
849
|
-
});
|
|
850
|
-
|
|
851
|
-
// checkWeekdaysSlotAvailability
|
|
852
|
-
it("checks visibility status", () => {
|
|
853
|
-
const emptySlots = [
|
|
854
|
-
{
|
|
855
|
-
day: "2019-09-29",
|
|
856
|
-
slots: [
|
|
857
|
-
{
|
|
858
|
-
start: "2019-09-29T09:00:00Z",
|
|
859
|
-
end: "2019-09-29T09:15:00Z",
|
|
860
|
-
},
|
|
861
|
-
{
|
|
862
|
-
start: "2019-09-29T09:15:00Z",
|
|
863
|
-
end: "2019-09-29T09:30:00Z",
|
|
864
|
-
},
|
|
865
|
-
{
|
|
866
|
-
start: "2019-09-29T09:30:00Z",
|
|
867
|
-
end: "2019-09-29T09:45:00Z",
|
|
868
|
-
},
|
|
869
|
-
{
|
|
870
|
-
start: "2019-09-29T09:45:00Z",
|
|
871
|
-
end: "2019-09-29T10:00:00Z",
|
|
872
|
-
},
|
|
873
|
-
],
|
|
874
|
-
},
|
|
875
|
-
];
|
|
876
|
-
|
|
877
|
-
const availablePeriods = {
|
|
878
|
-
"2019-09-29T09:30:00Z": {
|
|
879
|
-
start: "2019-09-29T09:30:00Z",
|
|
880
|
-
end: "2019-09-29T10:30:00Z",
|
|
881
|
-
participants: ["PARTICIPANT_1", "PARTICIPANT_2"],
|
|
882
|
-
},
|
|
883
|
-
"2019-09-29T09:45:00Z": {
|
|
884
|
-
start: "2019-09-29T09:45:00Z",
|
|
885
|
-
end: "2019-09-29T10:45:00Z",
|
|
886
|
-
participants: ["PARTICIPANT_1", "PARTICIPANT_2"],
|
|
887
|
-
},
|
|
888
|
-
"2019-09-29T10:00:00Z": {
|
|
889
|
-
start: "2019-09-29T10:00:00Z",
|
|
890
|
-
end: "2019-09-29T11:00:00Z",
|
|
891
|
-
participants: ["PARTICIPANT_1", "PARTICIPANT_2"],
|
|
892
|
-
},
|
|
893
|
-
};
|
|
894
|
-
|
|
895
|
-
const selectedSlots = {};
|
|
896
|
-
const input = [emptySlots, availablePeriods, selectedSlots, 30, 15, false];
|
|
897
|
-
const checkedSlots = utils.checkWeekdaysSlotAvailability(...input);
|
|
898
|
-
|
|
899
|
-
expect(checkedSlots[0].day).toEqual("2019-09-29");
|
|
900
|
-
expect(checkedSlots[0].slots.length).toEqual(4);
|
|
901
|
-
expect(checkedSlots[0].slots[0].available).toEqual(false); // before period starts
|
|
902
|
-
expect(checkedSlots[0].slots[1].available).toEqual(false); // before period starts
|
|
903
|
-
expect(checkedSlots[0].slots[2].available).toEqual(true); // 09:30-10:00 Selectable
|
|
904
|
-
expect(checkedSlots[0].slots[3].available).toEqual(false); // 09:45 overruns the window of empty slots
|
|
905
|
-
});
|
|
906
|
-
|
|
907
|
-
it("checks visibility status with overlap", () => {
|
|
908
|
-
const emptySlots = [
|
|
909
|
-
{
|
|
910
|
-
day: "2019-09-29",
|
|
911
|
-
slots: [
|
|
912
|
-
{
|
|
913
|
-
start: "2019-09-29T09:00:00Z",
|
|
914
|
-
end: "2019-09-29T09:15:00Z",
|
|
915
|
-
},
|
|
916
|
-
{
|
|
917
|
-
start: "2019-09-29T09:15:00Z",
|
|
918
|
-
end: "2019-09-29T09:30:00Z",
|
|
919
|
-
},
|
|
920
|
-
{
|
|
921
|
-
start: "2019-09-29T09:30:00Z",
|
|
922
|
-
end: "2019-09-29T09:45:00Z",
|
|
923
|
-
},
|
|
924
|
-
{
|
|
925
|
-
start: "2019-09-29T09:45:00Z",
|
|
926
|
-
end: "2019-09-29T10:00:00Z",
|
|
927
|
-
},
|
|
928
|
-
{
|
|
929
|
-
start: "2019-09-29T10:00:00Z",
|
|
930
|
-
end: "2019-09-29T10:15:00Z",
|
|
931
|
-
},
|
|
932
|
-
{
|
|
933
|
-
start: "2019-09-29T10:15:00Z",
|
|
934
|
-
end: "2019-09-29T10:30:00Z",
|
|
935
|
-
},
|
|
936
|
-
{
|
|
937
|
-
start: "2019-09-29T10:30:00Z",
|
|
938
|
-
end: "2019-09-29T10:45:00Z",
|
|
939
|
-
},
|
|
940
|
-
{
|
|
941
|
-
start: "2019-09-29T10:45:00Z",
|
|
942
|
-
end: "2019-09-29T11:00:00Z",
|
|
943
|
-
},
|
|
944
|
-
],
|
|
945
|
-
},
|
|
946
|
-
];
|
|
947
|
-
|
|
948
|
-
const availablePeriods = {
|
|
949
|
-
"2019-09-29T09:30:00Z": {
|
|
950
|
-
start: "2019-09-29T09:30:00Z",
|
|
951
|
-
end: "2019-09-29T10:30:00Z",
|
|
952
|
-
participants: ["PARTICIPANT_1", "PARTICIPANT_2"],
|
|
953
|
-
},
|
|
954
|
-
};
|
|
955
|
-
|
|
956
|
-
const selectedSlots = {};
|
|
957
|
-
const input = [emptySlots, availablePeriods, selectedSlots, 60, 15, false];
|
|
958
|
-
const checkedSlots = utils.checkWeekdaysSlotAvailability(...input);
|
|
959
|
-
|
|
960
|
-
expect(checkedSlots[0].day).toEqual("2019-09-29");
|
|
961
|
-
|
|
962
|
-
const daySlots = checkedSlots[0].slots;
|
|
963
|
-
expect(daySlots.length).toEqual(8);
|
|
964
|
-
|
|
965
|
-
// Before start of the period
|
|
966
|
-
expect(daySlots[0].start).toEqual("2019-09-29T09:00:00Z");
|
|
967
|
-
expect(daySlots[0].available).toEqual(false);
|
|
968
|
-
expect(daySlots[0].visiblyAvailable).toEqual(false);
|
|
969
|
-
expect(daySlots[0].target).toEqual(false);
|
|
970
|
-
|
|
971
|
-
// Before start of the period
|
|
972
|
-
expect(daySlots[1].start).toEqual("2019-09-29T09:15:00Z");
|
|
973
|
-
expect(daySlots[1].available).toEqual(false);
|
|
974
|
-
expect(daySlots[1].visiblyAvailable).toEqual(false);
|
|
975
|
-
expect(daySlots[1].target).toEqual(false);
|
|
976
|
-
|
|
977
|
-
// 9:30 - 10:30 is available and in period
|
|
978
|
-
expect(daySlots[2].start).toEqual("2019-09-29T09:30:00Z");
|
|
979
|
-
expect(daySlots[2].available).toEqual(true);
|
|
980
|
-
expect(daySlots[2].visiblyAvailable).toEqual(true);
|
|
981
|
-
expect(daySlots[2].target).toEqual(false);
|
|
982
|
-
expect(daySlots[2].targetOffset).toEqual(false);
|
|
983
|
-
|
|
984
|
-
// Not enough time but can be part of the 9:30 - 10:30 slot
|
|
985
|
-
expect(daySlots[3].start).toEqual("2019-09-29T09:45:00Z");
|
|
986
|
-
expect(daySlots[3].available).toEqual(false);
|
|
987
|
-
expect(daySlots[3].visiblyAvailable).toEqual(true);
|
|
988
|
-
expect(daySlots[3].target).toEqual(daySlots[2].start);
|
|
989
|
-
expect(daySlots[3].targetOffset).toEqual(3);
|
|
990
|
-
|
|
991
|
-
// Not enough time but can be part of the 9:30 - 10:30 slot
|
|
992
|
-
expect(daySlots[4].start).toEqual("2019-09-29T10:00:00Z");
|
|
993
|
-
expect(daySlots[4].available).toEqual(false);
|
|
994
|
-
expect(daySlots[4].visiblyAvailable).toEqual(true);
|
|
995
|
-
expect(daySlots[4].target).toEqual(daySlots[2].start);
|
|
996
|
-
expect(daySlots[4].targetOffset).toEqual(2);
|
|
997
|
-
|
|
998
|
-
// Not enough time but can be part of the 9:30 - 10:30 slot
|
|
999
|
-
expect(daySlots[5].start).toEqual("2019-09-29T10:15:00Z");
|
|
1000
|
-
expect(daySlots[5].available).toEqual(false);
|
|
1001
|
-
expect(daySlots[5].visiblyAvailable).toEqual(true);
|
|
1002
|
-
expect(daySlots[5].target).toEqual(daySlots[2].start);
|
|
1003
|
-
expect(daySlots[5].targetOffset).toEqual(1);
|
|
1004
|
-
|
|
1005
|
-
// After the period
|
|
1006
|
-
expect(daySlots[6].start).toEqual("2019-09-29T10:30:00Z");
|
|
1007
|
-
expect(daySlots[6].available).toEqual(false);
|
|
1008
|
-
expect(daySlots[6].visiblyAvailable).toEqual(false);
|
|
1009
|
-
expect(daySlots[6].target).toEqual(false);
|
|
1010
|
-
//
|
|
1011
|
-
// After the period
|
|
1012
|
-
expect(daySlots[7].start).toEqual("2019-09-29T10:45:00Z");
|
|
1013
|
-
expect(daySlots[7].available).toEqual(false);
|
|
1014
|
-
expect(daySlots[7].visiblyAvailable).toEqual(false);
|
|
1015
|
-
expect(daySlots[7].target).toEqual(false);
|
|
1016
|
-
});
|
|
1017
|
-
|
|
1018
|
-
it("checks visibility status with overlap including a selected slot", () => {
|
|
1019
|
-
const emptySlots = [
|
|
1020
|
-
{
|
|
1021
|
-
day: "2019-09-29",
|
|
1022
|
-
slots: [
|
|
1023
|
-
{
|
|
1024
|
-
start: "2019-09-29T09:00:00Z",
|
|
1025
|
-
end: "2019-09-29T09:15:00Z",
|
|
1026
|
-
},
|
|
1027
|
-
{
|
|
1028
|
-
start: "2019-09-29T09:15:00Z",
|
|
1029
|
-
end: "2019-09-29T09:30:00Z",
|
|
1030
|
-
},
|
|
1031
|
-
{
|
|
1032
|
-
start: "2019-09-29T09:30:00Z",
|
|
1033
|
-
end: "2019-09-29T09:45:00Z",
|
|
1034
|
-
},
|
|
1035
|
-
{
|
|
1036
|
-
start: "2019-09-29T09:45:00Z",
|
|
1037
|
-
end: "2019-09-29T10:00:00Z",
|
|
1038
|
-
},
|
|
1039
|
-
{
|
|
1040
|
-
start: "2019-09-29T10:00:00Z",
|
|
1041
|
-
end: "2019-09-29T10:15:00Z",
|
|
1042
|
-
},
|
|
1043
|
-
{
|
|
1044
|
-
start: "2019-09-29T10:15:00Z",
|
|
1045
|
-
end: "2019-09-29T10:30:00Z",
|
|
1046
|
-
},
|
|
1047
|
-
{
|
|
1048
|
-
start: "2019-09-29T10:30:00Z",
|
|
1049
|
-
end: "2019-09-29T10:45:00Z",
|
|
1050
|
-
},
|
|
1051
|
-
{
|
|
1052
|
-
start: "2019-09-29T10:45:00Z",
|
|
1053
|
-
end: "2019-09-29T11:00:00Z",
|
|
1054
|
-
},
|
|
1055
|
-
{
|
|
1056
|
-
start: "2019-09-29T11:00:00Z",
|
|
1057
|
-
end: "2019-09-29T11:15:00Z",
|
|
1058
|
-
},
|
|
1059
|
-
{
|
|
1060
|
-
start: "2019-09-29T11:15:00Z",
|
|
1061
|
-
end: "2019-09-29T11:30:00Z",
|
|
1062
|
-
},
|
|
1063
|
-
],
|
|
1064
|
-
},
|
|
1065
|
-
];
|
|
1066
|
-
|
|
1067
|
-
const availablePeriods = {
|
|
1068
|
-
"2019-09-29T09:30:00Z": {
|
|
1069
|
-
start: "2019-09-29T09:30:00Z",
|
|
1070
|
-
end: "2019-09-29T11:30:00Z",
|
|
1071
|
-
participants: ["PARTICIPANT_1", "PARTICIPANT_2"],
|
|
1072
|
-
},
|
|
1073
|
-
};
|
|
1074
|
-
|
|
1075
|
-
const selectedSlots = {
|
|
1076
|
-
"2019-09-29T10:30:00Z": {
|
|
1077
|
-
start: "2019-09-29T10:30:00Z",
|
|
1078
|
-
end: "2019-09-29T11:30:00Z",
|
|
1079
|
-
participants: ["PARTICIPANT_1", "PARTICIPANT_2"],
|
|
1080
|
-
},
|
|
1081
|
-
};
|
|
1082
|
-
const input = [emptySlots, availablePeriods, selectedSlots, 60, 15, false];
|
|
1083
|
-
const checkedSlots = utils.checkWeekdaysSlotAvailability(...input);
|
|
1084
|
-
|
|
1085
|
-
expect(checkedSlots[0].day).toEqual("2019-09-29");
|
|
1086
|
-
|
|
1087
|
-
const daySlots = checkedSlots[0].slots;
|
|
1088
|
-
expect(daySlots.length).toEqual(10);
|
|
1089
|
-
|
|
1090
|
-
// Before start of the period
|
|
1091
|
-
expect(daySlots[0].start).toEqual("2019-09-29T09:00:00Z");
|
|
1092
|
-
expect(daySlots[0].available).toEqual(false);
|
|
1093
|
-
expect(daySlots[0].visiblyAvailable).toEqual(false);
|
|
1094
|
-
expect(daySlots[0].target).toEqual(false);
|
|
1095
|
-
|
|
1096
|
-
// Before start of the period
|
|
1097
|
-
expect(daySlots[1].start).toEqual("2019-09-29T09:15:00Z");
|
|
1098
|
-
expect(daySlots[1].available).toEqual(false);
|
|
1099
|
-
expect(daySlots[1].visiblyAvailable).toEqual(false);
|
|
1100
|
-
expect(daySlots[1].target).toEqual(false);
|
|
1101
|
-
|
|
1102
|
-
// 9:30 - 10:30 is available and in period
|
|
1103
|
-
expect(daySlots[2].start).toEqual("2019-09-29T09:30:00Z");
|
|
1104
|
-
expect(daySlots[2].available).toEqual(true);
|
|
1105
|
-
expect(daySlots[2].visiblyAvailable).toEqual(true);
|
|
1106
|
-
expect(daySlots[2].target).toEqual(false);
|
|
1107
|
-
expect(daySlots[2].targetOffset).toEqual(false);
|
|
1108
|
-
|
|
1109
|
-
// Not enough time but can be part of the 9:30 - 10:30 slot
|
|
1110
|
-
expect(daySlots[3].start).toEqual("2019-09-29T09:45:00Z");
|
|
1111
|
-
expect(daySlots[3].available).toEqual(false);
|
|
1112
|
-
expect(daySlots[3].visiblyAvailable).toEqual(true);
|
|
1113
|
-
expect(daySlots[3].target).toEqual(daySlots[2].start);
|
|
1114
|
-
expect(daySlots[3].targetOffset).toEqual(3);
|
|
1115
|
-
|
|
1116
|
-
// Not enough time but can be part of the 9:30 - 10:30 slot
|
|
1117
|
-
expect(daySlots[4].start).toEqual("2019-09-29T10:00:00Z");
|
|
1118
|
-
expect(daySlots[4].available).toEqual(false);
|
|
1119
|
-
expect(daySlots[4].visiblyAvailable).toEqual(true);
|
|
1120
|
-
expect(daySlots[4].target).toEqual(daySlots[2].start);
|
|
1121
|
-
expect(daySlots[4].targetOffset).toEqual(2);
|
|
1122
|
-
|
|
1123
|
-
// Not enough time but can be part of the 9:30 - 10:30 slot
|
|
1124
|
-
expect(daySlots[5].start).toEqual("2019-09-29T10:15:00Z");
|
|
1125
|
-
expect(daySlots[5].available).toEqual(false);
|
|
1126
|
-
expect(daySlots[5].visiblyAvailable).toEqual(true);
|
|
1127
|
-
expect(daySlots[5].target).toEqual(daySlots[2].start);
|
|
1128
|
-
expect(daySlots[5].targetOffset).toEqual(1);
|
|
1129
|
-
|
|
1130
|
-
// Start of selected period - 10:30 - 11: 30
|
|
1131
|
-
expect(daySlots[6].start).toEqual("2019-09-29T10:30:00Z");
|
|
1132
|
-
expect(daySlots[6].available).toEqual(false);
|
|
1133
|
-
expect(daySlots[6].visiblyAvailable).toEqual(true);
|
|
1134
|
-
expect(daySlots[6].target).toEqual(false);
|
|
1135
|
-
|
|
1136
|
-
// part of selected period - 10:30 - 11: 30
|
|
1137
|
-
expect(daySlots[7].start).toEqual("2019-09-29T10:45:00Z");
|
|
1138
|
-
expect(daySlots[7].available).toEqual(false);
|
|
1139
|
-
expect(daySlots[7].visiblyAvailable).toEqual(true);
|
|
1140
|
-
expect(daySlots[7].target).toEqual(false);
|
|
1141
|
-
});
|
|
1142
|
-
|
|
1143
|
-
describe("when running in an environment with a different timezone", () => {
|
|
1144
|
-
beforeEach(() => moment.tz.setDefault("Asia/Yekaterinburg"));
|
|
1145
|
-
afterEach(() => moment.tz.setDefault("UTC"));
|
|
1146
|
-
|
|
1147
|
-
it("checks visibility status with overlap including a selected slot in another timezone", () => {
|
|
1148
|
-
const emptySlots = [
|
|
1149
|
-
{
|
|
1150
|
-
day: "2019-09-29",
|
|
1151
|
-
slots: [
|
|
1152
|
-
{
|
|
1153
|
-
start: "2019-09-29T09:00:00Z",
|
|
1154
|
-
end: "2019-09-29T09:15:00Z",
|
|
1155
|
-
},
|
|
1156
|
-
{
|
|
1157
|
-
start: "2019-09-29T09:15:00Z",
|
|
1158
|
-
end: "2019-09-29T09:30:00Z",
|
|
1159
|
-
},
|
|
1160
|
-
{
|
|
1161
|
-
start: "2019-09-29T09:30:00Z",
|
|
1162
|
-
end: "2019-09-29T09:45:00Z",
|
|
1163
|
-
},
|
|
1164
|
-
{
|
|
1165
|
-
start: "2019-09-29T09:45:00Z",
|
|
1166
|
-
end: "2019-09-29T10:00:00Z",
|
|
1167
|
-
},
|
|
1168
|
-
{
|
|
1169
|
-
start: "2019-09-29T10:00:00Z",
|
|
1170
|
-
end: "2019-09-29T10:15:00Z",
|
|
1171
|
-
},
|
|
1172
|
-
{
|
|
1173
|
-
start: "2019-09-29T10:15:00Z",
|
|
1174
|
-
end: "2019-09-29T10:30:00Z",
|
|
1175
|
-
},
|
|
1176
|
-
{
|
|
1177
|
-
start: "2019-09-29T10:30:00Z",
|
|
1178
|
-
end: "2019-09-29T10:45:00Z",
|
|
1179
|
-
},
|
|
1180
|
-
{
|
|
1181
|
-
start: "2019-09-29T10:45:00Z",
|
|
1182
|
-
end: "2019-09-29T11:00:00Z",
|
|
1183
|
-
},
|
|
1184
|
-
{
|
|
1185
|
-
start: "2019-09-29T11:00:00Z",
|
|
1186
|
-
end: "2019-09-29T11:15:00Z",
|
|
1187
|
-
},
|
|
1188
|
-
{
|
|
1189
|
-
start: "2019-09-29T11:15:00Z",
|
|
1190
|
-
end: "2019-09-29T11:30:00Z",
|
|
1191
|
-
},
|
|
1192
|
-
],
|
|
1193
|
-
},
|
|
1194
|
-
];
|
|
1195
|
-
|
|
1196
|
-
const availablePeriods = {
|
|
1197
|
-
"2019-09-29T09:30:00Z": {
|
|
1198
|
-
start: "2019-09-29T09:30:00Z",
|
|
1199
|
-
end: "2019-09-29T11:30:00Z",
|
|
1200
|
-
participants: ["PARTICIPANT_1", "PARTICIPANT_2"],
|
|
1201
|
-
},
|
|
1202
|
-
};
|
|
1203
|
-
|
|
1204
|
-
const selectedSlots = {
|
|
1205
|
-
"2019-09-29T10:30:00Z": {
|
|
1206
|
-
start: "2019-09-29T10:30:00Z",
|
|
1207
|
-
end: "2019-09-29T11:30:00Z",
|
|
1208
|
-
participants: ["PARTICIPANT_1", "PARTICIPANT_2"],
|
|
1209
|
-
},
|
|
1210
|
-
};
|
|
1211
|
-
|
|
1212
|
-
const input = [emptySlots, availablePeriods, selectedSlots, 60, 15, false];
|
|
1213
|
-
const checkedSlots = utils.checkWeekdaysSlotAvailability(...input);
|
|
1214
|
-
|
|
1215
|
-
expect(checkedSlots[0].day).toEqual("2019-09-29");
|
|
1216
|
-
|
|
1217
|
-
const daySlots = checkedSlots[0].slots;
|
|
1218
|
-
expect(daySlots.length).toEqual(10);
|
|
1219
|
-
|
|
1220
|
-
// Before start of the period
|
|
1221
|
-
expect(daySlots[0].start).toEqual("2019-09-29T09:00:00Z");
|
|
1222
|
-
expect(daySlots[0].available).toEqual(false);
|
|
1223
|
-
expect(daySlots[0].visiblyAvailable).toEqual(false);
|
|
1224
|
-
expect(daySlots[0].target).toEqual(false);
|
|
1225
|
-
|
|
1226
|
-
// Before start of the period
|
|
1227
|
-
expect(daySlots[1].start).toEqual("2019-09-29T09:15:00Z");
|
|
1228
|
-
expect(daySlots[1].available).toEqual(false);
|
|
1229
|
-
expect(daySlots[1].visiblyAvailable).toEqual(false);
|
|
1230
|
-
expect(daySlots[1].target).toEqual(false);
|
|
1231
|
-
|
|
1232
|
-
// 9:30 - 10:30 is available and in period
|
|
1233
|
-
expect(daySlots[2].start).toEqual("2019-09-29T09:30:00Z");
|
|
1234
|
-
expect(daySlots[2].available).toEqual(true);
|
|
1235
|
-
expect(daySlots[2].visiblyAvailable).toEqual(true);
|
|
1236
|
-
expect(daySlots[2].target).toEqual(false);
|
|
1237
|
-
expect(daySlots[2].targetOffset).toEqual(false);
|
|
1238
|
-
|
|
1239
|
-
// Not enough time but can be part of the 9:30 - 10:30 slot
|
|
1240
|
-
expect(daySlots[3].start).toEqual("2019-09-29T09:45:00Z");
|
|
1241
|
-
expect(daySlots[3].available).toEqual(false);
|
|
1242
|
-
expect(daySlots[3].visiblyAvailable).toEqual(true);
|
|
1243
|
-
expect(daySlots[3].target).toEqual(daySlots[2].start);
|
|
1244
|
-
expect(daySlots[3].targetOffset).toEqual(3);
|
|
1245
|
-
|
|
1246
|
-
// Not enough time but can be part of the 9:30 - 10:30 slot
|
|
1247
|
-
expect(daySlots[4].start).toEqual("2019-09-29T10:00:00Z");
|
|
1248
|
-
expect(daySlots[4].available).toEqual(false);
|
|
1249
|
-
expect(daySlots[4].visiblyAvailable).toEqual(true);
|
|
1250
|
-
expect(daySlots[4].target).toEqual(daySlots[2].start);
|
|
1251
|
-
expect(daySlots[4].targetOffset).toEqual(2);
|
|
1252
|
-
|
|
1253
|
-
// Not enough time but can be part of the 9:30 - 10:30 slot
|
|
1254
|
-
expect(daySlots[5].start).toEqual("2019-09-29T10:15:00Z");
|
|
1255
|
-
expect(daySlots[5].available).toEqual(false);
|
|
1256
|
-
expect(daySlots[5].visiblyAvailable).toEqual(true);
|
|
1257
|
-
expect(daySlots[5].target).toEqual(daySlots[2].start);
|
|
1258
|
-
expect(daySlots[5].targetOffset).toEqual(1);
|
|
1259
|
-
|
|
1260
|
-
// Start of selected period - 10:30 - 11: 30
|
|
1261
|
-
expect(daySlots[6].start).toEqual("2019-09-29T10:30:00Z");
|
|
1262
|
-
expect(daySlots[6].available).toEqual(false);
|
|
1263
|
-
expect(daySlots[6].visiblyAvailable).toEqual(true);
|
|
1264
|
-
expect(daySlots[6].target).toEqual(false);
|
|
1265
|
-
|
|
1266
|
-
// part of selected period - 10:30 - 11: 30
|
|
1267
|
-
expect(daySlots[7].start).toEqual("2019-09-29T10:45:00Z");
|
|
1268
|
-
expect(daySlots[7].available).toEqual(false);
|
|
1269
|
-
expect(daySlots[7].visiblyAvailable).toEqual(true);
|
|
1270
|
-
expect(daySlots[7].target).toEqual(false);
|
|
1271
|
-
});
|
|
1272
|
-
});
|
|
1273
|
-
|
|
1274
|
-
describe("buildPeriodsFromSlots", () => {
|
|
1275
|
-
it("combines abutting slots into periods", () => {
|
|
1276
|
-
const slots = [
|
|
1277
|
-
{
|
|
1278
|
-
start: "2020-06-16T08:00:00Z",
|
|
1279
|
-
end: "2020-06-16T08:30:00Z",
|
|
1280
|
-
},
|
|
1281
|
-
{
|
|
1282
|
-
start: "2020-06-16T08:30:00Z",
|
|
1283
|
-
end: "2020-06-16T09:00:00Z",
|
|
1284
|
-
},
|
|
1285
|
-
{
|
|
1286
|
-
start: "2020-06-16T10:00:00Z",
|
|
1287
|
-
end: "2020-06-16T10:30:00Z",
|
|
1288
|
-
},
|
|
1289
|
-
{
|
|
1290
|
-
start: "2020-06-16T10:30:00Z",
|
|
1291
|
-
end: "2020-06-16T11:00:00Z",
|
|
1292
|
-
},
|
|
1293
|
-
{
|
|
1294
|
-
start: "2020-06-16T11:00:00Z",
|
|
1295
|
-
end: "2020-06-16T11:30:00Z",
|
|
1296
|
-
},
|
|
1297
|
-
];
|
|
1298
|
-
const expectedPeriods = [
|
|
1299
|
-
{
|
|
1300
|
-
start: "2020-06-16T08:00:00Z",
|
|
1301
|
-
end: "2020-06-16T09:00:00Z",
|
|
1302
|
-
},
|
|
1303
|
-
{
|
|
1304
|
-
start: "2020-06-16T10:00:00Z",
|
|
1305
|
-
end: "2020-06-16T11:30:00Z",
|
|
1306
|
-
},
|
|
1307
|
-
];
|
|
1308
|
-
const periods = utils.buildPeriodsFromSlots(slots);
|
|
1309
|
-
expect(periods.length).toEqual(2);
|
|
1310
|
-
expect(periods[0]).toEqual(expectedPeriods[0]);
|
|
1311
|
-
});
|
|
1312
|
-
|
|
1313
|
-
it("warns when slots are negative length", () => {
|
|
1314
|
-
const slots = [
|
|
1315
|
-
{
|
|
1316
|
-
start: "2020-10-23T09:00:00Z",
|
|
1317
|
-
end: "2020-10-22T09:00:00Z",
|
|
1318
|
-
},
|
|
1319
|
-
];
|
|
1320
|
-
const expectedPeriods = [];
|
|
1321
|
-
const periods = utils.buildPeriodsFromSlots(slots);
|
|
1322
|
-
});
|
|
1323
|
-
|
|
1324
|
-
it("combines unsorted abutting slots into periods", () => {
|
|
1325
|
-
const slots = [
|
|
1326
|
-
{
|
|
1327
|
-
start: "2020-06-16T08:30:00Z",
|
|
1328
|
-
end: "2020-06-16T09:00:00Z",
|
|
1329
|
-
},
|
|
1330
|
-
{
|
|
1331
|
-
start: "2020-06-16T08:00:00Z",
|
|
1332
|
-
end: "2020-06-16T08:30:00Z",
|
|
1333
|
-
},
|
|
1334
|
-
{
|
|
1335
|
-
start: "2020-06-16T10:30:00Z",
|
|
1336
|
-
end: "2020-06-16T11:00:00Z",
|
|
1337
|
-
},
|
|
1338
|
-
{
|
|
1339
|
-
start: "2020-06-17T10:30:00Z",
|
|
1340
|
-
end: "2020-06-17T11:00:00Z",
|
|
1341
|
-
},
|
|
1342
|
-
{
|
|
1343
|
-
start: "2020-06-16T11:00:00Z",
|
|
1344
|
-
end: "2020-06-16T11:30:00Z",
|
|
1345
|
-
},
|
|
1346
|
-
{
|
|
1347
|
-
start: "2020-06-16T10:00:00Z",
|
|
1348
|
-
end: "2020-06-16T10:30:00Z",
|
|
1349
|
-
},
|
|
1350
|
-
];
|
|
1351
|
-
const expectedPeriods = [
|
|
1352
|
-
{
|
|
1353
|
-
start: "2020-06-16T08:00:00Z",
|
|
1354
|
-
end: "2020-06-16T09:00:00Z",
|
|
1355
|
-
},
|
|
1356
|
-
{
|
|
1357
|
-
start: "2020-06-16T10:00:00Z",
|
|
1358
|
-
end: "2020-06-16T11:30:00Z",
|
|
1359
|
-
},
|
|
1360
|
-
{
|
|
1361
|
-
start: "2020-06-17T10:30:00Z",
|
|
1362
|
-
end: "2020-06-17T11:00:00Z",
|
|
1363
|
-
},
|
|
1364
|
-
];
|
|
1365
|
-
const periods = utils.buildPeriodsFromSlots(slots);
|
|
1366
|
-
expect(periods.length).toEqual(3);
|
|
1367
|
-
expect(periods[0]).toEqual(expectedPeriods[0]);
|
|
1368
|
-
expect(periods[1]).toEqual(expectedPeriods[1]);
|
|
1369
|
-
expect(periods[2]).toEqual(expectedPeriods[2]);
|
|
1370
|
-
});
|
|
1371
|
-
});
|
|
1372
|
-
|
|
1373
|
-
describe("tweenSlots", () => {
|
|
1374
|
-
it("calculates tweens for slot-starts", () => {
|
|
1375
|
-
const options = {
|
|
1376
|
-
start: "2020-06-16T08:00:00Z",
|
|
1377
|
-
end: "2020-06-16T11:30:00Z",
|
|
1378
|
-
tzid: "Europe/London",
|
|
1379
|
-
interval: 30,
|
|
1380
|
-
};
|
|
1381
|
-
const expected = [
|
|
1382
|
-
"2020-06-16T08:00:00Z",
|
|
1383
|
-
"2020-06-16T08:30:00Z",
|
|
1384
|
-
"2020-06-16T09:00:00Z",
|
|
1385
|
-
"2020-06-16T09:30:00Z",
|
|
1386
|
-
"2020-06-16T10:00:00Z",
|
|
1387
|
-
"2020-06-16T10:30:00Z",
|
|
1388
|
-
"2020-06-16T11:00:00Z",
|
|
1389
|
-
"2020-06-16T11:30:00Z",
|
|
1390
|
-
];
|
|
1391
|
-
|
|
1392
|
-
const result = utils.tweenSlots(options);
|
|
1393
|
-
expect(result).toEqual(expected);
|
|
1394
|
-
expect(Array.isArray(result)).toBe(true);
|
|
1395
|
-
expect(result.length).toBe(expected.length);
|
|
1396
|
-
});
|
|
1397
|
-
it("calculates tweens for cross-day slot-starts", () => {
|
|
1398
|
-
const options = {
|
|
1399
|
-
start: "2020-06-16T08:00:00Z",
|
|
1400
|
-
end: "2020-06-17T10:00:00Z",
|
|
1401
|
-
tzid: "America/Toronto",
|
|
1402
|
-
interval: 60,
|
|
1403
|
-
};
|
|
1404
|
-
const expected = [
|
|
1405
|
-
"2020-06-16T08:00:00Z",
|
|
1406
|
-
"2020-06-16T09:00:00Z",
|
|
1407
|
-
"2020-06-16T10:00:00Z",
|
|
1408
|
-
"2020-06-17T08:00:00Z",
|
|
1409
|
-
"2020-06-17T09:00:00Z",
|
|
1410
|
-
"2020-06-17T10:00:00Z",
|
|
1411
|
-
];
|
|
1412
|
-
|
|
1413
|
-
const result = utils.tweenSlots(options);
|
|
1414
|
-
expect(result).toEqual(expected);
|
|
1415
|
-
expect(Array.isArray(result)).toBe(true);
|
|
1416
|
-
expect(result.length).toBe(expected.length);
|
|
1417
|
-
});
|
|
1418
|
-
|
|
1419
|
-
it("calculates tweens for cross-day slot-starts over timezone boundaries", () => {
|
|
1420
|
-
const options = {
|
|
1421
|
-
// In America/Toronto, these times cross midnight
|
|
1422
|
-
// so there should be blocks for FOUR days (not
|
|
1423
|
-
// just the three that 23rd - 25th would suggest)
|
|
1424
|
-
start: "2020-06-23T02:00:00Z",
|
|
1425
|
-
end: "2020-06-25T21:00:00Z",
|
|
1426
|
-
tzid: "America/Toronto",
|
|
1427
|
-
interval: 60,
|
|
1428
|
-
};
|
|
1429
|
-
const expected = [
|
|
1430
|
-
// Block 1
|
|
1431
|
-
"2020-06-22T21:00:00Z",
|
|
1432
|
-
"2020-06-22T22:00:00Z",
|
|
1433
|
-
"2020-06-22T23:00:00Z",
|
|
1434
|
-
"2020-06-23T00:00:00Z",
|
|
1435
|
-
"2020-06-23T01:00:00Z",
|
|
1436
|
-
"2020-06-23T02:00:00Z",
|
|
1437
|
-
// Block 2
|
|
1438
|
-
"2020-06-23T21:00:00Z",
|
|
1439
|
-
"2020-06-23T22:00:00Z",
|
|
1440
|
-
"2020-06-23T23:00:00Z",
|
|
1441
|
-
"2020-06-24T00:00:00Z",
|
|
1442
|
-
"2020-06-24T01:00:00Z",
|
|
1443
|
-
"2020-06-24T02:00:00Z",
|
|
1444
|
-
// Block 3
|
|
1445
|
-
"2020-06-24T21:00:00Z",
|
|
1446
|
-
"2020-06-24T22:00:00Z",
|
|
1447
|
-
"2020-06-24T23:00:00Z",
|
|
1448
|
-
"2020-06-25T00:00:00Z",
|
|
1449
|
-
"2020-06-25T01:00:00Z",
|
|
1450
|
-
"2020-06-25T02:00:00Z",
|
|
1451
|
-
// Block 4
|
|
1452
|
-
"2020-06-25T21:00:00Z",
|
|
1453
|
-
"2020-06-25T22:00:00Z",
|
|
1454
|
-
"2020-06-25T23:00:00Z",
|
|
1455
|
-
"2020-06-26T00:00:00Z",
|
|
1456
|
-
"2020-06-26T01:00:00Z",
|
|
1457
|
-
"2020-06-26T02:00:00Z",
|
|
1458
|
-
];
|
|
1459
|
-
|
|
1460
|
-
const result = utils.tweenSlots(options);
|
|
1461
|
-
expect(result).toEqual(expected);
|
|
1462
|
-
expect(Array.isArray(result)).toBe(true);
|
|
1463
|
-
expect(result.length).toBe(expected.length);
|
|
1464
|
-
});
|
|
1465
|
-
});
|
|
1466
|
-
|
|
1467
|
-
// addSlotStarts
|
|
1468
|
-
it("adds N slot start times", () => {
|
|
1469
|
-
const options = [moment("2020-06-16T08:00:00Z", "YYYY-MM-DDTHH:mm:00Z"), 30, 4];
|
|
1470
|
-
const expected = [
|
|
1471
|
-
"2020-06-16T08:00:00Z",
|
|
1472
|
-
"2020-06-16T08:30:00Z",
|
|
1473
|
-
"2020-06-16T09:00:00Z",
|
|
1474
|
-
"2020-06-16T09:30:00Z",
|
|
1475
|
-
"2020-06-16T10:00:00Z",
|
|
1476
|
-
];
|
|
1477
|
-
const result = utils.addSlotStarts(...options);
|
|
1478
|
-
expect(result).toEqual(expected);
|
|
1479
|
-
});
|
|
1480
|
-
|
|
1481
|
-
// getDayOffset
|
|
1482
|
-
it("calculates the numerical difference between two day strings", () => {
|
|
1483
|
-
const tueSun = utils.getDayOffset("tuesday", "sunday");
|
|
1484
|
-
expect(tueSun).toEqual(2);
|
|
1485
|
-
|
|
1486
|
-
const sunTue = utils.getDayOffset("sunday", "tuesday");
|
|
1487
|
-
expect(sunTue).toEqual(5);
|
|
1488
|
-
|
|
1489
|
-
const sunSun = utils.getDayOffset("sunday", "sunday");
|
|
1490
|
-
expect(sunSun).toEqual(0);
|
|
1491
|
-
|
|
1492
|
-
const monMon = utils.getDayOffset("monday", "monday");
|
|
1493
|
-
expect(monMon).toEqual(0);
|
|
1494
|
-
|
|
1495
|
-
const tueTue = utils.getDayOffset("tuesday", "tuesday");
|
|
1496
|
-
expect(tueTue).toEqual(0);
|
|
1497
|
-
|
|
1498
|
-
const sunMon = utils.getDayOffset("sunday", "monday");
|
|
1499
|
-
expect(sunMon).toEqual(6);
|
|
1500
|
-
|
|
1501
|
-
const monSun = utils.getDayOffset("monday", "sunday");
|
|
1502
|
-
expect(monSun).toEqual(1);
|
|
1503
|
-
|
|
1504
|
-
const friWed = utils.getDayOffset("friday", "wednesday");
|
|
1505
|
-
expect(friWed).toEqual(2);
|
|
1506
|
-
|
|
1507
|
-
const wedFri = utils.getDayOffset("wednesday", "friday");
|
|
1508
|
-
expect(wedFri).toEqual(5);
|
|
1509
|
-
});
|
|
1510
|
-
|
|
1511
|
-
// condenseTimeLabel
|
|
1512
|
-
it("correctly truncates time string based on locale", () => {
|
|
1513
|
-
const enTimes = ["09:00", "10:00", "13:00", "23:00"];
|
|
1514
|
-
const usTimes = ["9:00 am", "10:00 am", "1:00 pm", "11 pm"];
|
|
1515
|
-
const weirds = ["9:00am", "1:00 PM", "11pm", "02pm", "02 pm"];
|
|
1516
|
-
|
|
1517
|
-
expect(utils.condenseTimeLabel(enTimes[0])).toEqual("09");
|
|
1518
|
-
expect(utils.condenseTimeLabel(enTimes[1])).toEqual("10");
|
|
1519
|
-
expect(utils.condenseTimeLabel(enTimes[2])).toEqual("13");
|
|
1520
|
-
expect(utils.condenseTimeLabel(enTimes[3])).toEqual("23");
|
|
1521
|
-
|
|
1522
|
-
expect(utils.condenseTimeLabel(usTimes[0])).toEqual("9a");
|
|
1523
|
-
expect(utils.condenseTimeLabel(usTimes[1])).toEqual("10a");
|
|
1524
|
-
expect(utils.condenseTimeLabel(usTimes[2])).toEqual("1p");
|
|
1525
|
-
expect(utils.condenseTimeLabel(usTimes[3])).toEqual("11p");
|
|
1526
|
-
|
|
1527
|
-
expect(utils.condenseTimeLabel(weirds[0])).toEqual("9a");
|
|
1528
|
-
expect(utils.condenseTimeLabel(weirds[1])).toEqual("1P");
|
|
1529
|
-
expect(utils.condenseTimeLabel(weirds[2])).toEqual("11p");
|
|
1530
|
-
expect(utils.condenseTimeLabel(weirds[3])).toEqual("02p");
|
|
1531
|
-
expect(utils.condenseTimeLabel(weirds[4])).toEqual("02p");
|
|
1532
|
-
});
|
|
1533
|
-
|
|
1534
|
-
describe("cropDaysToWindow", () => {
|
|
1535
|
-
it("crops an array of days into a defined window", () => {
|
|
1536
|
-
const rawDays = [
|
|
1537
|
-
"2021-03-25",
|
|
1538
|
-
"2021-03-26",
|
|
1539
|
-
"2021-03-27",
|
|
1540
|
-
"2021-03-28",
|
|
1541
|
-
"2021-03-29",
|
|
1542
|
-
"2021-03-30",
|
|
1543
|
-
"2021-03-31",
|
|
1544
|
-
"2021-04-01",
|
|
1545
|
-
"2021-04-02",
|
|
1546
|
-
"2021-04-03",
|
|
1547
|
-
"2021-04-04",
|
|
1548
|
-
"2021-04-05",
|
|
1549
|
-
"2021-04-06",
|
|
1550
|
-
];
|
|
1551
|
-
const windowSize = 8;
|
|
1552
|
-
|
|
1553
|
-
const { days, overflow } = utils.cropDaysToWindow(rawDays, windowSize);
|
|
1554
|
-
|
|
1555
|
-
expect(days.length).toBe(8);
|
|
1556
|
-
expect(overflow.length).toBe(6);
|
|
1557
|
-
expect(days[0]).toEqual("2021-03-25");
|
|
1558
|
-
expect(days[days.length - 1]).toEqual("2021-04-01");
|
|
1559
|
-
});
|
|
1560
|
-
|
|
1561
|
-
it("works when window is longer than array", () => {
|
|
1562
|
-
const rawDays = ["2021-03-25", "2021-03-26", "2021-03-27", "2021-03-28"];
|
|
1563
|
-
const windowSize = 8;
|
|
1564
|
-
|
|
1565
|
-
const { days, overflow } = utils.cropDaysToWindow(rawDays, windowSize);
|
|
1566
|
-
|
|
1567
|
-
expect(days.length).toBe(4);
|
|
1568
|
-
expect(overflow.length).toBe(0);
|
|
1569
|
-
expect(days[0]).toEqual("2021-03-25");
|
|
1570
|
-
expect(days[days.length - 1]).toEqual("2021-03-28");
|
|
1571
|
-
});
|
|
1572
|
-
|
|
1573
|
-
it("provides an array of overflow days (with a 1 day overlap)", () => {
|
|
1574
|
-
const rawDays = [
|
|
1575
|
-
"2021-03-25",
|
|
1576
|
-
"2021-03-26",
|
|
1577
|
-
"2021-03-27",
|
|
1578
|
-
"2021-03-28",
|
|
1579
|
-
"2021-03-29",
|
|
1580
|
-
"2021-03-30",
|
|
1581
|
-
"2021-03-31",
|
|
1582
|
-
"2021-04-01",
|
|
1583
|
-
"2021-04-02",
|
|
1584
|
-
"2021-04-03",
|
|
1585
|
-
"2021-04-04",
|
|
1586
|
-
"2021-04-05",
|
|
1587
|
-
"2021-04-06",
|
|
1588
|
-
];
|
|
1589
|
-
const windowSize = 8;
|
|
1590
|
-
|
|
1591
|
-
const { days, overflow } = utils.cropDaysToWindow(rawDays, windowSize);
|
|
1592
|
-
|
|
1593
|
-
expect(days.length).toBe(8);
|
|
1594
|
-
expect(overflow.length).toBe(6);
|
|
1595
|
-
expect(days[0]).toEqual("2021-03-25");
|
|
1596
|
-
expect(days[days.length - 1]).toEqual("2021-04-01");
|
|
1597
|
-
|
|
1598
|
-
expect(overflow[0]).toEqual("2021-04-01");
|
|
1599
|
-
expect(overflow[overflow.length - 1]).toEqual("2021-04-06");
|
|
1600
|
-
});
|
|
1601
|
-
});
|
|
1602
|
-
|
|
1603
|
-
describe("generate labels", () => {
|
|
1604
|
-
it("gets all labels", () => {
|
|
1605
|
-
const options = {
|
|
1606
|
-
days: [
|
|
1607
|
-
"2021-01-17",
|
|
1608
|
-
"2021-01-18",
|
|
1609
|
-
"2021-01-19",
|
|
1610
|
-
"2021-01-20",
|
|
1611
|
-
"2021-01-21",
|
|
1612
|
-
"2021-01-22",
|
|
1613
|
-
"2021-01-23",
|
|
1614
|
-
],
|
|
1615
|
-
limits: {
|
|
1616
|
-
duration: 60,
|
|
1617
|
-
start: "10:00",
|
|
1618
|
-
end: "14:00",
|
|
1619
|
-
interval: 30,
|
|
1620
|
-
},
|
|
1621
|
-
tzid: "Europe/London",
|
|
1622
|
-
i18n: {
|
|
1623
|
-
f: jest.fn(() => "STRING"),
|
|
1624
|
-
},
|
|
1625
|
-
locale: "en",
|
|
1626
|
-
};
|
|
1627
|
-
const allLabels = utils.getAllLabels(options);
|
|
1628
|
-
expect(allLabels.length).toBe(1);
|
|
1629
|
-
expect(allLabels[0].days.length).toBe(7);
|
|
1630
|
-
expect(allLabels[0].days[0].date).toBe(options.days[0]);
|
|
1631
|
-
expect(allLabels[0].days[0].number).toBe("STRING");
|
|
1632
|
-
expect(allLabels[0].days[0].name).toBe("STRING");
|
|
1633
|
-
expect(allLabels[0].days[6].date).toBe(options.days[6]);
|
|
1634
|
-
expect(allLabels[0].month).toBe("Jan 2021");
|
|
1635
|
-
expect(allLabels[0].times.length).toBe(8);
|
|
1636
|
-
expect(allLabels[0].times[0].start).toBe("2021-01-18T10:00:00Z");
|
|
1637
|
-
expect(allLabels[0].times[0].hour).toBe(true);
|
|
1638
|
-
expect(allLabels[0].times[1].start).toBe("2021-01-18T10:30:00Z");
|
|
1639
|
-
expect(allLabels[0].times[1].hour).toBe(false);
|
|
1640
|
-
});
|
|
1641
|
-
|
|
1642
|
-
it("detects when days match", () => {
|
|
1643
|
-
const days = ["2021-01-30", "2021-01-31", "2021-02-01", "2021-02-02"];
|
|
1644
|
-
const fullList = [
|
|
1645
|
-
{
|
|
1646
|
-
days: [
|
|
1647
|
-
{ date: "2021-01-30" },
|
|
1648
|
-
{ date: "2021-01-31" },
|
|
1649
|
-
{ date: "2021-02-01" },
|
|
1650
|
-
{ date: "2021-02-02" },
|
|
1651
|
-
],
|
|
1652
|
-
},
|
|
1653
|
-
];
|
|
1654
|
-
|
|
1655
|
-
const justKeyDates = [
|
|
1656
|
-
{
|
|
1657
|
-
days: [{ date: "2021-01-30" }, { date: "2021-02-02" }],
|
|
1658
|
-
},
|
|
1659
|
-
];
|
|
1660
|
-
|
|
1661
|
-
const matchFull = utils.checkIfDaysMatch(days, fullList);
|
|
1662
|
-
expect(matchFull).toBe(true);
|
|
1663
|
-
|
|
1664
|
-
const matchKeyDates = utils.checkIfDaysMatch(days, justKeyDates);
|
|
1665
|
-
expect(matchKeyDates).toBe(true);
|
|
1666
|
-
});
|
|
1667
|
-
|
|
1668
|
-
it("detects when days differ", () => {
|
|
1669
|
-
const days = ["2021-01-30", "2021-01-31", "2021-02-01", "2021-02-02"];
|
|
1670
|
-
|
|
1671
|
-
const inclusiveMore = [
|
|
1672
|
-
{
|
|
1673
|
-
days: [
|
|
1674
|
-
{ date: "2021-01-29" },
|
|
1675
|
-
{ date: "2021-01-30" },
|
|
1676
|
-
{ date: "2021-01-31" },
|
|
1677
|
-
{ date: "2021-02-01" },
|
|
1678
|
-
{ date: "2021-02-02" },
|
|
1679
|
-
{ date: "2021-02-03" },
|
|
1680
|
-
],
|
|
1681
|
-
},
|
|
1682
|
-
];
|
|
1683
|
-
const matchInclusiveMore = utils.checkIfDaysMatch(days, inclusiveMore);
|
|
1684
|
-
expect(matchInclusiveMore).toBe(false);
|
|
1685
|
-
|
|
1686
|
-
const inclusiveFewer = [
|
|
1687
|
-
{
|
|
1688
|
-
days: [{ date: "2021-01-31" }, { date: "2021-02-01" }],
|
|
1689
|
-
},
|
|
1690
|
-
];
|
|
1691
|
-
const matchInclusiveFewer = utils.checkIfDaysMatch(days, inclusiveFewer);
|
|
1692
|
-
expect(matchInclusiveFewer).toBe(false);
|
|
1693
|
-
|
|
1694
|
-
const overlapPre = [
|
|
1695
|
-
{
|
|
1696
|
-
days: [{ date: "2021-01-29" }, { date: "2021-01-30" }, { date: "2021-01-31" }],
|
|
1697
|
-
},
|
|
1698
|
-
];
|
|
1699
|
-
const matchOverlapPre = utils.checkIfDaysMatch(days, overlapPre);
|
|
1700
|
-
expect(matchOverlapPre).toBe(false);
|
|
1701
|
-
|
|
1702
|
-
const overlapPost = [
|
|
1703
|
-
{
|
|
1704
|
-
days: [{ date: "2021-02-01" }, { date: "2021-02-02" }, { date: "2021-02-03" }],
|
|
1705
|
-
},
|
|
1706
|
-
];
|
|
1707
|
-
const matchOverlapPost = utils.checkIfDaysMatch(days, overlapPost);
|
|
1708
|
-
expect(matchOverlapPost).toBe(false);
|
|
1709
|
-
});
|
|
1710
|
-
|
|
1711
|
-
it("detects missmatch with empty option", () => {
|
|
1712
|
-
const days = ["2021-01-30", "2021-01-31", "2021-02-01", "2021-02-02"];
|
|
1713
|
-
const matchEmpty = utils.checkIfDaysMatch(days, []);
|
|
1714
|
-
|
|
1715
|
-
expect(matchEmpty).toBe(false);
|
|
1716
|
-
|
|
1717
|
-
const matchMissing = utils.checkIfDaysMatch(days);
|
|
1718
|
-
|
|
1719
|
-
expect(matchMissing).toBe(false);
|
|
1720
|
-
});
|
|
1721
|
-
|
|
1722
|
-
it("detects when limits match", () => {
|
|
1723
|
-
const limits = { start: "08:00", end: "17:30" };
|
|
1724
|
-
const times = [
|
|
1725
|
-
{
|
|
1726
|
-
start: "2021-01-18T08:00:00Z",
|
|
1727
|
-
end: "2021-01-18T17:30:00Z",
|
|
1728
|
-
},
|
|
1729
|
-
];
|
|
1730
|
-
const matchEmpty = utils.checkIfLimitsMatch(limits, times);
|
|
1731
|
-
|
|
1732
|
-
expect(matchEmpty).toBe(true);
|
|
1733
|
-
});
|
|
1734
|
-
|
|
1735
|
-
it("detects when start limit does not match", () => {
|
|
1736
|
-
const limits = { start: "00:00", end: "17:30" };
|
|
1737
|
-
const times = [
|
|
1738
|
-
{
|
|
1739
|
-
start: "2021-01-18T08:00:00Z",
|
|
1740
|
-
end: "2021-01-18T17:30:00Z",
|
|
1741
|
-
},
|
|
1742
|
-
];
|
|
1743
|
-
const matchEmpty = utils.checkIfLimitsMatch(limits, times);
|
|
1744
|
-
|
|
1745
|
-
expect(matchEmpty).toBe(false);
|
|
1746
|
-
});
|
|
1747
|
-
|
|
1748
|
-
it("detects when end limit does not match", () => {
|
|
1749
|
-
const limits = { start: "08:00", end: "17:00" };
|
|
1750
|
-
const times = [
|
|
1751
|
-
{
|
|
1752
|
-
start: "2021-01-18T08:00:00Z",
|
|
1753
|
-
end: "2021-01-18T17:30:00Z",
|
|
1754
|
-
},
|
|
1755
|
-
];
|
|
1756
|
-
const matchEmpty = utils.checkIfLimitsMatch(limits, times);
|
|
1757
|
-
|
|
1758
|
-
expect(matchEmpty).toBe(false);
|
|
1759
|
-
});
|
|
1760
|
-
|
|
1761
|
-
it("detects when both limits do not match", () => {
|
|
1762
|
-
const limits = { start: "07:00", end: "17:00" };
|
|
1763
|
-
const times = [
|
|
1764
|
-
{
|
|
1765
|
-
start: "2021-01-18T08:00:00Z",
|
|
1766
|
-
end: "2021-01-18T17:30:00Z",
|
|
1767
|
-
},
|
|
1768
|
-
];
|
|
1769
|
-
const matchEmpty = utils.checkIfLimitsMatch(limits, times);
|
|
1770
|
-
|
|
1771
|
-
expect(matchEmpty).toBe(false);
|
|
1772
|
-
});
|
|
1773
|
-
|
|
1774
|
-
it("detects when both limits do not match", () => {
|
|
1775
|
-
const limits = { start: "07:00", end: "17:00" };
|
|
1776
|
-
const times = [
|
|
1777
|
-
{
|
|
1778
|
-
start: "2021-01-18T08:00:00Z",
|
|
1779
|
-
end: "2021-01-18T17:30:00Z",
|
|
1780
|
-
},
|
|
1781
|
-
];
|
|
1782
|
-
const matchEmpty = utils.checkIfLimitsMatch(limits, times);
|
|
1783
|
-
|
|
1784
|
-
expect(matchEmpty).toBe(false);
|
|
1785
|
-
});
|
|
1786
|
-
|
|
1787
|
-
it("handles matching limits when end is midnight", () => {
|
|
1788
|
-
const limits = { start: "08:00", end: "24:00" };
|
|
1789
|
-
const times = [
|
|
1790
|
-
{
|
|
1791
|
-
start: "2021-01-18T08:00:00Z",
|
|
1792
|
-
end: "2021-01-19T00:00:00Z",
|
|
1793
|
-
},
|
|
1794
|
-
];
|
|
1795
|
-
const matchEmpty = utils.checkIfLimitsMatch(limits, times);
|
|
1796
|
-
|
|
1797
|
-
expect(matchEmpty).toBe(true);
|
|
1798
|
-
});
|
|
1799
|
-
});
|
|
1800
|
-
});
|