cronofy-elements 1.48.1 → 1.49.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/dist/.gitkeep +0 -0
- package/dist/CronofyElements.js +2 -0
- package/{build/CronofyElements.v1.48.1.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.1.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 -414
- 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 -44
- 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,435 +0,0 @@
|
|
|
1
|
-
import { statusReducer } from "../../src/js/components/CalendarSync/contexts/status-reducer";
|
|
2
|
-
|
|
3
|
-
describe("CalendarSync statusReducer", () => {
|
|
4
|
-
describe("TOGGLE_ADD_PROFILE", () => {
|
|
5
|
-
it("sets `adding` to `true` on the state", () => {
|
|
6
|
-
const initialState = {
|
|
7
|
-
adding: false,
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
const action = {
|
|
11
|
-
type: "TOGGLE_ADD_PROFILE",
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
const actual = statusReducer(initialState, action);
|
|
15
|
-
|
|
16
|
-
expect(actual).toEqual({
|
|
17
|
-
adding: true,
|
|
18
|
-
});
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
it("sets `adding` to `false` on the state", () => {
|
|
22
|
-
const initialState = {
|
|
23
|
-
adding: true,
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
const action = {
|
|
27
|
-
type: "TOGGLE_ADD_PROFILE",
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
const actual = statusReducer(initialState, action);
|
|
31
|
-
|
|
32
|
-
expect(actual).toEqual({
|
|
33
|
-
adding: false,
|
|
34
|
-
});
|
|
35
|
-
});
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
describe("REVOKE_PROFILE", () => {
|
|
39
|
-
it("invokes a callback with correct params", () => {
|
|
40
|
-
const initialState = {
|
|
41
|
-
callback: jest.fn(),
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
const action = {
|
|
45
|
-
type: "REVOKE_PROFILE",
|
|
46
|
-
profile: {
|
|
47
|
-
id: "some_id",
|
|
48
|
-
},
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
const actual = statusReducer(initialState, action);
|
|
52
|
-
|
|
53
|
-
expect(actual).toEqual(initialState);
|
|
54
|
-
expect(initialState.callback).toHaveBeenCalledTimes(1);
|
|
55
|
-
expect(initialState.callback).toHaveBeenCalledWith({
|
|
56
|
-
notification: {
|
|
57
|
-
type: "profile_revoke_pressed",
|
|
58
|
-
profile: action.profile,
|
|
59
|
-
},
|
|
60
|
-
});
|
|
61
|
-
});
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
describe("REVOKE_PROFILE_SUCCESS", () => {
|
|
65
|
-
it("sets `pendingNotification` on the state", () => {
|
|
66
|
-
const initialState = {
|
|
67
|
-
adding: false,
|
|
68
|
-
editing: true,
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
const action = {
|
|
72
|
-
type: "REVOKE_PROFILE_SUCCESS",
|
|
73
|
-
profile: {
|
|
74
|
-
id: "some_id",
|
|
75
|
-
},
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
const actual = statusReducer(initialState, action);
|
|
79
|
-
|
|
80
|
-
expect(actual).toEqual({
|
|
81
|
-
...initialState,
|
|
82
|
-
pendingNotification: {
|
|
83
|
-
type: "profile_revoked",
|
|
84
|
-
profile: action.profile,
|
|
85
|
-
},
|
|
86
|
-
});
|
|
87
|
-
});
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
describe("TOGGLE_EDIT_PROFILES", () => {
|
|
91
|
-
it("sets `editing` to `true` on the state", () => {
|
|
92
|
-
const initialState = {
|
|
93
|
-
editing: false,
|
|
94
|
-
};
|
|
95
|
-
|
|
96
|
-
const action = {
|
|
97
|
-
type: "TOGGLE_EDIT_PROFILES",
|
|
98
|
-
};
|
|
99
|
-
|
|
100
|
-
const actual = statusReducer(initialState, action);
|
|
101
|
-
|
|
102
|
-
expect(actual).toEqual({
|
|
103
|
-
editing: true,
|
|
104
|
-
});
|
|
105
|
-
});
|
|
106
|
-
|
|
107
|
-
it("sets `editing` to `false` on the state", () => {
|
|
108
|
-
const initialState = {
|
|
109
|
-
editing: true,
|
|
110
|
-
};
|
|
111
|
-
|
|
112
|
-
const action = {
|
|
113
|
-
type: "TOGGLE_EDIT_PROFILES",
|
|
114
|
-
};
|
|
115
|
-
|
|
116
|
-
const actual = statusReducer(initialState, action);
|
|
117
|
-
|
|
118
|
-
expect(actual).toEqual({
|
|
119
|
-
editing: false,
|
|
120
|
-
});
|
|
121
|
-
});
|
|
122
|
-
});
|
|
123
|
-
|
|
124
|
-
describe("GET_USER_INFO_SUCCESS", () => {
|
|
125
|
-
it("sets `loading` to `false` on the state", () => {
|
|
126
|
-
const initialState = {
|
|
127
|
-
loading: true,
|
|
128
|
-
type: null,
|
|
129
|
-
pendingNotification: null,
|
|
130
|
-
someOtherState: "yes",
|
|
131
|
-
};
|
|
132
|
-
|
|
133
|
-
const action = {
|
|
134
|
-
type: "GET_USER_INFO_SUCCESS",
|
|
135
|
-
userInfo: {
|
|
136
|
-
id: "some_id",
|
|
137
|
-
"cronofy.type": "account",
|
|
138
|
-
},
|
|
139
|
-
};
|
|
140
|
-
|
|
141
|
-
const expected = {
|
|
142
|
-
loading: false,
|
|
143
|
-
type: action.userInfo["cronofy.type"],
|
|
144
|
-
pendingNotification: null,
|
|
145
|
-
someOtherState: "yes",
|
|
146
|
-
};
|
|
147
|
-
|
|
148
|
-
const actualWithLoadingTrue = statusReducer(initialState, action);
|
|
149
|
-
const actualWithLoadingFalse = statusReducer(
|
|
150
|
-
{ ...initialState, loading: false },
|
|
151
|
-
action
|
|
152
|
-
);
|
|
153
|
-
|
|
154
|
-
expect(actualWithLoadingTrue).toEqual(expected);
|
|
155
|
-
expect(actualWithLoadingFalse).toEqual(expected);
|
|
156
|
-
});
|
|
157
|
-
|
|
158
|
-
it("sets `type` to the `cronofy.type` on the state", () => {
|
|
159
|
-
const initialState = {
|
|
160
|
-
loading: true,
|
|
161
|
-
type: null,
|
|
162
|
-
pendingNotification: null,
|
|
163
|
-
someOtherState: "yes",
|
|
164
|
-
};
|
|
165
|
-
|
|
166
|
-
const action = {
|
|
167
|
-
type: "GET_USER_INFO_SUCCESS",
|
|
168
|
-
userInfo: {
|
|
169
|
-
id: "some_id",
|
|
170
|
-
"cronofy.type": "account",
|
|
171
|
-
},
|
|
172
|
-
};
|
|
173
|
-
|
|
174
|
-
const expected = {
|
|
175
|
-
loading: false,
|
|
176
|
-
type: action.userInfo["cronofy.type"],
|
|
177
|
-
pendingNotification: null,
|
|
178
|
-
someOtherState: "yes",
|
|
179
|
-
};
|
|
180
|
-
|
|
181
|
-
const actualWithNullType = statusReducer(initialState, action);
|
|
182
|
-
const actualWithPopulatedType = statusReducer(
|
|
183
|
-
{ ...initialState, type: "some_value" },
|
|
184
|
-
action
|
|
185
|
-
);
|
|
186
|
-
|
|
187
|
-
expect(actualWithNullType).toEqual(expected);
|
|
188
|
-
expect(actualWithPopulatedType).toEqual(expected);
|
|
189
|
-
});
|
|
190
|
-
|
|
191
|
-
it("sets `pendingNotification` to `null` on the state", () => {
|
|
192
|
-
const callback = () => {};
|
|
193
|
-
|
|
194
|
-
const initialState = {
|
|
195
|
-
loading: true,
|
|
196
|
-
type: null,
|
|
197
|
-
pendingNotification: null,
|
|
198
|
-
someOtherState: "yes",
|
|
199
|
-
callback,
|
|
200
|
-
};
|
|
201
|
-
|
|
202
|
-
const action = {
|
|
203
|
-
type: "GET_USER_INFO_SUCCESS",
|
|
204
|
-
userInfo: {
|
|
205
|
-
id: "some_id",
|
|
206
|
-
"cronofy.type": "account",
|
|
207
|
-
},
|
|
208
|
-
};
|
|
209
|
-
|
|
210
|
-
const expected = {
|
|
211
|
-
loading: false,
|
|
212
|
-
type: action.userInfo["cronofy.type"],
|
|
213
|
-
pendingNotification: null,
|
|
214
|
-
someOtherState: "yes",
|
|
215
|
-
callback,
|
|
216
|
-
};
|
|
217
|
-
|
|
218
|
-
const actualWithNullNotification = statusReducer(initialState, action);
|
|
219
|
-
const actualWithPopulatedNotification = statusReducer(
|
|
220
|
-
{ ...initialState, pendingNotification: "some_value" },
|
|
221
|
-
action
|
|
222
|
-
);
|
|
223
|
-
|
|
224
|
-
expect(actualWithNullNotification).toEqual(expected);
|
|
225
|
-
expect(actualWithPopulatedNotification).toEqual(expected);
|
|
226
|
-
});
|
|
227
|
-
|
|
228
|
-
describe("when `pendingNotification` exists", () => {
|
|
229
|
-
it("invokes callback with correct params", () => {
|
|
230
|
-
const initialState = {
|
|
231
|
-
pendingNotification: {
|
|
232
|
-
type: "profile_revoked",
|
|
233
|
-
profile: {
|
|
234
|
-
id: "some_id",
|
|
235
|
-
},
|
|
236
|
-
},
|
|
237
|
-
callback: jest.fn(),
|
|
238
|
-
};
|
|
239
|
-
|
|
240
|
-
const action = {
|
|
241
|
-
type: "GET_USER_INFO_SUCCESS",
|
|
242
|
-
userInfo: {
|
|
243
|
-
id: "some_userinfo_id",
|
|
244
|
-
"cronofy.type": "account",
|
|
245
|
-
},
|
|
246
|
-
};
|
|
247
|
-
|
|
248
|
-
statusReducer(initialState, action);
|
|
249
|
-
|
|
250
|
-
expect(initialState.callback).toHaveBeenCalledTimes(1);
|
|
251
|
-
expect(initialState.callback).toHaveBeenCalledWith({
|
|
252
|
-
notification: initialState.pendingNotification,
|
|
253
|
-
userinfo: action.userInfo,
|
|
254
|
-
});
|
|
255
|
-
});
|
|
256
|
-
});
|
|
257
|
-
|
|
258
|
-
describe("when `pendingNotification` doesn't exist", () => {
|
|
259
|
-
it("doesn't invoke callback", () => {
|
|
260
|
-
const initialState = {
|
|
261
|
-
pendingNotification: null,
|
|
262
|
-
callback: jest.fn(),
|
|
263
|
-
};
|
|
264
|
-
|
|
265
|
-
const action = {
|
|
266
|
-
type: "GET_USER_INFO_SUCCESS",
|
|
267
|
-
userInfo: {
|
|
268
|
-
id: "some_userinfo_id",
|
|
269
|
-
"cronofy.type": "account",
|
|
270
|
-
},
|
|
271
|
-
};
|
|
272
|
-
|
|
273
|
-
statusReducer(initialState, action);
|
|
274
|
-
|
|
275
|
-
expect(initialState.callback).toHaveBeenCalledTimes(0);
|
|
276
|
-
});
|
|
277
|
-
});
|
|
278
|
-
});
|
|
279
|
-
|
|
280
|
-
describe("GET_USER_INFO_ERROR", () => {
|
|
281
|
-
it("sets `loading` to `false` on the state", () => {
|
|
282
|
-
const initialState = {
|
|
283
|
-
loading: true,
|
|
284
|
-
error: null,
|
|
285
|
-
};
|
|
286
|
-
|
|
287
|
-
const action = {
|
|
288
|
-
type: "GET_USER_INFO_ERROR",
|
|
289
|
-
error: null,
|
|
290
|
-
};
|
|
291
|
-
|
|
292
|
-
const expected = {
|
|
293
|
-
loading: false,
|
|
294
|
-
error: null,
|
|
295
|
-
};
|
|
296
|
-
|
|
297
|
-
const actualWithLoadingTrue = statusReducer(initialState, action);
|
|
298
|
-
const actualWithLoadingFalse = statusReducer(
|
|
299
|
-
{ ...initialState, loading: false },
|
|
300
|
-
action
|
|
301
|
-
);
|
|
302
|
-
|
|
303
|
-
expect(actualWithLoadingTrue).toEqual(expected);
|
|
304
|
-
expect(actualWithLoadingFalse).toEqual(expected);
|
|
305
|
-
});
|
|
306
|
-
|
|
307
|
-
it("sets `error` to correct value on the state", () => {
|
|
308
|
-
const initialState = {
|
|
309
|
-
loading: false,
|
|
310
|
-
error: null,
|
|
311
|
-
};
|
|
312
|
-
|
|
313
|
-
const action = {
|
|
314
|
-
type: "GET_USER_INFO_ERROR",
|
|
315
|
-
error: "some error",
|
|
316
|
-
};
|
|
317
|
-
|
|
318
|
-
const expected = {
|
|
319
|
-
loading: false,
|
|
320
|
-
error: action.error,
|
|
321
|
-
};
|
|
322
|
-
|
|
323
|
-
const actualWithNullError = statusReducer(initialState, action);
|
|
324
|
-
const actualWithExistingError = statusReducer(
|
|
325
|
-
{ ...initialState, error: "previous error" },
|
|
326
|
-
action
|
|
327
|
-
);
|
|
328
|
-
|
|
329
|
-
expect(actualWithNullError).toEqual(expected);
|
|
330
|
-
expect(actualWithExistingError).toEqual(expected);
|
|
331
|
-
});
|
|
332
|
-
});
|
|
333
|
-
|
|
334
|
-
describe("NO_TOKEN_SUCCESS", () => {
|
|
335
|
-
it("sets `loading` to `false` on the state", () => {
|
|
336
|
-
const initialState = {
|
|
337
|
-
type: null,
|
|
338
|
-
loading: true,
|
|
339
|
-
pendingNotification: null,
|
|
340
|
-
};
|
|
341
|
-
|
|
342
|
-
const action = {
|
|
343
|
-
type: "NO_TOKEN_SUCCESS",
|
|
344
|
-
};
|
|
345
|
-
|
|
346
|
-
const expected = {
|
|
347
|
-
type: null,
|
|
348
|
-
loading: false,
|
|
349
|
-
pendingNotification: null,
|
|
350
|
-
};
|
|
351
|
-
|
|
352
|
-
const actualWithLoadingTrue = statusReducer(initialState, action);
|
|
353
|
-
const actualWithLoadingFalse = statusReducer(
|
|
354
|
-
{ ...initialState, loading: false },
|
|
355
|
-
action
|
|
356
|
-
);
|
|
357
|
-
|
|
358
|
-
expect(actualWithLoadingTrue).toEqual(expected);
|
|
359
|
-
expect(actualWithLoadingFalse).toEqual(expected);
|
|
360
|
-
});
|
|
361
|
-
|
|
362
|
-
it("sets `pendingNotification` to `null` on the state", () => {
|
|
363
|
-
const callback = () => {};
|
|
364
|
-
|
|
365
|
-
const initialState = {
|
|
366
|
-
type: null,
|
|
367
|
-
loading: true,
|
|
368
|
-
pendingNotification: null,
|
|
369
|
-
callback,
|
|
370
|
-
};
|
|
371
|
-
|
|
372
|
-
const action = {
|
|
373
|
-
type: "NO_TOKEN_SUCCESS",
|
|
374
|
-
};
|
|
375
|
-
|
|
376
|
-
const expected = {
|
|
377
|
-
type: null,
|
|
378
|
-
loading: false,
|
|
379
|
-
pendingNotification: null,
|
|
380
|
-
callback,
|
|
381
|
-
};
|
|
382
|
-
|
|
383
|
-
const actualWithNullNotification = statusReducer(initialState, action);
|
|
384
|
-
const actualWithPopulatedNotification = statusReducer(
|
|
385
|
-
{ ...initialState, pendingNotification: "some_value" },
|
|
386
|
-
action
|
|
387
|
-
);
|
|
388
|
-
|
|
389
|
-
expect(actualWithNullNotification).toEqual(expected);
|
|
390
|
-
expect(actualWithPopulatedNotification).toEqual(expected);
|
|
391
|
-
});
|
|
392
|
-
|
|
393
|
-
describe("when `pendingNotification` exists", () => {
|
|
394
|
-
it("invokes callback", () => {
|
|
395
|
-
const initialState = {
|
|
396
|
-
pendingNotification: {
|
|
397
|
-
type: "profile_revoked",
|
|
398
|
-
profile: {
|
|
399
|
-
id: "some_id",
|
|
400
|
-
},
|
|
401
|
-
},
|
|
402
|
-
callback: jest.fn(),
|
|
403
|
-
};
|
|
404
|
-
|
|
405
|
-
const action = {
|
|
406
|
-
type: "NO_TOKEN_SUCCESS",
|
|
407
|
-
};
|
|
408
|
-
|
|
409
|
-
statusReducer(initialState, action);
|
|
410
|
-
|
|
411
|
-
expect(initialState.callback).toHaveBeenCalledTimes(1);
|
|
412
|
-
expect(initialState.callback).toHaveBeenCalledWith({
|
|
413
|
-
notification: initialState.pendingNotification,
|
|
414
|
-
});
|
|
415
|
-
});
|
|
416
|
-
});
|
|
417
|
-
|
|
418
|
-
describe("when `pendingNotification` doesn't exist", () => {
|
|
419
|
-
it("doesn't invoke callback", () => {
|
|
420
|
-
const initialState = {
|
|
421
|
-
pendingNotification: null,
|
|
422
|
-
callback: jest.fn(),
|
|
423
|
-
};
|
|
424
|
-
|
|
425
|
-
const action = {
|
|
426
|
-
type: "NO_TOKEN_SUCCESS",
|
|
427
|
-
};
|
|
428
|
-
|
|
429
|
-
statusReducer(initialState, action);
|
|
430
|
-
|
|
431
|
-
expect(initialState.callback).toHaveBeenCalledTimes(0);
|
|
432
|
-
});
|
|
433
|
-
});
|
|
434
|
-
});
|
|
435
|
-
});
|
|
@@ -1,157 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { render, fireEvent, within } from "@testing-library/react";
|
|
3
|
-
import "@testing-library/jest-dom";
|
|
4
|
-
|
|
5
|
-
import SequencedSlotButton from "../../src/js/components/DateTimePicker/SequencedSlotButton";
|
|
6
|
-
|
|
7
|
-
import { I18nProvider } from "../../src/js/contexts/i18n-context";
|
|
8
|
-
import { ThemeProvider } from "../../src/js/components/DateTimePicker/contexts/theme-context";
|
|
9
|
-
import { StatusProvider } from "../../src/js/components/DateTimePicker/contexts/status-context";
|
|
10
|
-
import { TzProvider } from "../../src/js/contexts/tz-context";
|
|
11
|
-
|
|
12
|
-
const wrapper = ({ children, status }) => (
|
|
13
|
-
<ThemeProvider options={{ name: "DTP" }}>
|
|
14
|
-
<I18nProvider
|
|
15
|
-
options={{
|
|
16
|
-
locale: "en",
|
|
17
|
-
slug: "date_time_picker",
|
|
18
|
-
tzid: "Europe/London",
|
|
19
|
-
}}
|
|
20
|
-
>
|
|
21
|
-
<TzProvider
|
|
22
|
-
options={{
|
|
23
|
-
selectedTzid: {
|
|
24
|
-
tzid: "Europe/London",
|
|
25
|
-
offset: "+01:00",
|
|
26
|
-
offsetMins: 60,
|
|
27
|
-
name: "London",
|
|
28
|
-
abbr: "BST",
|
|
29
|
-
},
|
|
30
|
-
list: [],
|
|
31
|
-
}}
|
|
32
|
-
>
|
|
33
|
-
<StatusProvider
|
|
34
|
-
options={{
|
|
35
|
-
selected: false,
|
|
36
|
-
...status,
|
|
37
|
-
}}
|
|
38
|
-
>
|
|
39
|
-
{children}
|
|
40
|
-
</StatusProvider>
|
|
41
|
-
</TzProvider>
|
|
42
|
-
</I18nProvider>
|
|
43
|
-
</ThemeProvider>
|
|
44
|
-
);
|
|
45
|
-
|
|
46
|
-
describe("SequencedSlotButton", () => {
|
|
47
|
-
const slot = [
|
|
48
|
-
{ sequence_id: "test-1", start: "2022-10-05T09:30:00Z", end: "2022-10-05T10:00:00Z" },
|
|
49
|
-
{ sequence_id: "test-2", start: "2022-10-05T10:30:00Z", end: "2022-10-05T11:00:00Z" },
|
|
50
|
-
];
|
|
51
|
-
|
|
52
|
-
it("displays slot button with correct start and end time", () => {
|
|
53
|
-
const { container } = render(<SequencedSlotButton slot={slot} />, { wrapper });
|
|
54
|
-
|
|
55
|
-
const button = container.querySelector(".DTP__time-slot");
|
|
56
|
-
|
|
57
|
-
expect(button).toBeInTheDocument();
|
|
58
|
-
expect(button.innerHTML).toEqual(expect.stringContaining("10:30 AM - 12:00 PM (BST)"));
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
it("displays slot button with time in BST", () => {
|
|
62
|
-
const { container } = render(<SequencedSlotButton slot={slot} />, { wrapper });
|
|
63
|
-
|
|
64
|
-
const button = container.querySelector(".DTP__time-slot");
|
|
65
|
-
|
|
66
|
-
expect(button).toBeInTheDocument();
|
|
67
|
-
expect(button.innerHTML).toEqual(expect.stringContaining("10:30 AM - 12:00 PM (BST)"));
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
it("displays a detailed view when slot button mode is set to detailed", () => {
|
|
71
|
-
const status = {
|
|
72
|
-
slotButtonMode: "detailed",
|
|
73
|
-
};
|
|
74
|
-
const { container } = render(<SequencedSlotButton slot={slot} />, {
|
|
75
|
-
wrapper: e => wrapper({ ...e, status }),
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
const button = container.querySelector(".DTP__time-slot");
|
|
79
|
-
const detailedList = container.querySelector(".DTP__detailed-slot-list");
|
|
80
|
-
|
|
81
|
-
expect(button).toBeInTheDocument();
|
|
82
|
-
expect(detailedList).toBeInTheDocument();
|
|
83
|
-
|
|
84
|
-
const { getAllByRole } = within(detailedList);
|
|
85
|
-
const items = getAllByRole("listitem");
|
|
86
|
-
expect(items.length).toBe(2);
|
|
87
|
-
|
|
88
|
-
const listText = items.map(item => item.textContent);
|
|
89
|
-
expect(listText).toMatchInlineSnapshot(`
|
|
90
|
-
Array [
|
|
91
|
-
"10:30 AM - 11:00 AM (BST)",
|
|
92
|
-
"11:30 AM - 12:00 PM (BST)",
|
|
93
|
-
]
|
|
94
|
-
`);
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
it("displays slot button with time in GMT", () => {
|
|
98
|
-
const slot = [
|
|
99
|
-
{ sequence_id: "test-1", start: "2022-11-05T09:30:00Z", end: "2022-11-05T10:00:00Z" },
|
|
100
|
-
{ sequence_id: "test-2", start: "2022-11-05T10:30:00Z", end: "2022-11-05T11:00:00Z" },
|
|
101
|
-
];
|
|
102
|
-
const { container } = render(<SequencedSlotButton slot={slot} />, { wrapper });
|
|
103
|
-
|
|
104
|
-
const button = container.querySelector(".DTP__time-slot");
|
|
105
|
-
|
|
106
|
-
expect(button).toBeInTheDocument();
|
|
107
|
-
expect(button.innerHTML).toEqual(expect.stringContaining("9:30 AM - 11:00 AM (GMT)"));
|
|
108
|
-
});
|
|
109
|
-
|
|
110
|
-
it("focuses if slot start time matches status.focusedSlot", () => {
|
|
111
|
-
const status = {
|
|
112
|
-
focusedSlot: "2022-10-05T09:30:00Z",
|
|
113
|
-
selected: false,
|
|
114
|
-
};
|
|
115
|
-
|
|
116
|
-
const { container } = render(<SequencedSlotButton slot={slot} />, {
|
|
117
|
-
wrapper: e => wrapper({ ...e, status }),
|
|
118
|
-
});
|
|
119
|
-
|
|
120
|
-
const button = container.querySelector("button");
|
|
121
|
-
|
|
122
|
-
expect(button).toHaveFocus();
|
|
123
|
-
});
|
|
124
|
-
|
|
125
|
-
it("sets the slot to selected when button is clicked", () => {
|
|
126
|
-
const { container } = render(<SequencedSlotButton slot={slot} />, { wrapper });
|
|
127
|
-
|
|
128
|
-
const button = container.querySelector("button");
|
|
129
|
-
|
|
130
|
-
expect(button).not.toHaveClass("DTP_time-slot--selected");
|
|
131
|
-
|
|
132
|
-
fireEvent.click(button);
|
|
133
|
-
|
|
134
|
-
expect(button).toHaveFocus();
|
|
135
|
-
expect(button.classList).toContain("DTP__time-slot--selected");
|
|
136
|
-
});
|
|
137
|
-
|
|
138
|
-
it("shows selected className if preselected slot exists", () => {
|
|
139
|
-
const status = {
|
|
140
|
-
focusedSlot: "2022-10-05T09:30:00Z",
|
|
141
|
-
selected: {
|
|
142
|
-
start: "2022-10-05T09:30:00Z",
|
|
143
|
-
end: "2022-10-05T11:00:00Z",
|
|
144
|
-
sequence: slot,
|
|
145
|
-
},
|
|
146
|
-
};
|
|
147
|
-
|
|
148
|
-
const { container } = render(<SequencedSlotButton slot={slot} />, {
|
|
149
|
-
wrapper: e => wrapper({ ...e, status }),
|
|
150
|
-
});
|
|
151
|
-
|
|
152
|
-
const button = container.querySelector("button");
|
|
153
|
-
|
|
154
|
-
expect(button).toHaveFocus();
|
|
155
|
-
expect(button).toHaveClass("DTP__time-slot--selected");
|
|
156
|
-
});
|
|
157
|
-
});
|
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { render, fireEvent } from "@testing-library/react";
|
|
3
|
-
import "@testing-library/jest-dom";
|
|
4
|
-
|
|
5
|
-
import SlotButton from "../../src/js/components/DateTimePicker/SlotButton";
|
|
6
|
-
|
|
7
|
-
import { I18nProvider } from "../../src/js/contexts/i18n-context";
|
|
8
|
-
import { ThemeProvider } from "../../src/js/components/DateTimePicker/contexts/theme-context";
|
|
9
|
-
import { StatusProvider } from "../../src/js/components/DateTimePicker/contexts/status-context";
|
|
10
|
-
import { TzProvider } from "../../src/js/contexts/tz-context";
|
|
11
|
-
|
|
12
|
-
const wrapper = ({ children, status }) => (
|
|
13
|
-
<ThemeProvider options={{ name: "DTP" }}>
|
|
14
|
-
<I18nProvider
|
|
15
|
-
options={{
|
|
16
|
-
locale: "en",
|
|
17
|
-
slug: "date_time_picker",
|
|
18
|
-
tzid: "Europe/London",
|
|
19
|
-
}}
|
|
20
|
-
>
|
|
21
|
-
<TzProvider
|
|
22
|
-
options={{
|
|
23
|
-
selectedTzid: {
|
|
24
|
-
tzid: "Europe/London",
|
|
25
|
-
offset: "+01:00",
|
|
26
|
-
offsetMins: 60,
|
|
27
|
-
name: "London",
|
|
28
|
-
abbr: "BST",
|
|
29
|
-
},
|
|
30
|
-
list: [],
|
|
31
|
-
}}
|
|
32
|
-
>
|
|
33
|
-
<StatusProvider
|
|
34
|
-
options={{
|
|
35
|
-
selected: false,
|
|
36
|
-
...status,
|
|
37
|
-
}}
|
|
38
|
-
>
|
|
39
|
-
{children}
|
|
40
|
-
</StatusProvider>
|
|
41
|
-
</TzProvider>
|
|
42
|
-
</I18nProvider>
|
|
43
|
-
</ThemeProvider>
|
|
44
|
-
);
|
|
45
|
-
|
|
46
|
-
describe("SlotButton", () => {
|
|
47
|
-
const slot = {
|
|
48
|
-
start: "2020-10-05T09:30:00Z",
|
|
49
|
-
end: "2020-10-05T10:00:00Z",
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
it("displays slot button with time in BST", () => {
|
|
53
|
-
const { container } = render(<SlotButton slot={slot} />, { wrapper });
|
|
54
|
-
|
|
55
|
-
const button = container.querySelector(".DTP__time-slot");
|
|
56
|
-
|
|
57
|
-
expect(button).toBeInTheDocument();
|
|
58
|
-
expect(button.innerHTML).toEqual(expect.stringContaining("10:30 AM - 11:00 AM (BST)"));
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
it("displays slot button with time in GMT", () => {
|
|
62
|
-
const slot = {
|
|
63
|
-
start: "2020-11-05T09:30:00Z",
|
|
64
|
-
end: "2020-11-05T10:00:00Z",
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
const { container } = render(<SlotButton slot={slot} />, { wrapper });
|
|
68
|
-
|
|
69
|
-
const button = container.querySelector(".DTP__time-slot");
|
|
70
|
-
|
|
71
|
-
expect(button).toBeInTheDocument();
|
|
72
|
-
expect(button.innerHTML).toEqual(expect.stringContaining("9:30 AM - 10:00 AM (GMT)"));
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
it("focuses if slot start time matches status.focusedSlot", () => {
|
|
76
|
-
const status = {
|
|
77
|
-
focusedSlot: slot.start,
|
|
78
|
-
selected: false,
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
const { container } = render(<SlotButton slot={slot} />, {
|
|
82
|
-
wrapper: e => wrapper({ ...e, status }),
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
const button = container.querySelector("button");
|
|
86
|
-
|
|
87
|
-
expect(button).toHaveFocus();
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
it("sets the slot to selected when button is clicked", () => {
|
|
91
|
-
const { container } = render(<SlotButton slot={slot} />, { wrapper });
|
|
92
|
-
|
|
93
|
-
const button = container.querySelector("button");
|
|
94
|
-
|
|
95
|
-
expect(button).not.toHaveClass("DTP_time-slot--selected");
|
|
96
|
-
|
|
97
|
-
fireEvent.click(button);
|
|
98
|
-
|
|
99
|
-
expect(button).toHaveFocus();
|
|
100
|
-
expect(button.classList).toContain("DTP__time-slot--selected");
|
|
101
|
-
});
|
|
102
|
-
|
|
103
|
-
it("shows selected className if preselected slot exists", () => {
|
|
104
|
-
const status = {
|
|
105
|
-
focusedSlot: slot.start,
|
|
106
|
-
selected: slot,
|
|
107
|
-
};
|
|
108
|
-
|
|
109
|
-
const { container } = render(<SlotButton slot={slot} />, {
|
|
110
|
-
wrapper: e => wrapper({ ...e, status }),
|
|
111
|
-
});
|
|
112
|
-
|
|
113
|
-
const button = container.querySelector("button");
|
|
114
|
-
|
|
115
|
-
expect(button).toHaveFocus();
|
|
116
|
-
expect(button.classList).toContain("DTP__time-slot--selected");
|
|
117
|
-
});
|
|
118
|
-
});
|