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,166 +0,0 @@
|
|
|
1
|
-
import moment from "moment-timezone";
|
|
2
|
-
import { parseSlotPickerOptions } from "../src/js/helpers/init.SlotPicker";
|
|
3
|
-
|
|
4
|
-
// The parsers rely on console warning and errors to
|
|
5
|
-
// comunicate problems to the users
|
|
6
|
-
console.error = jest.fn();
|
|
7
|
-
console.warn = jest.fn();
|
|
8
|
-
|
|
9
|
-
beforeEach(() => {
|
|
10
|
-
console.error.mockClear();
|
|
11
|
-
console.warn.mockClear();
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
const generic_query_periods = [
|
|
15
|
-
{
|
|
16
|
-
start: moment().toISOString(),
|
|
17
|
-
end: moment().add(1, "days").toISOString(),
|
|
18
|
-
},
|
|
19
|
-
];
|
|
20
|
-
|
|
21
|
-
describe("Parsing SlotPicker options", () => {
|
|
22
|
-
it("works when all options are declared", () => {
|
|
23
|
-
const input = {
|
|
24
|
-
target_id: "TARGET",
|
|
25
|
-
element_token: "TOKEN",
|
|
26
|
-
availability_query: {
|
|
27
|
-
query_periods: generic_query_periods,
|
|
28
|
-
required_duration: "TEST",
|
|
29
|
-
},
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
const result = parseSlotPickerOptions(input);
|
|
33
|
-
expect(result.config).toEqual({
|
|
34
|
-
mode: "confirm",
|
|
35
|
-
logs: "warn",
|
|
36
|
-
});
|
|
37
|
-
expect(result.domains).toEqual({
|
|
38
|
-
apiDomain: "https://api.cronofy.com",
|
|
39
|
-
appDomain: "https://app.cronofy.com",
|
|
40
|
-
});
|
|
41
|
-
expect(result.query).toEqual({
|
|
42
|
-
query_periods: generic_query_periods,
|
|
43
|
-
required_duration: "TEST",
|
|
44
|
-
});
|
|
45
|
-
expect(result.target).toEqual("TARGET");
|
|
46
|
-
expect(result.token).toEqual("TOKEN");
|
|
47
|
-
expect(console.error).toHaveBeenCalledTimes(0);
|
|
48
|
-
expect(console.warn).toHaveBeenCalledTimes(0);
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
it("fails if there is no token declared", () => {
|
|
52
|
-
expect(parseSlotPickerOptions()).toEqual(false);
|
|
53
|
-
expect(console.error).toHaveBeenCalledTimes(1);
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
it("continues if there is no token declared, but we're in demo mode", () => {
|
|
57
|
-
const expectedOutput = {
|
|
58
|
-
config: {
|
|
59
|
-
mode: "confirm",
|
|
60
|
-
logs: "warn",
|
|
61
|
-
},
|
|
62
|
-
demo: true,
|
|
63
|
-
domains: {
|
|
64
|
-
apiDomain: "https://api.cronofy.com",
|
|
65
|
-
appDomain: "https://app.cronofy.com",
|
|
66
|
-
},
|
|
67
|
-
query: {
|
|
68
|
-
query_periods: generic_query_periods,
|
|
69
|
-
required_duration: "TEST",
|
|
70
|
-
},
|
|
71
|
-
target: "cronofy-element-slot-picker",
|
|
72
|
-
token: false,
|
|
73
|
-
};
|
|
74
|
-
const result = parseSlotPickerOptions({
|
|
75
|
-
demo: true,
|
|
76
|
-
availability_query: {
|
|
77
|
-
query_periods: generic_query_periods,
|
|
78
|
-
required_duration: "TEST",
|
|
79
|
-
},
|
|
80
|
-
});
|
|
81
|
-
expect(result.config).toEqual(expectedOutput.config);
|
|
82
|
-
expect(result.domains).toEqual(expectedOutput.domains);
|
|
83
|
-
expect(result.target).toEqual(expectedOutput.target);
|
|
84
|
-
expect(console.warn).toHaveBeenCalledTimes(2);
|
|
85
|
-
expect(console.error).toHaveBeenCalledTimes(0);
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
it("applies the default target if there is no target option", () => {
|
|
89
|
-
expect(
|
|
90
|
-
parseSlotPickerOptions({
|
|
91
|
-
availability_query: {
|
|
92
|
-
query_periods: generic_query_periods,
|
|
93
|
-
required_duration: "TEST",
|
|
94
|
-
},
|
|
95
|
-
element_token: "TOKEN",
|
|
96
|
-
}).target
|
|
97
|
-
).toEqual("cronofy-element-slot-picker");
|
|
98
|
-
expect(console.warn).toHaveBeenCalledTimes(1);
|
|
99
|
-
expect(console.error).toHaveBeenCalledTimes(0);
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
it("applies the default domains if there is no data_center option", () => {
|
|
103
|
-
expect(
|
|
104
|
-
parseSlotPickerOptions({
|
|
105
|
-
availability_query: {
|
|
106
|
-
query_periods: generic_query_periods,
|
|
107
|
-
required_duration: "TEST",
|
|
108
|
-
},
|
|
109
|
-
element_token: "TOKEN",
|
|
110
|
-
target_id: "TARGET",
|
|
111
|
-
}).domains
|
|
112
|
-
).toEqual({
|
|
113
|
-
apiDomain: "https://api.cronofy.com",
|
|
114
|
-
appDomain: "https://app.cronofy.com",
|
|
115
|
-
});
|
|
116
|
-
expect(console.warn).toHaveBeenCalledTimes(0);
|
|
117
|
-
expect(console.error).toHaveBeenCalledTimes(0);
|
|
118
|
-
});
|
|
119
|
-
|
|
120
|
-
it("creates correct domains if there is a data_center option", () => {
|
|
121
|
-
expect(
|
|
122
|
-
parseSlotPickerOptions({
|
|
123
|
-
availability_query: {
|
|
124
|
-
query_periods: generic_query_periods,
|
|
125
|
-
required_duration: "TEST",
|
|
126
|
-
},
|
|
127
|
-
data_center: "de",
|
|
128
|
-
element_token: "TOKEN",
|
|
129
|
-
target_id: "TARGET",
|
|
130
|
-
}).domains
|
|
131
|
-
).toEqual({
|
|
132
|
-
apiDomain: "https://api-de.cronofy.com",
|
|
133
|
-
appDomain: "https://app-de.cronofy.com",
|
|
134
|
-
});
|
|
135
|
-
expect(console.warn).toHaveBeenCalledTimes(0);
|
|
136
|
-
expect(console.error).toHaveBeenCalledTimes(0);
|
|
137
|
-
});
|
|
138
|
-
|
|
139
|
-
it("passes query through unchanged if bookable_events are present", () => {
|
|
140
|
-
const result = parseSlotPickerOptions({
|
|
141
|
-
availability_query: {
|
|
142
|
-
bookable_events: ["EVENT", "EVENT"],
|
|
143
|
-
test: "UNKNOWN_KEY",
|
|
144
|
-
},
|
|
145
|
-
element_token: "TOKEN",
|
|
146
|
-
target_id: "TARGET",
|
|
147
|
-
});
|
|
148
|
-
expect(result).toHaveProperty("query");
|
|
149
|
-
expect(result.query.bookable_events.length).toBe(2);
|
|
150
|
-
expect(console.warn).toHaveBeenCalledTimes(0);
|
|
151
|
-
expect(console.error).toHaveBeenCalledTimes(0);
|
|
152
|
-
});
|
|
153
|
-
|
|
154
|
-
it("errors if query does not contain query_periods", () => {
|
|
155
|
-
const result = parseSlotPickerOptions({
|
|
156
|
-
availability_query: {
|
|
157
|
-
test: "UNKNOWN_KEY",
|
|
158
|
-
},
|
|
159
|
-
element_token: "TOKEN",
|
|
160
|
-
target_id: "TARGET",
|
|
161
|
-
});
|
|
162
|
-
expect(result).toHaveProperty("query");
|
|
163
|
-
expect(console.warn).toHaveBeenCalledTimes(0);
|
|
164
|
-
expect(console.error).toHaveBeenCalledTimes(1);
|
|
165
|
-
});
|
|
166
|
-
});
|
package/tests/init.test.js
DELETED
|
@@ -1,231 +0,0 @@
|
|
|
1
|
-
import { parseQuery } from "../src/js/helpers/init";
|
|
2
|
-
|
|
3
|
-
// The parsers rely on console warning and errors to
|
|
4
|
-
// comunicate problems to the users
|
|
5
|
-
console.error = jest.fn();
|
|
6
|
-
console.warn = jest.fn();
|
|
7
|
-
|
|
8
|
-
beforeEach(() => {
|
|
9
|
-
console.error.mockClear();
|
|
10
|
-
console.warn.mockClear();
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
describe("Parsing query_periods", () => {
|
|
14
|
-
let log = {
|
|
15
|
-
error: jest.fn(),
|
|
16
|
-
warn: jest.fn(),
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
beforeEach(() => {
|
|
20
|
-
log.error.mockClear();
|
|
21
|
-
log.warn.mockClear();
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
it("returns an error if query_periods is not provided", () => {
|
|
25
|
-
const input = {
|
|
26
|
-
element_token: "TOKEN",
|
|
27
|
-
target_id: "TARGET",
|
|
28
|
-
config: { start_time: "01:00", end_time: "02:00" },
|
|
29
|
-
availability_query: {},
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
const output = parseQuery({
|
|
33
|
-
options: input,
|
|
34
|
-
elementSlug: "docs-slug",
|
|
35
|
-
log,
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
expect(log.error).toHaveBeenCalledWith(
|
|
39
|
-
expect.stringMatching(
|
|
40
|
-
"You need to provide an `availability_query.query_periods` option."
|
|
41
|
-
),
|
|
42
|
-
{ docsSlug: "availability-viewer/#availability_query" }
|
|
43
|
-
);
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
it("returns an error if query_periods is not an array", () => {
|
|
47
|
-
const input = {
|
|
48
|
-
element_token: "TOKEN",
|
|
49
|
-
target_id: "TARGET",
|
|
50
|
-
config: { start_time: "01:00", end_time: "02:00" },
|
|
51
|
-
availability_query: {
|
|
52
|
-
query_periods: { hello: "world" },
|
|
53
|
-
},
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
const output = parseQuery({
|
|
57
|
-
options: input,
|
|
58
|
-
elementSlug: "docs-slug",
|
|
59
|
-
log,
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
expect(log.error).toHaveBeenCalledWith(expect.stringMatching("not an array"), {
|
|
63
|
-
docsSlug: "availability-viewer/#availability_query",
|
|
64
|
-
});
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
it("returns an error if query_periods is an empty array", () => {
|
|
68
|
-
const input = {
|
|
69
|
-
element_token: "TOKEN",
|
|
70
|
-
target_id: "TARGET",
|
|
71
|
-
config: { start_time: "01:00", end_time: "02:00" },
|
|
72
|
-
availability_query: {
|
|
73
|
-
query_periods: [],
|
|
74
|
-
},
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
const output = parseQuery({
|
|
78
|
-
options: input,
|
|
79
|
-
elementSlug: "docs-slug",
|
|
80
|
-
log,
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
expect(log.error).toHaveBeenCalledWith(
|
|
84
|
-
expect.stringMatching(
|
|
85
|
-
"The provided `availability_query.query_periods` option is empty."
|
|
86
|
-
),
|
|
87
|
-
{ docsSlug: "availability-viewer/#availability_query" }
|
|
88
|
-
);
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
it("returns an warning if query_periods is an empty array but allowEmpty flag is set", () => {
|
|
92
|
-
const input = {
|
|
93
|
-
element_token: "TOKEN",
|
|
94
|
-
target_id: "TARGET",
|
|
95
|
-
config: { start_time: "01:00", end_time: "02:00" },
|
|
96
|
-
availability_query: {
|
|
97
|
-
query_periods: [],
|
|
98
|
-
required_duration: "TEST",
|
|
99
|
-
},
|
|
100
|
-
};
|
|
101
|
-
|
|
102
|
-
const output = parseQuery({
|
|
103
|
-
options: input,
|
|
104
|
-
elementSlug: "docs-slug",
|
|
105
|
-
log,
|
|
106
|
-
allowEmpty: true,
|
|
107
|
-
});
|
|
108
|
-
|
|
109
|
-
expect(log.error.mock.calls.length).toBe(0);
|
|
110
|
-
expect(log.warn.mock.calls.length).toBe(1);
|
|
111
|
-
expect(log.warn).toHaveBeenCalledWith(
|
|
112
|
-
expect.stringMatching(
|
|
113
|
-
"The provided `availability_query.query_periods` option is empty."
|
|
114
|
-
),
|
|
115
|
-
{ docsSlug: "availability-viewer/#availability_query" }
|
|
116
|
-
);
|
|
117
|
-
});
|
|
118
|
-
|
|
119
|
-
it("returns an error if query_periods cannot be parsed as dates", () => {
|
|
120
|
-
const input = {
|
|
121
|
-
element_token: "TOKEN",
|
|
122
|
-
target_id: "TARGET",
|
|
123
|
-
config: { start_time: "01:00", end_time: "02:00" },
|
|
124
|
-
availability_query: {
|
|
125
|
-
query_periods: [{ start: "hello", end: "world" }],
|
|
126
|
-
},
|
|
127
|
-
};
|
|
128
|
-
|
|
129
|
-
const output = parseQuery({
|
|
130
|
-
options: input,
|
|
131
|
-
elementSlug: "docs-slug",
|
|
132
|
-
log,
|
|
133
|
-
});
|
|
134
|
-
|
|
135
|
-
expect(log.error).toHaveBeenCalledWith(
|
|
136
|
-
expect.stringMatching(
|
|
137
|
-
"Some of the provided `availability_query.query_periods` option have errors."
|
|
138
|
-
),
|
|
139
|
-
{
|
|
140
|
-
docsSlug: "availability-viewer/#availability_query",
|
|
141
|
-
errorObject: expect.objectContaining({
|
|
142
|
-
"query_period[0]": [
|
|
143
|
-
"start must be a valid date string",
|
|
144
|
-
"end must be a valid date string",
|
|
145
|
-
],
|
|
146
|
-
}),
|
|
147
|
-
}
|
|
148
|
-
);
|
|
149
|
-
});
|
|
150
|
-
|
|
151
|
-
it("returns an error if query_periods are not objects", () => {
|
|
152
|
-
const input = {
|
|
153
|
-
element_token: "TOKEN",
|
|
154
|
-
target_id: "TARGET",
|
|
155
|
-
config: { start_time: "01:00", end_time: "02:00" },
|
|
156
|
-
availability_query: {
|
|
157
|
-
query_periods: [null, 5, "nope", {}, { foo: 3 }],
|
|
158
|
-
},
|
|
159
|
-
};
|
|
160
|
-
|
|
161
|
-
const output = parseQuery({
|
|
162
|
-
options: input,
|
|
163
|
-
elementSlug: "docs-slug",
|
|
164
|
-
log,
|
|
165
|
-
});
|
|
166
|
-
|
|
167
|
-
expect(log.error).toHaveBeenCalledWith(
|
|
168
|
-
expect.stringMatching(
|
|
169
|
-
"Some of the provided `availability_query.query_periods` option have errors."
|
|
170
|
-
),
|
|
171
|
-
{
|
|
172
|
-
docsSlug: "availability-viewer/#availability_query",
|
|
173
|
-
errorObject: expect.objectContaining({
|
|
174
|
-
"query_period[0]": [
|
|
175
|
-
"query period must be an object with start and end properties",
|
|
176
|
-
],
|
|
177
|
-
"query_period[1]": [
|
|
178
|
-
"query period must be an object with start and end properties",
|
|
179
|
-
],
|
|
180
|
-
"query_period[2]": [
|
|
181
|
-
"query period must be an object with start and end properties",
|
|
182
|
-
],
|
|
183
|
-
"query_period[3]": [
|
|
184
|
-
"query period must be an object with start and end properties",
|
|
185
|
-
],
|
|
186
|
-
"query_period[3]": [
|
|
187
|
-
"query period must be an object with start and end properties",
|
|
188
|
-
],
|
|
189
|
-
}),
|
|
190
|
-
}
|
|
191
|
-
);
|
|
192
|
-
});
|
|
193
|
-
|
|
194
|
-
it("returns an error if one of the query_periods has the start after the end", () => {
|
|
195
|
-
const input = {
|
|
196
|
-
element_token: "TOKEN",
|
|
197
|
-
target_id: "TARGET",
|
|
198
|
-
config: { start_time: "01:00", end_time: "02:00" },
|
|
199
|
-
availability_query: {
|
|
200
|
-
query_periods: [
|
|
201
|
-
{
|
|
202
|
-
start: "2020-10-21T13:15:00Z",
|
|
203
|
-
end: "2020-10-21T17:15:00Z",
|
|
204
|
-
}, // OK
|
|
205
|
-
{
|
|
206
|
-
start: "2020-10-23T13:15:00Z",
|
|
207
|
-
end: "2020-10-22T13:15:00Z",
|
|
208
|
-
}, // End == Start
|
|
209
|
-
],
|
|
210
|
-
},
|
|
211
|
-
};
|
|
212
|
-
|
|
213
|
-
const output = parseQuery({
|
|
214
|
-
options: input,
|
|
215
|
-
elementSlug: "docs-slug",
|
|
216
|
-
log,
|
|
217
|
-
});
|
|
218
|
-
|
|
219
|
-
expect(log.error).toHaveBeenCalledWith(
|
|
220
|
-
expect.stringMatching(
|
|
221
|
-
"Some of the provided `availability_query.query_periods` option have errors."
|
|
222
|
-
),
|
|
223
|
-
{
|
|
224
|
-
docsSlug: "availability-viewer/#availability_query",
|
|
225
|
-
errorObject: expect.objectContaining({
|
|
226
|
-
"query_period[1]": ["end must be after start"],
|
|
227
|
-
}),
|
|
228
|
-
}
|
|
229
|
-
);
|
|
230
|
-
});
|
|
231
|
-
});
|
package/tests/logging.test.js
DELETED
|
@@ -1,235 +0,0 @@
|
|
|
1
|
-
import { buildLogNotification, logConstructor } from "../src/js/helpers/logging";
|
|
2
|
-
|
|
3
|
-
// The parsers rely on console warning and errors to
|
|
4
|
-
// comunicate problems to the users
|
|
5
|
-
console.error = jest.fn();
|
|
6
|
-
console.info = jest.fn();
|
|
7
|
-
console.log = jest.fn();
|
|
8
|
-
console.warn = jest.fn();
|
|
9
|
-
|
|
10
|
-
const messageTemplate = (type, message, slug) =>
|
|
11
|
-
`UI Elements: ${type}\n${message}\nhttps://docs.cronofy.com/developers/ui-elements/${slug}\n`;
|
|
12
|
-
|
|
13
|
-
beforeEach(() => {
|
|
14
|
-
console.error.mockClear();
|
|
15
|
-
console.info.mockClear();
|
|
16
|
-
console.log.mockClear();
|
|
17
|
-
console.warn.mockClear();
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
describe("Logging", () => {
|
|
21
|
-
it("works in `info` mode", () => {
|
|
22
|
-
const log = logConstructor("info");
|
|
23
|
-
log.error("message");
|
|
24
|
-
log.warn("message");
|
|
25
|
-
log.info("message");
|
|
26
|
-
log.log("message");
|
|
27
|
-
expect(console.error).toHaveBeenCalledTimes(1);
|
|
28
|
-
expect(console.warn).toHaveBeenCalledTimes(1);
|
|
29
|
-
expect(console.info).toHaveBeenCalledTimes(1);
|
|
30
|
-
expect(console.log).toHaveBeenCalledTimes(1);
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
it("works in `warn` mode", () => {
|
|
34
|
-
const log = logConstructor("warn");
|
|
35
|
-
log.error("message");
|
|
36
|
-
log.warn("message");
|
|
37
|
-
log.info("message");
|
|
38
|
-
log.log("message");
|
|
39
|
-
expect(console.error).toHaveBeenCalledTimes(1);
|
|
40
|
-
expect(console.warn).toHaveBeenCalledTimes(1);
|
|
41
|
-
expect(console.info).toHaveBeenCalledTimes(0);
|
|
42
|
-
expect(console.log).toHaveBeenCalledTimes(0);
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
it("works in `error` mode", () => {
|
|
46
|
-
const log = logConstructor("error");
|
|
47
|
-
log.error("message");
|
|
48
|
-
log.warn("message");
|
|
49
|
-
log.info("message");
|
|
50
|
-
log.log("message");
|
|
51
|
-
expect(console.error).toHaveBeenCalledTimes(1);
|
|
52
|
-
expect(console.warn).toHaveBeenCalledTimes(0);
|
|
53
|
-
expect(console.info).toHaveBeenCalledTimes(0);
|
|
54
|
-
expect(console.log).toHaveBeenCalledTimes(0);
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
it("works in `none` mode", () => {
|
|
58
|
-
const log = logConstructor("none");
|
|
59
|
-
log.error("message");
|
|
60
|
-
log.warn("message");
|
|
61
|
-
log.info("message");
|
|
62
|
-
log.log("message");
|
|
63
|
-
expect(console.error).toHaveBeenCalledTimes(0);
|
|
64
|
-
expect(console.warn).toHaveBeenCalledTimes(0);
|
|
65
|
-
expect(console.info).toHaveBeenCalledTimes(0);
|
|
66
|
-
expect(console.log).toHaveBeenCalledTimes(0);
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
it("defaults to `warn` mode", () => {
|
|
70
|
-
const log = logConstructor();
|
|
71
|
-
log.error("message");
|
|
72
|
-
log.warn("message");
|
|
73
|
-
log.info("message");
|
|
74
|
-
log.log("message");
|
|
75
|
-
expect(console.error).toHaveBeenCalledTimes(1);
|
|
76
|
-
expect(console.warn).toHaveBeenCalledTimes(1);
|
|
77
|
-
expect(console.info).toHaveBeenCalledTimes(0);
|
|
78
|
-
expect(console.log).toHaveBeenCalledTimes(0);
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
it("correctly creates a log", () => {
|
|
82
|
-
const log = logConstructor("info");
|
|
83
|
-
log.info("TEST MESSAGE");
|
|
84
|
-
expect(console.error).toHaveBeenCalledTimes(0);
|
|
85
|
-
expect(console.warn).toHaveBeenCalledTimes(0);
|
|
86
|
-
expect(console.info).toHaveBeenCalledTimes(1);
|
|
87
|
-
expect(console.log).toHaveBeenCalledTimes(0);
|
|
88
|
-
expect(console.info.mock.calls[0][0]).toEqual(
|
|
89
|
-
messageTemplate("General", "TEST MESSAGE", "")
|
|
90
|
-
);
|
|
91
|
-
expect(console.info.mock.calls[0][1]).toBe(undefined);
|
|
92
|
-
});
|
|
93
|
-
|
|
94
|
-
it("ignores unwanted properties", () => {
|
|
95
|
-
const log = logConstructor("info");
|
|
96
|
-
log.info("TEST MESSAGE", { unwanted: "THING" });
|
|
97
|
-
expect(console.error).toHaveBeenCalledTimes(0);
|
|
98
|
-
expect(console.warn).toHaveBeenCalledTimes(0);
|
|
99
|
-
expect(console.info).toHaveBeenCalledTimes(1);
|
|
100
|
-
expect(console.log).toHaveBeenCalledTimes(0);
|
|
101
|
-
expect(console.info.mock.calls[0][0]).toEqual(
|
|
102
|
-
messageTemplate("General", "TEST MESSAGE", "")
|
|
103
|
-
);
|
|
104
|
-
expect(console.info.mock.calls[0][1]).toBe(undefined);
|
|
105
|
-
});
|
|
106
|
-
|
|
107
|
-
it("adds wanted properties to the log output", () => {
|
|
108
|
-
const log = logConstructor("info");
|
|
109
|
-
log.info("TEST MESSAGE", { errorObject: "THING" });
|
|
110
|
-
expect(console.error).toHaveBeenCalledTimes(0);
|
|
111
|
-
expect(console.warn).toHaveBeenCalledTimes(0);
|
|
112
|
-
expect(console.info).toHaveBeenCalledTimes(1);
|
|
113
|
-
expect(console.log).toHaveBeenCalledTimes(0);
|
|
114
|
-
expect(console.info.mock.calls[0][0]).toEqual(
|
|
115
|
-
messageTemplate("General", "TEST MESSAGE", "")
|
|
116
|
-
);
|
|
117
|
-
expect(console.info.mock.calls[0][1]).toBe("THING");
|
|
118
|
-
});
|
|
119
|
-
|
|
120
|
-
it("adds slug to end of docs URL when needed", () => {
|
|
121
|
-
const log = logConstructor("info");
|
|
122
|
-
log.info("TEST MESSAGE", { docsSlug: "TEST" });
|
|
123
|
-
expect(console.error).toHaveBeenCalledTimes(0);
|
|
124
|
-
expect(console.warn).toHaveBeenCalledTimes(0);
|
|
125
|
-
expect(console.info).toHaveBeenCalledTimes(1);
|
|
126
|
-
expect(console.log).toHaveBeenCalledTimes(0);
|
|
127
|
-
expect(console.info.mock.calls[0][0]).toEqual(
|
|
128
|
-
messageTemplate("General", "TEST MESSAGE", "TEST")
|
|
129
|
-
);
|
|
130
|
-
expect(console.info.mock.calls[0][1]).toBe(undefined);
|
|
131
|
-
});
|
|
132
|
-
|
|
133
|
-
it("adds docs URL slug, and extra props (and ignores unwanted props)", () => {
|
|
134
|
-
const log = logConstructor("info");
|
|
135
|
-
log.info("TEST MESSAGE", {
|
|
136
|
-
docsSlug: "TEST",
|
|
137
|
-
errorObject: "THING",
|
|
138
|
-
unwanted: "THING",
|
|
139
|
-
});
|
|
140
|
-
expect(console.error).toHaveBeenCalledTimes(0);
|
|
141
|
-
expect(console.warn).toHaveBeenCalledTimes(0);
|
|
142
|
-
expect(console.info).toHaveBeenCalledTimes(1);
|
|
143
|
-
expect(console.log).toHaveBeenCalledTimes(0);
|
|
144
|
-
expect(console.info.mock.calls[0][0]).toEqual(
|
|
145
|
-
messageTemplate("General", "TEST MESSAGE", "TEST")
|
|
146
|
-
);
|
|
147
|
-
expect(console.info.mock.calls[0][1]).toBe("THING");
|
|
148
|
-
expect(console.info.mock.calls[0][2]).toBe(undefined);
|
|
149
|
-
});
|
|
150
|
-
|
|
151
|
-
it("calls provided callback", () => {
|
|
152
|
-
const callback = jest.fn();
|
|
153
|
-
const expectedNotification = {
|
|
154
|
-
notification: {
|
|
155
|
-
element: "ELEMENT_NAME",
|
|
156
|
-
errors: {},
|
|
157
|
-
message: "TEST MESSAGE",
|
|
158
|
-
type: "error",
|
|
159
|
-
url: "https://docs.cronofy.com/developers/ui-elements/",
|
|
160
|
-
},
|
|
161
|
-
};
|
|
162
|
-
|
|
163
|
-
logConstructor("error", "ELEMENT_NAME", callback);
|
|
164
|
-
const log = logConstructor("error", "ELEMENT_NAME", callback);
|
|
165
|
-
|
|
166
|
-
log.error("TEST MESSAGE");
|
|
167
|
-
|
|
168
|
-
expect(console.error).toHaveBeenCalledTimes(1);
|
|
169
|
-
expect(callback).toHaveBeenCalledTimes(1);
|
|
170
|
-
expect(callback).toHaveBeenCalledWith(expectedNotification);
|
|
171
|
-
});
|
|
172
|
-
|
|
173
|
-
it("calls provided callback with extra options", () => {
|
|
174
|
-
const callback = jest.fn();
|
|
175
|
-
const expectedNotification = {
|
|
176
|
-
notification: {
|
|
177
|
-
element: "ELEMENT_NAME",
|
|
178
|
-
errors: "ERRORS_OBJECT",
|
|
179
|
-
message: "TEST MESSAGE",
|
|
180
|
-
type: "error",
|
|
181
|
-
url: "https://docs.cronofy.com/developers/ui-elements/TEST",
|
|
182
|
-
},
|
|
183
|
-
};
|
|
184
|
-
|
|
185
|
-
logConstructor("error", "ELEMENT_NAME", callback);
|
|
186
|
-
const log = logConstructor("error", "ELEMENT_NAME", callback);
|
|
187
|
-
|
|
188
|
-
log.error("TEST MESSAGE", {
|
|
189
|
-
docsSlug: "TEST",
|
|
190
|
-
errorObject: "ERRORS_OBJECT",
|
|
191
|
-
unwanted: "THING",
|
|
192
|
-
});
|
|
193
|
-
|
|
194
|
-
expect(console.error).toHaveBeenCalledTimes(1);
|
|
195
|
-
expect(callback).toHaveBeenCalledTimes(1);
|
|
196
|
-
expect(callback).toHaveBeenCalledWith(expectedNotification);
|
|
197
|
-
});
|
|
198
|
-
|
|
199
|
-
it("correctly builds log notification", () => {
|
|
200
|
-
const notification = buildLogNotification("TYPE", "ELEMENT", "MESSAGE");
|
|
201
|
-
expect(typeof notification.notification).toBe("object");
|
|
202
|
-
expect(notification.notification.message).toEqual("MESSAGE");
|
|
203
|
-
expect(notification.notification.type).toEqual("TYPE");
|
|
204
|
-
expect(notification.notification.element).toEqual("ELEMENT");
|
|
205
|
-
expect(notification.notification.errors).toEqual({});
|
|
206
|
-
});
|
|
207
|
-
|
|
208
|
-
it("correctly builds log notification with a URL slug", () => {
|
|
209
|
-
const notificationWithUrlSlug = buildLogNotification("TYPE", "ELEMENT", "MESSAGE", "SLUG");
|
|
210
|
-
expect(typeof notificationWithUrlSlug.notification).toBe("object");
|
|
211
|
-
expect(notificationWithUrlSlug.notification.message).toEqual("MESSAGE");
|
|
212
|
-
expect(notificationWithUrlSlug.notification.type).toEqual("TYPE");
|
|
213
|
-
expect(notificationWithUrlSlug.notification.element).toEqual("ELEMENT");
|
|
214
|
-
expect(notificationWithUrlSlug.notification.url).toEqual(
|
|
215
|
-
"https://docs.cronofy.com/developers/ui-elements/SLUG"
|
|
216
|
-
);
|
|
217
|
-
});
|
|
218
|
-
|
|
219
|
-
it("correctly builds log notification with an errors object", () => {
|
|
220
|
-
const notificationWithUrlSlug = buildLogNotification("TYPE", "ELEMENT", "MESSAGE", "SLUG", {
|
|
221
|
-
error_1: "ERROR_1",
|
|
222
|
-
error_2: "ERROR_2",
|
|
223
|
-
});
|
|
224
|
-
expect(typeof notificationWithUrlSlug.notification).toBe("object");
|
|
225
|
-
expect(notificationWithUrlSlug.notification.message).toEqual("MESSAGE");
|
|
226
|
-
expect(notificationWithUrlSlug.notification.type).toEqual("TYPE");
|
|
227
|
-
expect(notificationWithUrlSlug.notification.element).toEqual("ELEMENT");
|
|
228
|
-
expect(notificationWithUrlSlug.notification.url).toEqual(
|
|
229
|
-
"https://docs.cronofy.com/developers/ui-elements/SLUG"
|
|
230
|
-
);
|
|
231
|
-
expect(typeof notificationWithUrlSlug.notification.errors).toBe("object");
|
|
232
|
-
expect(Object.keys(notificationWithUrlSlug.notification.errors).length).toEqual(2);
|
|
233
|
-
expect(notificationWithUrlSlug.notification.errors.error_1).toEqual("ERROR_1");
|
|
234
|
-
});
|
|
235
|
-
});
|
package/tests/mocks/i18n.js
DELETED
package/tests/mocks/theme.js
DELETED
package/tests/setupJest.js
DELETED