@pingux/astro 2.163.1-alpha.0 → 2.163.1-alpha.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/lib/cjs/components/ComboBoxField/ComboBoxField.js +7 -3
- package/lib/cjs/components/ListBox/ListBox.js +15 -0
- package/lib/cjs/components/ListBox/ListBox.test.js +14 -1
- package/lib/cjs/components/TimeZonePicker/TimeZonePicker.js +117 -140
- package/lib/cjs/components/TimeZonePicker/TimeZonePicker.test.js +29 -2
- package/lib/cjs/components/TimeZonePicker/helper.d.ts +6 -0
- package/lib/cjs/components/TimeZonePicker/helper.js +59 -0
- package/lib/cjs/components/TimeZonePicker/helper.test.js +79 -0
- package/lib/cjs/types/listBox.d.ts +1 -1
- package/lib/components/ComboBoxField/ComboBoxField.js +7 -3
- package/lib/components/ListBox/ListBox.js +15 -0
- package/lib/components/ListBox/ListBox.test.js +14 -1
- package/lib/components/TimeZonePicker/TimeZonePicker.js +122 -146
- package/lib/components/TimeZonePicker/TimeZonePicker.test.js +29 -2
- package/lib/components/TimeZonePicker/helper.js +51 -0
- package/lib/components/TimeZonePicker/helper.test.js +76 -0
- package/lib/tsconfig.lib.tsbuildinfo +1 -1
- package/package.json +20 -22
|
@@ -30,7 +30,7 @@ export interface ListBoxProps extends AriaListBoxOptions<object> {
|
|
|
30
30
|
onLoadPrev?: () => void;
|
|
31
31
|
onScroll?: () => void;
|
|
32
32
|
state: ListBoxStateType | SelectState<object, 'single'> | ComboBoxState<object>;
|
|
33
|
-
renderEmptyState?:
|
|
33
|
+
renderEmptyState?: () => ReactNode;
|
|
34
34
|
variant?: string;
|
|
35
35
|
children?: CollectionChildren<object>;
|
|
36
36
|
isCondensed?: boolean;
|
|
@@ -10,7 +10,7 @@ import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
|
|
|
10
10
|
import _slicedToArray from "@babel/runtime-corejs3/helpers/esm/slicedToArray";
|
|
11
11
|
import _defineProperty from "@babel/runtime-corejs3/helpers/esm/defineProperty";
|
|
12
12
|
import _objectWithoutProperties from "@babel/runtime-corejs3/helpers/esm/objectWithoutProperties";
|
|
13
|
-
var _excluded = ["hasAutoFocus", "hasAddOption", "hasCustomValue", "hasNoEmptySelection", "selectedKey", "onSelectionChange", "defaultItems", "items", "loadingState", "onLoadMore", "inputValue", "isReadOnly", "menuTrigger", "isNotFlippable", "direction", "scrollBoxProps", "controlProps", "defaultFilter", "status", "helperText"],
|
|
13
|
+
var _excluded = ["hasAutoFocus", "hasAddOption", "hasCustomValue", "hasNoEmptySelection", "selectedKey", "onSelectionChange", "defaultItems", "items", "loadingState", "onLoadMore", "inputValue", "isReadOnly", "menuTrigger", "isNotFlippable", "direction", "scrollBoxProps", "controlProps", "defaultFilter", "status", "helperText", "renderEmptyState", "allowsEmptyCollection"],
|
|
14
14
|
_excluded2 = ["shouldFocusOnHover", "shouldSelectOnPressUp", "UNSTABLE_itemBehavior"];
|
|
15
15
|
import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/concat";
|
|
16
16
|
import _Array$from from "@babel/runtime-corejs3/core-js-stable/array/from";
|
|
@@ -56,6 +56,8 @@ var ComboBoxField = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
56
56
|
defaultFilter = props.defaultFilter,
|
|
57
57
|
status = props.status,
|
|
58
58
|
helperText = props.helperText,
|
|
59
|
+
renderEmptyState = props.renderEmptyState,
|
|
60
|
+
allowsEmptyCollection = props.allowsEmptyCollection,
|
|
59
61
|
others = _objectWithoutProperties(props, _excluded);
|
|
60
62
|
var _getAriaAttributeProp = getAriaAttributeProps(others),
|
|
61
63
|
nonAriaProps = _getAriaAttributeProp.nonAriaProps;
|
|
@@ -71,7 +73,8 @@ var ComboBoxField = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
71
73
|
menuTrigger: menuTrigger,
|
|
72
74
|
shouldFlip: !isNotFlippable,
|
|
73
75
|
direction: direction,
|
|
74
|
-
label: 'default'
|
|
76
|
+
label: 'default',
|
|
77
|
+
allowsEmptyCollection: allowsEmptyCollection
|
|
75
78
|
}, nonAriaProps);
|
|
76
79
|
var popoverRef = useRef();
|
|
77
80
|
var buttonRef = useRef();
|
|
@@ -197,7 +200,8 @@ var ComboBoxField = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
197
200
|
isLoading: loadingState === loadingStates.LOADING_MORE,
|
|
198
201
|
onLoadMore: onLoadMore,
|
|
199
202
|
isFocusedOnHover: shouldFocusOnHover,
|
|
200
|
-
isSelectedOnPressUp: shouldSelectOnPressUp
|
|
203
|
+
isSelectedOnPressUp: shouldSelectOnPressUp,
|
|
204
|
+
renderEmptyState: renderEmptyState
|
|
201
205
|
}, otherListBoxProps))), ___EmotionJSX(DismissButton, {
|
|
202
206
|
onDismiss: state.close
|
|
203
207
|
})));
|
|
@@ -153,6 +153,18 @@ var ListBox = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
153
153
|
};
|
|
154
154
|
}, [isLoading, onLoadPrev, items]);
|
|
155
155
|
useLoadPrev(memoedLoadMoreProps, listBoxRef);
|
|
156
|
+
var EmptyState = function EmptyState() {
|
|
157
|
+
var emptyState = renderEmptyState ? renderEmptyState() : null;
|
|
158
|
+
if (emptyState == null) {
|
|
159
|
+
return null;
|
|
160
|
+
}
|
|
161
|
+
return ___EmotionJSX(Box, {
|
|
162
|
+
as: "li",
|
|
163
|
+
isRow: true,
|
|
164
|
+
role: "option",
|
|
165
|
+
variant: "listBox.option"
|
|
166
|
+
}, emptyState);
|
|
167
|
+
};
|
|
156
168
|
return ___EmotionJSX(ListBoxContext.Provider, {
|
|
157
169
|
value: state
|
|
158
170
|
}, ___EmotionJSX(Box, {
|
|
@@ -194,6 +206,9 @@ var ListBox = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
194
206
|
"aria-label": "Loading more..."
|
|
195
207
|
});
|
|
196
208
|
}
|
|
209
|
+
if (type === collectionTypes.PLACEHOLDER) {
|
|
210
|
+
return ___EmotionJSX(EmptyState, null);
|
|
211
|
+
}
|
|
197
212
|
return null;
|
|
198
213
|
})));
|
|
199
214
|
});
|
|
@@ -157,4 +157,17 @@ test('should have is-focused class when hover', /*#__PURE__*/_asyncToGenerator(/
|
|
|
157
157
|
return _context.stop();
|
|
158
158
|
}
|
|
159
159
|
}, _callee);
|
|
160
|
-
})));
|
|
160
|
+
})));
|
|
161
|
+
test('should render empty state when no items', function () {
|
|
162
|
+
getComponent({
|
|
163
|
+
items: [],
|
|
164
|
+
renderEmptyState: function renderEmptyState() {
|
|
165
|
+
return ___EmotionJSX("div", {
|
|
166
|
+
"data-testid": "empty-state"
|
|
167
|
+
}, "No items");
|
|
168
|
+
}
|
|
169
|
+
});
|
|
170
|
+
var emptyState = screen.getByTestId('empty-state');
|
|
171
|
+
expect(emptyState).toBeInTheDocument();
|
|
172
|
+
expect(emptyState).toHaveTextContent('No items');
|
|
173
|
+
});
|
|
@@ -1,62 +1,45 @@
|
|
|
1
|
-
import _Object$keys from "@babel/runtime-corejs3/core-js-stable/object/keys";
|
|
2
|
-
import _Object$getOwnPropertySymbols from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols";
|
|
3
|
-
import _Object$getOwnPropertyDescriptor from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor";
|
|
4
|
-
import _forEachInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/for-each";
|
|
5
|
-
import _Object$getOwnPropertyDescriptors from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors";
|
|
6
|
-
import _Object$defineProperties from "@babel/runtime-corejs3/core-js-stable/object/define-properties";
|
|
7
|
-
import _Object$defineProperty from "@babel/runtime-corejs3/core-js-stable/object/define-property";
|
|
8
1
|
import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
|
|
2
|
+
import _defineProperty from "@babel/runtime-corejs3/helpers/esm/defineProperty";
|
|
9
3
|
import _slicedToArray from "@babel/runtime-corejs3/helpers/esm/slicedToArray";
|
|
10
4
|
import _objectWithoutProperties from "@babel/runtime-corejs3/helpers/esm/objectWithoutProperties";
|
|
11
|
-
import _defineProperty from "@babel/runtime-corejs3/helpers/esm/defineProperty";
|
|
12
5
|
var _excluded = ["additionalTimeZones", "emptySearchText", "locales", "localeOptions"];
|
|
13
6
|
function ownKeys(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = _filterInstanceProperty(o).call(o, function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
14
7
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context8, _context9; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context8 = ownKeys(Object(t), !0)).call(_context8, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context9 = ownKeys(Object(t))).call(_context9, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
15
8
|
import _includesInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/includes";
|
|
16
9
|
import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/concat";
|
|
10
|
+
import _sortInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/sort";
|
|
17
11
|
import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/map";
|
|
18
12
|
import _Object$entries from "@babel/runtime-corejs3/core-js-stable/object/entries";
|
|
13
|
+
import _findInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/find";
|
|
19
14
|
import _filterInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/filter";
|
|
20
|
-
import
|
|
21
|
-
import
|
|
22
|
-
import
|
|
23
|
-
import
|
|
15
|
+
import _Map from "@babel/runtime-corejs3/core-js-stable/map";
|
|
16
|
+
import _forEachInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/for-each";
|
|
17
|
+
import _Object$keys from "@babel/runtime-corejs3/core-js-stable/object/keys";
|
|
18
|
+
import _Object$getOwnPropertySymbols from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols";
|
|
19
|
+
import _Object$getOwnPropertyDescriptor from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor";
|
|
20
|
+
import _Object$getOwnPropertyDescriptors from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors";
|
|
21
|
+
import _Object$defineProperties from "@babel/runtime-corejs3/core-js-stable/object/define-properties";
|
|
22
|
+
import _Object$defineProperty from "@babel/runtime-corejs3/core-js-stable/object/define-property";
|
|
23
|
+
import React, { forwardRef, useImperativeHandle, useMemo, useRef, useState } from 'react';
|
|
24
24
|
import PropTypes from 'prop-types';
|
|
25
25
|
import { Box, ComboBoxField, Item, Text } from '../../index';
|
|
26
26
|
import { getPendoID } from '../../utils/devUtils/constants/pendoID';
|
|
27
|
+
import { getGmtAndOffset } from './helper';
|
|
27
28
|
import defaultTimezones, { usCities } from './timezones';
|
|
28
29
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
|
29
30
|
var createSearchTags = function createSearchTags(_ref) {
|
|
30
|
-
var _context, _context2, _context3
|
|
31
|
+
var _context, _context2, _context3;
|
|
31
32
|
var gmt = _ref.gmt,
|
|
32
|
-
gmtLabel = _ref.gmtLabel,
|
|
33
33
|
timeZone = _ref.timeZone;
|
|
34
|
+
var normalizedTz = timeZone.replace(/_/g, ' ');
|
|
34
35
|
var additionalTags = '';
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
if (_includesInstanceProperty(timeZone).call(timeZone, 'America')) {
|
|
37
|
+
var city = timeZone.split('/')[1];
|
|
38
|
+
if (_includesInstanceProperty(usCities).call(usCities, city)) {
|
|
39
|
+
additionalTags = "US ".concat(city);
|
|
40
|
+
}
|
|
38
41
|
}
|
|
39
|
-
return _concatInstanceProperty(_context = _concatInstanceProperty(_context2 = _concatInstanceProperty(_context3 =
|
|
40
|
-
};
|
|
41
|
-
var getLocaleTime = function getLocaleTime(_ref2) {
|
|
42
|
-
var timeZone = _ref2.timeZone,
|
|
43
|
-
locales = _ref2.locales,
|
|
44
|
-
localeOptions = _ref2.localeOptions;
|
|
45
|
-
var date = new Date();
|
|
46
|
-
return date.toLocaleTimeString(locales, _objectSpread({
|
|
47
|
-
timeZone: timeZone
|
|
48
|
-
}, localeOptions));
|
|
49
|
-
};
|
|
50
|
-
var getTimezoneOffset = function getTimezoneOffset(timeZone) {
|
|
51
|
-
var now = new Date();
|
|
52
|
-
var tzString = now.toLocaleString('en-US', {
|
|
53
|
-
timeZone: timeZone
|
|
54
|
-
});
|
|
55
|
-
var localString = now.toLocaleString('en-US');
|
|
56
|
-
var diff = (Date.parse(localString) - Date.parse(tzString)) / 3600000;
|
|
57
|
-
var offset = -(diff + now.getTimezoneOffset() / 60);
|
|
58
|
-
var formattedString = "".concat(offset, ":00");
|
|
59
|
-
return offset > 0 ? "+".concat(formattedString) : formattedString;
|
|
42
|
+
return _concatInstanceProperty(_context = _concatInstanceProperty(_context2 = _concatInstanceProperty(_context3 = "".concat(gmt, " ")).call(_context3, timeZone, " ")).call(_context2, normalizedTz, " ")).call(_context, additionalTags).toUpperCase();
|
|
60
43
|
};
|
|
61
44
|
var TimeZonePicker = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
62
45
|
var additionalTimeZones = props.additionalTimeZones,
|
|
@@ -68,127 +51,120 @@ var TimeZonePicker = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
68
51
|
_useState2 = _slicedToArray(_useState, 2),
|
|
69
52
|
search = _useState2[0],
|
|
70
53
|
setSearch = _useState2[1];
|
|
71
|
-
var _useState3 = useState(
|
|
54
|
+
var _useState3 = useState(''),
|
|
72
55
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
var _useState5 = useState([]),
|
|
76
|
-
_useState6 = _slicedToArray(_useState5, 2),
|
|
77
|
-
timeZones = _useState6[0],
|
|
78
|
-
setTimeZones = _useState6[1];
|
|
79
|
-
var extendedTimeZonesList = additionalTimeZones ? _objectSpread(_objectSpread({}, defaultTimezones), additionalTimeZones) : defaultTimezones;
|
|
56
|
+
selectedKey = _useState4[0],
|
|
57
|
+
setSelectedKey = _useState4[1];
|
|
80
58
|
var timeZonePickerRef = useRef();
|
|
81
59
|
/* istanbul ignore next */
|
|
82
60
|
useImperativeHandle(ref, function () {
|
|
83
61
|
return timeZonePickerRef.current;
|
|
84
62
|
});
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
searchTags: searchTags
|
|
109
|
-
};
|
|
110
|
-
});
|
|
63
|
+
var allTimeZones = useMemo(function () {
|
|
64
|
+
var _context4, _context5;
|
|
65
|
+
var sourceList = additionalTimeZones ? _objectSpread(_objectSpread({}, defaultTimezones), additionalTimeZones) : defaultTimezones;
|
|
66
|
+
return _sortInstanceProperty(_context4 = _mapInstanceProperty(_context5 = _Object$entries(sourceList)).call(_context5, function (_ref2) {
|
|
67
|
+
var _context6;
|
|
68
|
+
var _ref3 = _slicedToArray(_ref2, 2),
|
|
69
|
+
label = _ref3[0],
|
|
70
|
+
tzValue = _ref3[1];
|
|
71
|
+
var _getGmtAndOffset = getGmtAndOffset(tzValue),
|
|
72
|
+
gmt = _getGmtAndOffset.gmt,
|
|
73
|
+
numericOffset = _getGmtAndOffset.numericOffset;
|
|
74
|
+
var displayTz = tzValue.replace(/_/g, ' ');
|
|
75
|
+
return {
|
|
76
|
+
key: _concatInstanceProperty(_context6 = "".concat(displayTz, " ")).call(_context6, gmt),
|
|
77
|
+
id: tzValue,
|
|
78
|
+
label: label,
|
|
79
|
+
timeZone: displayTz,
|
|
80
|
+
gmt: gmt,
|
|
81
|
+
numericOffset: numericOffset,
|
|
82
|
+
searchTags: createSearchTags({
|
|
83
|
+
gmt: gmt,
|
|
84
|
+
timeZone: tzValue
|
|
85
|
+
})
|
|
111
86
|
};
|
|
112
|
-
|
|
113
|
-
|
|
87
|
+
})).call(_context4, function (a, b) {
|
|
88
|
+
return a.numericOffset - b.numericOffset;
|
|
89
|
+
});
|
|
90
|
+
}, [additionalTimeZones]);
|
|
91
|
+
var filteredItems = useMemo(function () {
|
|
92
|
+
var selectedItem = _findInstanceProperty(allTimeZones).call(allTimeZones, function (tz) {
|
|
93
|
+
return tz.key === selectedKey;
|
|
94
|
+
});
|
|
95
|
+
var isExactMatch = selectedItem && selectedItem.key === search;
|
|
96
|
+
if (!search || isExactMatch) {
|
|
97
|
+
return allTimeZones;
|
|
114
98
|
}
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
var searchTags = _ref3.searchTags;
|
|
120
|
-
return _indexOfInstanceProperty(_context6 = searchTags.toUpperCase()).call(_context6, search.toUpperCase()) > -1;
|
|
99
|
+
var upperSearch = search.toUpperCase();
|
|
100
|
+
return _filterInstanceProperty(allTimeZones).call(allTimeZones, function (tz) {
|
|
101
|
+
var _context7;
|
|
102
|
+
return _includesInstanceProperty(_context7 = tz.searchTags).call(_context7, upperSearch);
|
|
121
103
|
});
|
|
122
|
-
}, [search]);
|
|
123
|
-
var
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
};
|
|
131
|
-
var checkIsSelectedItem = function checkIsSelectedItem() {
|
|
132
|
-
return _filterInstanceProperty(timeZones).call(timeZones, function (tz) {
|
|
133
|
-
return tz.timeZone === search;
|
|
134
|
-
}).length > 0;
|
|
135
|
-
};
|
|
136
|
-
var renderTimeZones = function renderTimeZones(timeZonesToRender) {
|
|
137
|
-
var _context7;
|
|
138
|
-
return _mapInstanceProperty(_context7 = _sortInstanceProperty(timeZonesToRender).call(timeZonesToRender, sortByGMT)).call(_context7, function (_ref4) {
|
|
139
|
-
var gmt = _ref4.gmt,
|
|
140
|
-
time = _ref4.time,
|
|
141
|
-
timeZone = _ref4.timeZone;
|
|
142
|
-
return ___EmotionJSX(Item, {
|
|
143
|
-
key: timeZone,
|
|
144
|
-
"data-id": timeZone,
|
|
145
|
-
textValue: timeZone
|
|
146
|
-
}, ___EmotionJSX(Box, {
|
|
147
|
-
flexDirection: "row",
|
|
148
|
-
justifyContent: "space-between",
|
|
149
|
-
width: "100%"
|
|
150
|
-
}, ___EmotionJSX(Box, {
|
|
151
|
-
flexDirection: "row"
|
|
152
|
-
}, ___EmotionJSX(Text, {
|
|
153
|
-
variant: "variants.timeZone.item.title"
|
|
154
|
-
}, timeZone), ___EmotionJSX(Text, {
|
|
155
|
-
variant: "variants.timeZone.item.subTitle"
|
|
156
|
-
}, gmt)), ___EmotionJSX(Box, null, ___EmotionJSX(Text, {
|
|
157
|
-
variant: "variants.timeZone.item.time"
|
|
158
|
-
}, time))));
|
|
104
|
+
}, [search, selectedKey, allTimeZones]);
|
|
105
|
+
var timeData = useMemo(function () {
|
|
106
|
+
var now = new Date();
|
|
107
|
+
var map = new _Map();
|
|
108
|
+
_forEachInstanceProperty(allTimeZones).call(allTimeZones, function (tz) {
|
|
109
|
+
map.set(tz.id, now.toLocaleTimeString(locales, _objectSpread({
|
|
110
|
+
timeZone: tz.id
|
|
111
|
+
}, localeOptions)));
|
|
159
112
|
});
|
|
113
|
+
return map;
|
|
114
|
+
}, [allTimeZones, locales, localeOptions]);
|
|
115
|
+
var onInputChange = function onInputChange(value) {
|
|
116
|
+
setSearch(value);
|
|
117
|
+
if (value === '') {
|
|
118
|
+
setSelectedKey(null);
|
|
119
|
+
}
|
|
160
120
|
};
|
|
161
|
-
var
|
|
162
|
-
if (
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
121
|
+
var onSelectionChange = function onSelectionChange(key) {
|
|
122
|
+
if (!key) return;
|
|
123
|
+
var selectedItem = _findInstanceProperty(allTimeZones).call(allTimeZones, function (item) {
|
|
124
|
+
return item.key === key;
|
|
125
|
+
});
|
|
126
|
+
if (selectedItem) {
|
|
127
|
+
setSearch(selectedItem.key);
|
|
128
|
+
setSelectedKey(key);
|
|
166
129
|
}
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
},
|
|
177
|
-
onInputChange: setSearch,
|
|
178
|
-
items: filteredTimezones,
|
|
179
|
-
ref: timeZonePickerRef,
|
|
180
|
-
onOpenChange: function onOpenChange(isOpen) {
|
|
181
|
-
return setTimeUpdate(isOpen);
|
|
182
|
-
},
|
|
183
|
-
disabledKeys: [{
|
|
184
|
-
emptySearchText: emptySearchText
|
|
185
|
-
}]
|
|
186
|
-
}, otherProps);
|
|
187
|
-
}, [emptySearchText, filteredTimezones, otherProps]);
|
|
188
|
-
return ___EmotionJSX(ComboBoxField, _extends({}, getPendoID('TimeZonePicker'), comboBoxFieldProps, {
|
|
130
|
+
};
|
|
131
|
+
return ___EmotionJSX(ComboBoxField, _extends({}, getPendoID('TimeZonePicker'), otherProps, {
|
|
132
|
+
ref: timeZonePickerRef,
|
|
133
|
+
items: filteredItems,
|
|
134
|
+
inputValue: search,
|
|
135
|
+
selectedKey: selectedKey,
|
|
136
|
+
onInputChange: onInputChange,
|
|
137
|
+
onSelectionChange: onSelectionChange,
|
|
138
|
+
menuTrigger: "input",
|
|
189
139
|
disabledKeys: [emptySearchText],
|
|
190
|
-
|
|
191
|
-
|
|
140
|
+
containerProps: {
|
|
141
|
+
sx: {
|
|
142
|
+
width: 400,
|
|
143
|
+
fontSize: 'md'
|
|
144
|
+
}
|
|
145
|
+
},
|
|
146
|
+
allowsEmptyCollection: true,
|
|
147
|
+
renderEmptyState: function renderEmptyState() {
|
|
148
|
+
return ___EmotionJSX("span", null, emptySearchText);
|
|
149
|
+
}
|
|
150
|
+
}), function (item) {
|
|
151
|
+
return ___EmotionJSX(Item, {
|
|
152
|
+
key: "".concat(item.key),
|
|
153
|
+
textValue: "".concat(item.key)
|
|
154
|
+
}, ___EmotionJSX(Box, {
|
|
155
|
+
flexDirection: "row",
|
|
156
|
+
justifyContent: "space-between",
|
|
157
|
+
width: "100%"
|
|
158
|
+
}, ___EmotionJSX(Box, {
|
|
159
|
+
flexDirection: "row"
|
|
160
|
+
}, ___EmotionJSX(Text, {
|
|
161
|
+
variant: "variants.timeZone.item.title"
|
|
162
|
+
}, item.timeZone), ___EmotionJSX(Text, {
|
|
163
|
+
variant: "variants.timeZone.item.subTitle"
|
|
164
|
+
}, item.gmt)), ___EmotionJSX(Box, null, ___EmotionJSX(Text, {
|
|
165
|
+
variant: "variants.timeZone.item.time"
|
|
166
|
+
}, timeData.get(item.id)))));
|
|
167
|
+
});
|
|
192
168
|
});
|
|
193
169
|
TimeZonePicker.propTypes = {
|
|
194
170
|
/**
|
|
@@ -9,9 +9,10 @@ import _sliceInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instan
|
|
|
9
9
|
import _typeof from "@babel/runtime-corejs3/helpers/esm/typeof";
|
|
10
10
|
import _asyncToGenerator from "@babel/runtime-corejs3/helpers/esm/asyncToGenerator";
|
|
11
11
|
import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
|
|
12
|
-
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return r; }; var t, r = {}, e = Object.prototype, n = e.hasOwnProperty, o = "function" == typeof _Symbol ? _Symbol : {}, i = o.iterator || "@@iterator", a = o.asyncIterator || "@@asyncIterator", u = o.toStringTag || "@@toStringTag"; function c(t, r, e, n) { return _Object$defineProperty(t, r, { value: e, enumerable: !n, configurable: !n, writable: !n }); } try { c({}, ""); } catch (t) { c = function c(t, r, e) { return t[r] = e; }; } function h(r, e, n, o) { var i = e && e.prototype instanceof Generator ? e : Generator, a = _Object$create(i.prototype); return c(a, "_invoke", function (r, e, n) { var o = 1; return function (i, a) { if (3 === o) throw Error("Generator is already running"); if (4 === o) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var u = n.delegate; if (u) { var c = d(u, n); if (c) { if (c === f) continue; return c; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (1 === o) throw o = 4, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = 3; var h = s(r, e, n); if ("normal" === h.type) { if (o = n.done ? 4 : 2, h.arg === f) continue; return { value: h.arg, done: n.done }; } "throw" === h.type && (o = 4, n.method = "throw", n.arg = h.arg); } }; }(r, n, new Context(o || [])), !0), a; } function s(t, r, e) { try { return { type: "normal", arg: t.call(r, e) }; } catch (t) { return { type: "throw", arg: t }; } } r.wrap = h; var f = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var l = {}; c(l, i, function () { return this; }); var p = _Object$getPrototypeOf, y = p && p(p(x([]))); y && y !== e && n.call(y, i) && (l = y); var v = GeneratorFunctionPrototype.prototype = Generator.prototype = _Object$create(l); function g(t) { var
|
|
12
|
+
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return r; }; var t, r = {}, e = Object.prototype, n = e.hasOwnProperty, o = "function" == typeof _Symbol ? _Symbol : {}, i = o.iterator || "@@iterator", a = o.asyncIterator || "@@asyncIterator", u = o.toStringTag || "@@toStringTag"; function c(t, r, e, n) { return _Object$defineProperty(t, r, { value: e, enumerable: !n, configurable: !n, writable: !n }); } try { c({}, ""); } catch (t) { c = function c(t, r, e) { return t[r] = e; }; } function h(r, e, n, o) { var i = e && e.prototype instanceof Generator ? e : Generator, a = _Object$create(i.prototype); return c(a, "_invoke", function (r, e, n) { var o = 1; return function (i, a) { if (3 === o) throw Error("Generator is already running"); if (4 === o) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var u = n.delegate; if (u) { var c = d(u, n); if (c) { if (c === f) continue; return c; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (1 === o) throw o = 4, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = 3; var h = s(r, e, n); if ("normal" === h.type) { if (o = n.done ? 4 : 2, h.arg === f) continue; return { value: h.arg, done: n.done }; } "throw" === h.type && (o = 4, n.method = "throw", n.arg = h.arg); } }; }(r, n, new Context(o || [])), !0), a; } function s(t, r, e) { try { return { type: "normal", arg: t.call(r, e) }; } catch (t) { return { type: "throw", arg: t }; } } r.wrap = h; var f = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var l = {}; c(l, i, function () { return this; }); var p = _Object$getPrototypeOf, y = p && p(p(x([]))); y && y !== e && n.call(y, i) && (l = y); var v = GeneratorFunctionPrototype.prototype = Generator.prototype = _Object$create(l); function g(t) { var _context5; _forEachInstanceProperty(_context5 = ["next", "throw", "return"]).call(_context5, function (r) { c(t, r, function (t) { return this._invoke(r, t); }); }); } function AsyncIterator(t, r) { function e(o, i, a, u) { var c = s(t[o], t, i); if ("throw" !== c.type) { var h = c.arg, f = h.value; return f && "object" == _typeof(f) && n.call(f, "__await") ? r.resolve(f.__await).then(function (t) { e("next", t, a, u); }, function (t) { e("throw", t, a, u); }) : r.resolve(f).then(function (t) { h.value = t, a(h); }, function (t) { return e("throw", t, a, u); }); } u(c.arg); } var o; c(this, "_invoke", function (t, n) { function i() { return new r(function (r, o) { e(t, n, r, o); }); } return o = o ? o.then(i, i) : i(); }, !0); } function d(r, e) { var n = e.method, o = r.i[n]; if (o === t) return e.delegate = null, "throw" === n && r.i["return"] && (e.method = "return", e.arg = t, d(r, e), "throw" === e.method) || "return" !== n && (e.method = "throw", e.arg = new TypeError("The iterator does not provide a '" + n + "' method")), f; var i = s(o, r.i, e.arg); if ("throw" === i.type) return e.method = "throw", e.arg = i.arg, e.delegate = null, f; var a = i.arg; return a ? a.done ? (e[r.r] = a.value, e.next = r.n, "return" !== e.method && (e.method = "next", e.arg = t), e.delegate = null, f) : a : (e.method = "throw", e.arg = new TypeError("iterator result is not an object"), e.delegate = null, f); } function w(t) { this.tryEntries.push(t); } function m(r) { var e = r[4] || {}; e.type = "normal", e.arg = t, r[4] = e; } function Context(t) { this.tryEntries = [[-1]], _forEachInstanceProperty(t).call(t, w, this), this.reset(!0); } function x(r) { if (null != r) { var e = r[i]; if (e) return e.call(r); if ("function" == typeof r.next) return r; if (!isNaN(r.length)) { var o = -1, a = function e() { for (; ++o < r.length;) if (n.call(r, o)) return e.value = r[o], e.done = !1, e; return e.value = t, e.done = !0, e; }; return a.next = a; } } throw new TypeError(_typeof(r) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, c(v, "constructor", GeneratorFunctionPrototype), c(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = c(GeneratorFunctionPrototype, u, "GeneratorFunction"), r.isGeneratorFunction = function (t) { var r = "function" == typeof t && t.constructor; return !!r && (r === GeneratorFunction || "GeneratorFunction" === (r.displayName || r.name)); }, r.mark = function (t) { return _Object$setPrototypeOf ? _Object$setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, c(t, u, "GeneratorFunction")), t.prototype = _Object$create(v), t; }, r.awrap = function (t) { return { __await: t }; }, g(AsyncIterator.prototype), c(AsyncIterator.prototype, a, function () { return this; }), r.AsyncIterator = AsyncIterator, r.async = function (t, e, n, o, i) { void 0 === i && (i = _Promise); var a = new AsyncIterator(h(t, e, n, o), i); return r.isGeneratorFunction(e) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, g(v), c(v, u, "Generator"), c(v, i, function () { return this; }), c(v, "toString", function () { return "[object Generator]"; }), r.keys = function (t) { var r = Object(t), e = []; for (var n in r) e.unshift(n); return function t() { for (; e.length;) if ((n = e.pop()) in r) return t.value = n, t.done = !1, t; return t.done = !0, t; }; }, r.values = x, Context.prototype = { constructor: Context, reset: function reset(r) { var _context6; if (this.prev = this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, _forEachInstanceProperty(_context6 = this.tryEntries).call(_context6, m), !r) for (var e in this) "t" === e.charAt(0) && n.call(this, e) && !isNaN(+_sliceInstanceProperty(e).call(e, 1)) && (this[e] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0][4]; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(r) { if (this.done) throw r; var e = this; function n(t) { a.type = "throw", a.arg = r, e.next = t; } for (var o = e.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i[4], u = this.prev, c = i[1], h = i[2]; if (-1 === i[0]) return n("end"), !1; if (!c && !h) throw Error("try statement without catch or finally"); if (null != i[0] && i[0] <= u) { if (u < c) return this.method = "next", this.arg = t, n(c), !0; if (u < h) return n(h), !1; } } }, abrupt: function abrupt(t, r) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var n = this.tryEntries[e]; if (n[0] > -1 && n[0] <= this.prev && this.prev < n[2]) { var o = n; break; } } o && ("break" === t || "continue" === t) && o[0] <= r && r <= o[2] && (o = null); var i = o ? o[4] : {}; return i.type = t, i.arg = r, o ? (this.method = "next", this.next = o[2], f) : this.complete(i); }, complete: function complete(t, r) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && r && (this.next = r), f; }, finish: function finish(t) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var e = this.tryEntries[r]; if (e[2] === t) return this.complete(e[4], e[3]), m(e), f; } }, "catch": function _catch(t) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var e = this.tryEntries[r]; if (e[0] === t) { var n = e[4]; if ("throw" === n.type) { var o = n.arg; m(e); } return o; } } throw Error("illegal catch attempt"); }, delegateYield: function delegateYield(r, e, n) { return this.delegate = { i: x(r), r: e, n: n }, "next" === this.method && (this.arg = t), f; } }, r; }
|
|
13
13
|
import React from 'react';
|
|
14
14
|
import userEvent from '@testing-library/user-event';
|
|
15
|
+
import exp from 'constants';
|
|
15
16
|
import { OverlayProvider, TimeZonePicker } from '../../index';
|
|
16
17
|
import { render, screen } from '../../utils/testUtils/testWrapper';
|
|
17
18
|
import { universalComponentTests } from '../../utils/testUtils/universalComponentTest';
|
|
@@ -125,4 +126,30 @@ universalComponentTests({
|
|
|
125
126
|
renderComponent: function renderComponent(props) {
|
|
126
127
|
return ___EmotionJSX(TimeZonePicker, _extends({}, defaultProps, props));
|
|
127
128
|
}
|
|
128
|
-
});
|
|
129
|
+
});
|
|
130
|
+
test('selecting a timezone updates the input value', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
|
|
131
|
+
var input, option;
|
|
132
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
133
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
134
|
+
case 0:
|
|
135
|
+
getComponent();
|
|
136
|
+
input = screen.queryByRole('combobox');
|
|
137
|
+
_context4.next = 4;
|
|
138
|
+
return userEvent.type(input, 'America/New York');
|
|
139
|
+
case 4:
|
|
140
|
+
expect(input).toHaveValue('America/New York');
|
|
141
|
+
expect(screen.queryByRole('listbox')).toBeInTheDocument();
|
|
142
|
+
option = screen.getByRole('option', {
|
|
143
|
+
key: 'America/New York GMT-05:00'
|
|
144
|
+
});
|
|
145
|
+
expect(option).toBeInTheDocument();
|
|
146
|
+
_context4.next = 10;
|
|
147
|
+
return userEvent.click(option);
|
|
148
|
+
case 10:
|
|
149
|
+
expect(input).toHaveValue('America/New York GMT-05:00');
|
|
150
|
+
case 11:
|
|
151
|
+
case "end":
|
|
152
|
+
return _context4.stop();
|
|
153
|
+
}
|
|
154
|
+
}, _callee4);
|
|
155
|
+
})));
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import _slicedToArray from "@babel/runtime-corejs3/helpers/esm/slicedToArray";
|
|
2
|
+
import _findInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/find";
|
|
3
|
+
import _parseInt from "@babel/runtime-corejs3/core-js-stable/parse-int";
|
|
4
|
+
export var getOffSetString = function getOffSetString(timeZone) {
|
|
5
|
+
var _parts$find;
|
|
6
|
+
// Use Intl.DateTimeFormat to get the GMT offset string
|
|
7
|
+
var parts = new Intl.DateTimeFormat('en-US', {
|
|
8
|
+
timeZone: timeZone,
|
|
9
|
+
timeZoneName: 'longOffset'
|
|
10
|
+
}).formatToParts(new Date());
|
|
11
|
+
|
|
12
|
+
// Extract the GMT offset part
|
|
13
|
+
var offsetString = ((_parts$find = _findInstanceProperty(parts).call(parts, function (p) {
|
|
14
|
+
return p.type === 'timeZoneName';
|
|
15
|
+
})) === null || _parts$find === void 0 ? void 0 : _parts$find.value) || 'GMT+00:00';
|
|
16
|
+
if (offsetString !== 'GMT') {
|
|
17
|
+
return offsetString;
|
|
18
|
+
}
|
|
19
|
+
return 'GMT+00:00';
|
|
20
|
+
};
|
|
21
|
+
export var getNumericOffset = function getNumericOffset(offsetString) {
|
|
22
|
+
// Convert GMT offset string to numeric offset in hours
|
|
23
|
+
var match = offsetString.match(/([+-])(\d+):(\d+)/);
|
|
24
|
+
if (match) {
|
|
25
|
+
var _match = _slicedToArray(match, 4),
|
|
26
|
+
_ = _match[0],
|
|
27
|
+
sign = _match[1],
|
|
28
|
+
hours = _match[2],
|
|
29
|
+
minutes = _match[3];
|
|
30
|
+
// Calculate the numeric offset in hours
|
|
31
|
+
return (_parseInt(hours, 10) + _parseInt(minutes, 10) / 60) * (sign === '+' ? 1 : -1);
|
|
32
|
+
}
|
|
33
|
+
return 0;
|
|
34
|
+
};
|
|
35
|
+
export var getGmtAndOffset = function getGmtAndOffset(timeZone) {
|
|
36
|
+
try {
|
|
37
|
+
var offsetString = getOffSetString(timeZone);
|
|
38
|
+
var numericOffset = getNumericOffset(offsetString);
|
|
39
|
+
|
|
40
|
+
// Return both the GMT string and numeric offset
|
|
41
|
+
return {
|
|
42
|
+
gmt: offsetString,
|
|
43
|
+
numericOffset: numericOffset
|
|
44
|
+
};
|
|
45
|
+
} catch (e) {
|
|
46
|
+
return {
|
|
47
|
+
gmt: 'GMT+00:00',
|
|
48
|
+
numericOffset: 0
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
};
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import _typeof from "@babel/runtime-corejs3/helpers/esm/typeof";
|
|
2
|
+
import { getGmtAndOffset, getNumericOffset, getOffSetString } from './helper';
|
|
3
|
+
describe('TimeZonePicker helpers', function () {
|
|
4
|
+
describe('getOffSetString', function () {
|
|
5
|
+
test('returns GMT offset string for America/New_York', function () {
|
|
6
|
+
var result = getOffSetString('America/New_York');
|
|
7
|
+
expect(result).toMatch(/GMT[+-]\d{2}:\d{2}/);
|
|
8
|
+
});
|
|
9
|
+
test('returns GMT offset string for Europe/London', function () {
|
|
10
|
+
var result = getOffSetString('Europe/London');
|
|
11
|
+
expect(result).toMatch(/GMT[+-]\d{2}:\d{2}/);
|
|
12
|
+
});
|
|
13
|
+
test('returns GMT offset string for Asia/Tokyo', function () {
|
|
14
|
+
var result = getOffSetString('Asia/Tokyo');
|
|
15
|
+
expect(result).toMatch(/GMT[+-]\d{2}:\d{2}/);
|
|
16
|
+
});
|
|
17
|
+
test('returns GMT+00:00 for UTC', function () {
|
|
18
|
+
var result = getOffSetString('UTC');
|
|
19
|
+
expect(result).toBe('GMT+00:00');
|
|
20
|
+
});
|
|
21
|
+
});
|
|
22
|
+
describe('getNumericOffset', function () {
|
|
23
|
+
test('parses positive offset correctly', function () {
|
|
24
|
+
var result = getNumericOffset('GMT+05:30');
|
|
25
|
+
expect(result).toBe(5.5);
|
|
26
|
+
});
|
|
27
|
+
test('parses negative offset correctly', function () {
|
|
28
|
+
var result = getNumericOffset('GMT-08:00');
|
|
29
|
+
expect(result).toBe(-8);
|
|
30
|
+
});
|
|
31
|
+
test('parses zero offset correctly', function () {
|
|
32
|
+
var result = getNumericOffset('GMT+00:00');
|
|
33
|
+
expect(result).toBe(0);
|
|
34
|
+
});
|
|
35
|
+
test('handles offset with minutes correctly', function () {
|
|
36
|
+
var result = getNumericOffset('GMT+03:30');
|
|
37
|
+
expect(result).toBe(3.5);
|
|
38
|
+
});
|
|
39
|
+
test('returns 0 for invalid offset string', function () {
|
|
40
|
+
var result = getNumericOffset('invalid');
|
|
41
|
+
expect(result).toBe(0);
|
|
42
|
+
});
|
|
43
|
+
test('returns 0 for GMT without offset', function () {
|
|
44
|
+
var result = getNumericOffset('GMT');
|
|
45
|
+
expect(result).toBe(0);
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
describe('getGmtAndOffset', function () {
|
|
49
|
+
test('returns GMT string and numeric offset for valid timezone', function () {
|
|
50
|
+
var result = getGmtAndOffset('America/New_York');
|
|
51
|
+
expect(result).toHaveProperty('gmt');
|
|
52
|
+
expect(result).toHaveProperty('numericOffset');
|
|
53
|
+
expect(result.gmt).toMatch(/GMT[+-]\d{2}:\d{2}/);
|
|
54
|
+
expect(_typeof(result.numericOffset)).toBe('number');
|
|
55
|
+
});
|
|
56
|
+
test('returns GMT+00:00 and 0 for invalid timezone', function () {
|
|
57
|
+
var result = getGmtAndOffset('Invalid/Timezone');
|
|
58
|
+
expect(result).toEqual({
|
|
59
|
+
gmt: 'GMT+00:00',
|
|
60
|
+
numericOffset: 0
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
test('returns correct values for UTC', function () {
|
|
64
|
+
var result = getGmtAndOffset('UTC');
|
|
65
|
+
expect(result).toEqual({
|
|
66
|
+
gmt: 'GMT+00:00',
|
|
67
|
+
numericOffset: 0
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
test('returns correct values for Asia/Kolkata', function () {
|
|
71
|
+
var result = getGmtAndOffset('Asia/Kolkata');
|
|
72
|
+
expect(result.gmt).toMatch(/GMT\+05:30/);
|
|
73
|
+
expect(result.numericOffset).toBe(5.5);
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
});
|