@pingux/astro 2.96.0-alpha.0 → 2.96.0-alpha.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/lib/cjs/components/PasswordField/PasswordField.d.ts +4 -0
- package/lib/cjs/components/PasswordField/PasswordField.js +17 -97
- package/lib/cjs/components/PasswordField/PasswordField.stories.d.ts +17 -0
- package/lib/cjs/components/PasswordField/PasswordField.stories.js +12 -0
- package/lib/cjs/components/PasswordField/PasswordField.test.d.ts +1 -0
- package/lib/cjs/components/PasswordField/PasswordField.test.js +88 -43
- package/lib/cjs/components/PasswordField/index.d.ts +1 -0
- package/lib/cjs/types/index.d.ts +1 -0
- package/lib/cjs/types/index.js +29 -18
- package/lib/cjs/types/passwordField.d.ts +69 -0
- package/lib/cjs/types/passwordField.js +6 -0
- package/lib/cjs/types/requirementsList.d.ts +2 -1
- package/lib/components/PasswordField/PasswordField.js +20 -100
- package/lib/components/PasswordField/PasswordField.stories.js +12 -0
- package/lib/components/PasswordField/PasswordField.test.js +66 -21
- package/lib/types/index.js +1 -0
- package/lib/types/passwordField.js +1 -0
- package/package.json +1 -1
@@ -30,44 +30,36 @@ var _EyeOffOutlineIcon = _interopRequireDefault(require("@pingux/mdi-react/EyeOf
|
|
30
30
|
var _EyeOutlineIcon = _interopRequireDefault(require("@pingux/mdi-react/EyeOutlineIcon"));
|
31
31
|
var _utils = require("@react-aria/utils");
|
32
32
|
var _visuallyHidden = require("@react-aria/visually-hidden");
|
33
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
34
33
|
var _ = require("../..");
|
35
34
|
var _hooks = require("../../hooks");
|
36
35
|
var _pendoID = require("../../utils/devUtils/constants/pendoID");
|
37
36
|
var _statuses = _interopRequireDefault(require("../../utils/devUtils/constants/statuses"));
|
38
|
-
var _ariaAttributes = require("../../utils/docUtils/ariaAttributes");
|
39
|
-
var _fieldAttributes = require("../../utils/docUtils/fieldAttributes");
|
40
37
|
var _statusProp = require("../../utils/docUtils/statusProp");
|
41
38
|
var _react2 = require("@emotion/react");
|
42
39
|
var _excluded = ["helperText", "isVisible", "onVisibleChange", "requirements", "requirementsListProps", "slots", "status", "viewHiddenIconTestId", "viewIconTestId"];
|
43
40
|
function _getRequireWildcardCache(nodeInterop) { if (typeof _WeakMap !== "function") return null; var cacheBabelInterop = new _WeakMap(); var cacheNodeInterop = new _WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
44
41
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = _Object$defineProperty && _Object$getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? _Object$getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { _Object$defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
45
42
|
function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); enumerableOnly && (symbols = _filterInstanceProperty2(symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
46
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var
|
43
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context2, _context3; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty(_context2 = ownKeys(Object(source), !0)).call(_context2, function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context3 = ownKeys(Object(source))).call(_context3, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
|
47
44
|
var displayName = 'PasswordField';
|
48
45
|
var ARIA_LABELS_FOR_SHOW_PASSWORD_TOGGLE = {
|
49
46
|
HIDE: 'hide password',
|
50
47
|
SHOW: 'show password'
|
51
48
|
};
|
52
|
-
var RequirementMessage = function RequirementMessage(
|
49
|
+
var RequirementMessage = function RequirementMessage(props) {
|
53
50
|
var _context;
|
54
|
-
var requirement =
|
51
|
+
var requirement = props.requirement;
|
55
52
|
return (0, _react2.jsx)(_react["default"].Fragment, null, (0, _hooks.useDebounce)({
|
56
|
-
value: (0, _concat["default"])(_context = "".concat(requirement.name, " ")).call(_context, requirement.status === _statuses["default"].SUCCESS ?
|
53
|
+
value: (0, _concat["default"])(_context = "".concat(requirement.name, " ")).call(_context, requirement.status === _statuses["default"].SUCCESS ? _statuses["default"].SUCCESS : 'not met'),
|
57
54
|
delay: 100
|
58
55
|
}));
|
59
56
|
};
|
60
|
-
RequirementMessage.propTypes = {
|
61
|
-
requirement: _propTypes["default"].shape({
|
62
|
-
name: _propTypes["default"].string,
|
63
|
-
status: _propTypes["default"].string
|
64
|
-
})
|
65
|
-
};
|
66
57
|
var PasswordField = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
67
58
|
var helperText = props.helperText,
|
68
59
|
isVisibleProp = props.isVisible,
|
69
60
|
onVisibleChangeProp = props.onVisibleChange,
|
70
|
-
requirements = props.requirements,
|
61
|
+
_props$requirements = props.requirements,
|
62
|
+
requirements = _props$requirements === void 0 ? [] : _props$requirements,
|
71
63
|
requirementsListProps = props.requirementsListProps,
|
72
64
|
slots = props.slots,
|
73
65
|
status = props.status,
|
@@ -79,9 +71,9 @@ var PasswordField = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
79
71
|
isTyping = _useState2[0],
|
80
72
|
setIsTyping = _useState2[1];
|
81
73
|
var checkRequirements = function checkRequirements() {
|
82
|
-
return
|
74
|
+
return (0, _filter["default"])(requirements).call(requirements, function (req) {
|
83
75
|
return req.status === 'default';
|
84
|
-
}).length
|
76
|
+
}).length === 0;
|
85
77
|
};
|
86
78
|
var _useField = (0, _hooks.useField)(_objectSpread({
|
87
79
|
status: status
|
@@ -92,20 +84,16 @@ var PasswordField = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
92
84
|
fieldLabelProps = _useField.fieldLabelProps;
|
93
85
|
var isFocused = fieldControlInputProps.isFocused,
|
94
86
|
onChange = fieldControlInputProps.onChange;
|
95
|
-
var inputRef = (0,
|
96
|
-
var popoverRef = (0, _react.useRef)();
|
87
|
+
var inputRef = (0, _hooks.useLocalOrForwardRef)(ref);
|
88
|
+
var popoverRef = (0, _react.useRef)(null);
|
97
89
|
(0, _hooks.usePropWarning)(props, 'disabled', 'isDisabled');
|
98
|
-
/* istanbul ignore next */
|
99
|
-
(0, _react.useImperativeHandle)(ref, function () {
|
100
|
-
return inputRef.current;
|
101
|
-
});
|
102
90
|
var _useProgressiveState = (0, _hooks.useProgressiveState)(isVisibleProp, isVisibleProp),
|
103
91
|
_useProgressiveState2 = (0, _slicedToArray2["default"])(_useProgressiveState, 2),
|
104
92
|
isVisible = _useProgressiveState2[0],
|
105
93
|
setIsShown = _useProgressiveState2[1];
|
106
94
|
|
107
95
|
// Measure the width of the input to inform the width of the menu (below).
|
108
|
-
var _useState3 = (0, _react.useState)(
|
96
|
+
var _useState3 = (0, _react.useState)(0),
|
109
97
|
_useState4 = (0, _slicedToArray2["default"])(_useState3, 2),
|
110
98
|
menuWidth = _useState4[0],
|
111
99
|
setMenuWidth = _useState4[1];
|
@@ -150,12 +138,12 @@ var PasswordField = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
150
138
|
var toggleShowPasswordAriaLabel = isVisible ? ARIA_LABELS_FOR_SHOW_PASSWORD_TOGGLE.HIDE : ARIA_LABELS_FOR_SHOW_PASSWORD_TOGGLE.SHOW;
|
151
139
|
var handleToggleShowPassword = function handleToggleShowPassword() {
|
152
140
|
setIsShown(!isVisible);
|
141
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
142
|
+
args[_key] = arguments[_key];
|
143
|
+
}
|
144
|
+
var params = _objectSpread({}, args);
|
153
145
|
if (onVisibleChangeProp) {
|
154
|
-
|
155
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
156
|
-
args[_key] = arguments[_key];
|
157
|
-
}
|
158
|
-
onVisibleChangeProp.apply(void 0, (0, _concat["default"])(_context2 = [!isVisible]).call(_context2, args));
|
146
|
+
onVisibleChangeProp(!isVisible, params);
|
159
147
|
}
|
160
148
|
};
|
161
149
|
var handleInputChange = function handleInputChange(e) {
|
@@ -165,7 +153,7 @@ var PasswordField = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
165
153
|
setIsTyping(true);
|
166
154
|
(0, _setTimeout2["default"])(function () {
|
167
155
|
setIsTyping(false);
|
168
|
-
},
|
156
|
+
}, 300);
|
169
157
|
};
|
170
158
|
return (0, _react2.jsx)(_react["default"].Fragment, null, (0, _react2.jsx)(_.Box, (0, _extends2["default"])({
|
171
159
|
variant: "forms.input.fieldContainer"
|
@@ -222,74 +210,6 @@ var PasswordField = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
222
210
|
}));
|
223
211
|
}))));
|
224
212
|
});
|
225
|
-
PasswordField.propTypes = _objectSpread(_objectSpread(_objectSpread({
|
226
|
-
/** The rendered label for the field. */
|
227
|
-
label: _propTypes["default"].node,
|
228
|
-
/** Whether or not the password is visible. */
|
229
|
-
isVisible: _propTypes["default"].bool,
|
230
|
-
/** Function that is passed into the IconButton within this component. */
|
231
|
-
onVisibleChange: _propTypes["default"].func,
|
232
|
-
/** Text rendered below the input. */
|
233
|
-
helperText: _propTypes["default"].node,
|
234
|
-
/** The unique identifier for the input element. */
|
235
|
-
id: _propTypes["default"].string,
|
236
|
-
/** The name for the input element. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#htmlattrdefname). */
|
237
|
-
name: _propTypes["default"].string,
|
238
|
-
/**
|
239
|
-
* Callback fired when the value is changed on the input element.
|
240
|
-
*
|
241
|
-
* @param {object} event The event source of the callback.
|
242
|
-
* You can pull out the new value by accessing `event.target.value` (string).
|
243
|
-
*/
|
244
|
-
onChange: _propTypes["default"].func,
|
245
|
-
/** The value for the input element (controlled). */
|
246
|
-
value: _propTypes["default"].string,
|
247
|
-
/** How the input should handle autocompletion according to the browser. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#htmlattrdefautocomplete). The `autocomplete` prop is an alias for this. */
|
248
|
-
autoComplete: _propTypes["default"].string,
|
249
|
-
/** @ignore Alias for `autoComplete` prop. Exists for backwards-compatibility. */
|
250
|
-
autocomplete: _propTypes["default"].string,
|
251
|
-
/** A list of class names to apply to the input element. */
|
252
|
-
className: _propTypes["default"].oneOfType([_propTypes["default"].string, _propTypes["default"].arrayOf(_propTypes["default"].string)]),
|
253
|
-
/** The default value for the input element. */
|
254
|
-
defaultValue: _propTypes["default"].string,
|
255
|
-
/** Whether the input element is automatically focused when loaded onto the page. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#htmlattrdefautofocus). */
|
256
|
-
hasAutoFocus: _propTypes["default"].bool,
|
257
|
-
/** Whether the field is disabled. */
|
258
|
-
isDisabled: _propTypes["default"].bool,
|
259
|
-
/** Whether the input can be selected, but not changed by the user. */
|
260
|
-
isReadOnly: _propTypes["default"].bool,
|
261
|
-
/** Whether the field is required. */
|
262
|
-
isRequired: _propTypes["default"].bool,
|
263
|
-
/** Add max Length to input value */
|
264
|
-
maxLength: _propTypes["default"].number,
|
265
|
-
/**
|
266
|
-
* Callback fired when focus is lost on the input element.
|
267
|
-
*/
|
268
|
-
onBlur: _propTypes["default"].func,
|
269
|
-
/**
|
270
|
-
* Callback fired when focus is lost on the input element.
|
271
|
-
*/
|
272
|
-
onFocus: _propTypes["default"].func,
|
273
|
-
/** The placeholder text to display in the input element. */
|
274
|
-
placeholder: _propTypes["default"].string,
|
275
|
-
/** Provides a way to insert markup in specified places. */
|
276
|
-
slots: _propTypes["default"].shape({
|
277
|
-
/** The given node will be inserted into the field container. */
|
278
|
-
inContainer: _propTypes["default"].node
|
279
|
-
}),
|
280
|
-
/** Determines the type of input to use. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#htmlattrdeftype). */
|
281
|
-
type: _propTypes["default"].string,
|
282
|
-
/** @ignore Prop that allows testing of the icon button. */
|
283
|
-
viewHiddenIconTestId: _propTypes["default"].string,
|
284
|
-
/** @ignore Prop that allows testing of the icon button. */
|
285
|
-
viewIconTestId: _propTypes["default"].string,
|
286
|
-
/** Array of Requirements and their status. */
|
287
|
-
requirements: _propTypes["default"].arrayOf(_propTypes["default"].shape(_objectSpread({
|
288
|
-
name: _propTypes["default"].string.isRequired
|
289
|
-
}, _statusProp.statusPropTypes))),
|
290
|
-
/** Props object that is spread to the requirements list. */
|
291
|
-
requirementsListProps: _propTypes["default"].shape({})
|
292
|
-
}, _statusProp.statusPropTypes), _ariaAttributes.ariaAttributesBasePropTypes), _fieldAttributes.inputFieldAttributesBasePropTypes);
|
293
213
|
PasswordField.defaultProps = _objectSpread({
|
294
214
|
hasAutoFocus: false,
|
295
215
|
isDisabled: false,
|
@@ -0,0 +1,17 @@
|
|
1
|
+
import { StoryFn } from '@storybook/react';
|
2
|
+
import { PasswordFieldProps } from '../../types';
|
3
|
+
declare const _default: import("@storybook/types").ComponentAnnotations<import("@storybook/react/dist/types-0a347bb9").R, import("@storybook/types").Args>;
|
4
|
+
export default _default;
|
5
|
+
export declare const Default: StoryFn<PasswordFieldProps>;
|
6
|
+
export declare const WithRequirementsList: StoryFn<PasswordFieldProps>;
|
7
|
+
export declare const WithStateProps: StoryFn<PasswordFieldProps>;
|
8
|
+
export declare const FloatLabel: StoryFn<PasswordFieldProps>;
|
9
|
+
export declare const LeftLabel: StoryFn<PasswordFieldProps>;
|
10
|
+
export declare const Controlled: StoryFn<PasswordFieldProps>;
|
11
|
+
export declare const Disabled: StoryFn<PasswordFieldProps>;
|
12
|
+
export declare const ReadOnly: StoryFn<PasswordFieldProps>;
|
13
|
+
export declare const Required: StoryFn<PasswordFieldProps>;
|
14
|
+
export declare const Warning: StoryFn<PasswordFieldProps>;
|
15
|
+
export declare const Success: StoryFn<PasswordFieldProps>;
|
16
|
+
export declare const DynamicRequired: StoryFn<PasswordFieldProps>;
|
17
|
+
export declare const MaxLength: StoryFn<PasswordFieldProps>;
|
@@ -204,7 +204,19 @@ var FloatLabel = function FloatLabel() {
|
|
204
204
|
labelMode: "float"
|
205
205
|
});
|
206
206
|
};
|
207
|
+
|
208
|
+
// Added to bypass color contrast issue
|
207
209
|
exports.FloatLabel = FloatLabel;
|
210
|
+
FloatLabel.parameters = {
|
211
|
+
a11y: {
|
212
|
+
config: {
|
213
|
+
rules: [{
|
214
|
+
id: 'color-contrast',
|
215
|
+
enabled: false
|
216
|
+
}]
|
217
|
+
}
|
218
|
+
}
|
219
|
+
};
|
208
220
|
var LeftLabel = function LeftLabel() {
|
209
221
|
var _useState15 = (0, _react.useState)(false),
|
210
222
|
_useState16 = (0, _slicedToArray2["default"])(_useState15, 2),
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -16,12 +16,12 @@ var _extends2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/e
|
|
16
16
|
var _react = _interopRequireDefault(require("react"));
|
17
17
|
var _cache = _interopRequireDefault(require("@emotion/cache"));
|
18
18
|
var _react2 = require("@emotion/react");
|
19
|
-
var _react3 = require("@testing-library/react");
|
20
19
|
var _userEvent = _interopRequireDefault(require("@testing-library/user-event"));
|
20
|
+
var _statuses = _interopRequireDefault(require("../../utils/devUtils/constants/statuses"));
|
21
21
|
var _testWrapper = require("../../utils/testUtils/testWrapper");
|
22
22
|
var _universalComponentTest = require("../../utils/testUtils/universalComponentTest");
|
23
23
|
var _ = _interopRequireDefault(require("."));
|
24
|
-
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = _Object$defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof _Symbol ? _Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return _Object$defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = _Object$create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = _Object$getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = _Object$create(IteratorPrototype); function defineIteratorMethods(prototype) { var _context5; _forEachInstanceProperty(_context5 = ["next", "throw", "return"]).call(_context5, function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator["return"] && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel; var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], _forEachInstanceProperty(tryLocsList).call(tryLocsList, pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return _Object$setPrototypeOf ? _Object$setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = _Object$create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = _Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) keys.push(key); return _reverseInstanceProperty(keys).call(keys), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { var _context6; if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, _forEachInstanceProperty(_context6 = this.tryEntries).call(_context6, resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+_sliceInstanceProperty(name).call(name, 1)) && (this[name] = undefined); }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, "catch": function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; } // Emotion Cache added as test fails otherwise, root cause of this failure is unknown.
|
24
|
+
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = _Object$defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof _Symbol ? _Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return _Object$defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = _Object$create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = _Object$getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = _Object$create(IteratorPrototype); function defineIteratorMethods(prototype) { var _context6; _forEachInstanceProperty(_context6 = ["next", "throw", "return"]).call(_context6, function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator["return"] && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel; var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], _forEachInstanceProperty(tryLocsList).call(tryLocsList, pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return _Object$setPrototypeOf ? _Object$setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = _Object$create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = _Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) keys.push(key); return _reverseInstanceProperty(keys).call(keys), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { var _context7; if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, _forEachInstanceProperty(_context7 = this.tryEntries).call(_context7, resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+_sliceInstanceProperty(name).call(name, 1)) && (this[name] = undefined); }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, "catch": function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; } // Emotion Cache added as test fails otherwise, root cause of this failure is unknown.
|
25
25
|
// Failure occured with ThemeUI refactor.
|
26
26
|
// https://github.com/emotion-js/emotion/issues/1105#issuecomment-557726922
|
27
27
|
var emotionCache = (0, _cache["default"])({
|
@@ -34,45 +34,45 @@ var helperProp = 'helperText';
|
|
34
34
|
var defaultProps = {
|
35
35
|
'data-testid': testId,
|
36
36
|
label: testLabel,
|
37
|
-
|
37
|
+
helperText: helperProp,
|
38
38
|
viewHiddenIconTestId: 'view-hidden-test-id',
|
39
39
|
viewIconTestId: 'view-icon-test-id'
|
40
40
|
};
|
41
41
|
var defaultRequirements = [{
|
42
42
|
name: '6 characters',
|
43
|
-
status:
|
43
|
+
status: _statuses["default"].DEFAULT
|
44
44
|
}, {
|
45
45
|
name: '1 UPPERCASE letter',
|
46
|
-
status:
|
46
|
+
status: _statuses["default"].DEFAULT
|
47
47
|
}, {
|
48
48
|
name: '1 lowercase letter',
|
49
|
-
status:
|
49
|
+
status: _statuses["default"].DEFAULT
|
50
50
|
}, {
|
51
51
|
name: '1 number',
|
52
|
-
status:
|
52
|
+
status: _statuses["default"].DEFAULT
|
53
53
|
}, {
|
54
54
|
name: '1 special character',
|
55
|
-
status:
|
55
|
+
status: _statuses["default"].DEFAULT
|
56
56
|
}];
|
57
|
-
var
|
57
|
+
var successfulRequirements = [{
|
58
58
|
name: '6 characters',
|
59
|
-
status:
|
59
|
+
status: _statuses["default"].SUCCESS
|
60
60
|
}, {
|
61
61
|
name: '1 UPPERCASE letter',
|
62
|
-
status:
|
62
|
+
status: _statuses["default"].SUCCESS
|
63
63
|
}, {
|
64
64
|
name: '1 lowercase letter',
|
65
|
-
status:
|
65
|
+
status: _statuses["default"].SUCCESS
|
66
66
|
}, {
|
67
67
|
name: '1 number',
|
68
|
-
status:
|
68
|
+
status: _statuses["default"].SUCCESS
|
69
69
|
}, {
|
70
70
|
name: '1 special character',
|
71
|
-
status:
|
71
|
+
status: _statuses["default"].SUCCESS
|
72
72
|
}];
|
73
73
|
var getComponent = function getComponent() {
|
74
74
|
var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
75
|
-
return (0,
|
75
|
+
return (0, _testWrapper.render)((0, _react2.jsx)(_react2.CacheProvider, {
|
76
76
|
value: emotionCache
|
77
77
|
}, (0, _react2.jsx)(_["default"], (0, _extends2["default"])({}, defaultProps, props))));
|
78
78
|
};
|
@@ -88,9 +88,9 @@ afterEach(function () {
|
|
88
88
|
});
|
89
89
|
test('default password field', function () {
|
90
90
|
getComponent();
|
91
|
-
var field =
|
92
|
-
var label =
|
93
|
-
var control =
|
91
|
+
var field = _testWrapper.screen.getByTestId(testId);
|
92
|
+
var label = _testWrapper.screen.getByText(testLabel);
|
93
|
+
var control = _testWrapper.screen.getByLabelText(testLabel);
|
94
94
|
expect(field).toBeInstanceOf(HTMLDivElement);
|
95
95
|
expect(label).toBeInstanceOf(HTMLLabelElement);
|
96
96
|
expect(control).toBeInstanceOf(HTMLInputElement);
|
@@ -104,7 +104,7 @@ test('renders view icon', /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__
|
|
104
104
|
while (1) switch (_context.prev = _context.next) {
|
105
105
|
case 0:
|
106
106
|
getComponent();
|
107
|
-
viewIcon =
|
107
|
+
viewIcon = _testWrapper.screen.getByTestId(defaultProps.viewHiddenIconTestId);
|
108
108
|
expect(viewIcon).toBeInTheDocument();
|
109
109
|
case 3:
|
110
110
|
case "end":
|
@@ -118,12 +118,12 @@ test('renders view-hidden icon', /*#__PURE__*/(0, _asyncToGenerator2["default"])
|
|
118
118
|
while (1) switch (_context2.prev = _context2.next) {
|
119
119
|
case 0:
|
120
120
|
getComponent();
|
121
|
-
button =
|
121
|
+
button = _testWrapper.screen.getByRole('button');
|
122
122
|
_userEvent["default"].click(button);
|
123
|
-
viewHiddenIcon =
|
123
|
+
viewHiddenIcon = _testWrapper.screen.getByTestId(defaultProps.viewIconTestId);
|
124
124
|
expect(viewHiddenIcon).toBeInTheDocument();
|
125
125
|
_userEvent["default"].click(button);
|
126
|
-
viewIcon =
|
126
|
+
viewIcon = _testWrapper.screen.getByTestId(defaultProps.viewHiddenIconTestId);
|
127
127
|
expect(viewIcon).toBeInTheDocument();
|
128
128
|
case 8:
|
129
129
|
case "end":
|
@@ -137,9 +137,9 @@ test('renders view icon', /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__
|
|
137
137
|
while (1) switch (_context3.prev = _context3.next) {
|
138
138
|
case 0:
|
139
139
|
getComponent();
|
140
|
-
button =
|
140
|
+
button = _testWrapper.screen.getByRole('button');
|
141
141
|
_userEvent["default"].click(button);
|
142
|
-
viewHiddenIcon =
|
142
|
+
viewHiddenIcon = _testWrapper.screen.getByTestId(defaultProps.viewIconTestId);
|
143
143
|
expect(viewHiddenIcon).toBeInTheDocument();
|
144
144
|
case 5:
|
145
145
|
case "end":
|
@@ -156,7 +156,7 @@ test('onPress callback is called when iconButton is pressed', /*#__PURE__*/(0, _
|
|
156
156
|
getComponent({
|
157
157
|
onVisibleChange: onPress
|
158
158
|
});
|
159
|
-
button =
|
159
|
+
button = _testWrapper.screen.getByRole('button');
|
160
160
|
_userEvent["default"].click(button);
|
161
161
|
expect(onPress).toHaveBeenCalled();
|
162
162
|
case 5:
|
@@ -167,37 +167,37 @@ test('onPress callback is called when iconButton is pressed', /*#__PURE__*/(0, _
|
|
167
167
|
})));
|
168
168
|
test('renders password input', function () {
|
169
169
|
getComponent();
|
170
|
-
var input =
|
170
|
+
var input = _testWrapper.screen.getByLabelText(testLabel);
|
171
171
|
expect(input.type).toBe('password');
|
172
172
|
});
|
173
173
|
test('renders helper text', function () {
|
174
174
|
getComponent();
|
175
|
-
var helperText =
|
175
|
+
var helperText = _testWrapper.screen.getByText(testLabel);
|
176
176
|
expect(helperText).toBeInTheDocument();
|
177
177
|
});
|
178
178
|
test('clicking icon changes input type', function () {
|
179
179
|
getComponent({
|
180
180
|
isVisible: true
|
181
181
|
});
|
182
|
-
var input =
|
182
|
+
var input = _testWrapper.screen.getByLabelText(testLabel);
|
183
183
|
expect(input.type).toBe('text');
|
184
184
|
});
|
185
185
|
test('passing in requirements and focusing renders the requirements popover', function () {
|
186
186
|
getComponent({
|
187
187
|
requirements: defaultRequirements
|
188
188
|
});
|
189
|
-
var input =
|
189
|
+
var input = _testWrapper.screen.getByRole('textbox');
|
190
190
|
_userEvent["default"].click(input);
|
191
|
-
var popover =
|
191
|
+
var popover = _testWrapper.screen.getByRole('presentation');
|
192
192
|
expect(popover).toBeInTheDocument();
|
193
193
|
});
|
194
194
|
test('if all requirements are successful, do not render popover', function () {
|
195
195
|
getComponent({
|
196
|
-
requirements:
|
196
|
+
requirements: successfulRequirements
|
197
197
|
});
|
198
|
-
var input =
|
198
|
+
var input = _testWrapper.screen.getByRole('textbox');
|
199
199
|
_userEvent["default"].click(input);
|
200
|
-
expect(
|
200
|
+
expect(_testWrapper.screen.queryByRole('presentation')).not.toBeInTheDocument();
|
201
201
|
});
|
202
202
|
test('passing in props to the requirements list works', function () {
|
203
203
|
var requirementsListProps = {
|
@@ -207,32 +207,77 @@ test('passing in props to the requirements list works', function () {
|
|
207
207
|
requirements: defaultRequirements,
|
208
208
|
requirementsListProps: requirementsListProps
|
209
209
|
});
|
210
|
-
expect(
|
211
|
-
_userEvent["default"].click(
|
212
|
-
expect(
|
210
|
+
expect(_testWrapper.screen.queryByTestId(requirementsListProps['data-testid'])).not.toBeInTheDocument();
|
211
|
+
_userEvent["default"].click(_testWrapper.screen.getByRole('textbox'));
|
212
|
+
expect(_testWrapper.screen.queryByTestId(requirementsListProps['data-testid'])).toBeInTheDocument();
|
213
213
|
});
|
214
214
|
test('password field with helper text', function () {
|
215
215
|
var helperText = 'helper text';
|
216
216
|
getComponent({
|
217
217
|
helperText: helperText
|
218
218
|
});
|
219
|
-
var helper =
|
219
|
+
var helper = _testWrapper.screen.getByText(helperText);
|
220
220
|
expect(helper).toBeInTheDocument();
|
221
221
|
});
|
222
222
|
test('onChange function receives right text', function () {
|
223
223
|
var inputText = '';
|
224
|
-
(0, _testWrapper.act)(function () {
|
225
|
-
global.setTimeout = jest.fn(function (cb) {
|
226
|
-
return cb();
|
227
|
-
});
|
228
|
-
});
|
229
224
|
var testOnChange = function testOnChange(e) {
|
230
225
|
inputText = e.target.value;
|
231
226
|
};
|
232
227
|
getComponent({
|
233
228
|
onChange: testOnChange
|
234
229
|
});
|
235
|
-
var input =
|
230
|
+
var input = _testWrapper.screen.getByRole('textbox');
|
236
231
|
_userEvent["default"].type(input, '12345678');
|
232
|
+
jest.useFakeTimers();
|
237
233
|
expect(inputText).toBe('12345678');
|
234
|
+
});
|
235
|
+
test('renders left slot content', function () {
|
236
|
+
var leftSlotContent = (0, _react2.jsx)("div", {
|
237
|
+
"data-testid": "in-container-slot"
|
238
|
+
}, "Slot Content");
|
239
|
+
getComponent({
|
240
|
+
slots: {
|
241
|
+
inContainer: leftSlotContent
|
242
|
+
}
|
243
|
+
});
|
244
|
+
var leftSlot = _testWrapper.screen.getByTestId('in-container-slot');
|
245
|
+
expect(leftSlot).toBeInTheDocument();
|
246
|
+
expect(leftSlot).toHaveTextContent('Slot Content');
|
247
|
+
});
|
248
|
+
test('handleInputChange sets isTyping to true and then false after 300ms', /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
|
249
|
+
var delay, input;
|
250
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
251
|
+
while (1) switch (_context5.prev = _context5.next) {
|
252
|
+
case 0:
|
253
|
+
delay = 300;
|
254
|
+
jest.useFakeTimers();
|
255
|
+
getComponent();
|
256
|
+
input = _testWrapper.screen.getByRole('textbox');
|
257
|
+
_userEvent["default"].type(input, 'test');
|
258
|
+
expect(input).toHaveValue('test');
|
259
|
+
expect(input.type).toBe('password');
|
260
|
+
(0, _testWrapper.act)(function () {
|
261
|
+
jest.advanceTimersByTime(delay);
|
262
|
+
});
|
263
|
+
_context5.next = 10;
|
264
|
+
return (0, _testWrapper.act)(function () {
|
265
|
+
expect(input).toHaveValue('test');
|
266
|
+
}, {
|
267
|
+
timeout: delay + 1
|
268
|
+
});
|
269
|
+
case 10:
|
270
|
+
case "end":
|
271
|
+
return _context5.stop();
|
272
|
+
}
|
273
|
+
}, _callee5);
|
274
|
+
})));
|
275
|
+
test('handleInputChange calls onChange prop', function () {
|
276
|
+
var onChange = jest.fn();
|
277
|
+
getComponent({
|
278
|
+
onChange: onChange
|
279
|
+
});
|
280
|
+
var input = _testWrapper.screen.getByRole('textbox');
|
281
|
+
_userEvent["default"].type(input, 'test');
|
282
|
+
expect(onChange).toHaveBeenCalled();
|
238
283
|
});
|
@@ -0,0 +1 @@
|
|
1
|
+
export { default } from './PasswordField';
|
package/lib/cjs/types/index.d.ts
CHANGED
@@ -36,6 +36,7 @@ export * from './Modal';
|
|
36
36
|
export * from './navBar';
|
37
37
|
export * from './navSideBar';
|
38
38
|
export * from './overlayPanel';
|
39
|
+
export * from './passwordField';
|
39
40
|
export * from './popoverContainer';
|
40
41
|
export * from './popoverMenu';
|
41
42
|
export * from './progressBar';
|