auth0-lock 11.35.0 → 12.0.0
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/.browserslistrc +1 -0
- package/.circleci/config.yml +3 -1
- package/.shiprc +4 -5
- package/CHANGELOG.md +25 -0
- package/DEVELOPMENT.md +1 -1
- package/README.md +20 -16
- package/karma.conf.js +1 -1
- package/lib/CSSCore.js +1 -4
- package/lib/__tests__/auth_button.js +12 -22
- package/lib/__tests__/connection/database/actions.js +48 -49
- package/lib/__tests__/connection/database/index.js +22 -28
- package/lib/__tests__/connection/database/login_pane.js +24 -47
- package/lib/__tests__/connection/database/password_reset_confirmation.js +23 -32
- package/lib/__tests__/connection/database/reset_password.js +17 -39
- package/lib/__tests__/connection/database/signed_up_confirmation.js +23 -32
- package/lib/__tests__/connection/enterprise/actions.js +22 -47
- package/lib/__tests__/connection/enterprise/hrd_pane.js +16 -33
- package/lib/__tests__/connection/enterprise/hrd_screen.js +26 -40
- package/lib/__tests__/connection/enterprise/quick_auth_screen.js +32 -75
- package/lib/__tests__/connection/passwordless/ask_vcode.js +29 -51
- package/lib/__tests__/connection/passwordless/email_sent_confirmation.js +23 -32
- package/lib/__tests__/connection/passwordless/passwordless.js +35 -97
- package/lib/__tests__/core/actions.js +23 -46
- package/lib/__tests__/core/client/index.js +10 -13
- package/lib/__tests__/core/index.js +46 -94
- package/lib/__tests__/core/remote_data.js +14 -20
- package/lib/__tests__/core/signed_in_confirmation.js +23 -32
- package/lib/__tests__/core/sso/last_login_screen.js +27 -50
- package/lib/__tests__/core/tenant.js +10 -12
- package/lib/__tests__/core/web_api/helper.js +6 -14
- package/lib/__tests__/core/web_api/p2_api.js +38 -33
- package/lib/__tests__/core/web_api.js +37 -33
- package/lib/__tests__/engine/classic/login.js +20 -41
- package/lib/__tests__/engine/classic/mfa_login_screen.js +6 -19
- package/lib/__tests__/engine/classic/sign_up_pane.js +33 -55
- package/lib/__tests__/engine/classic/sign_up_screen.js +18 -45
- package/lib/__tests__/engine/classic.js +13 -6
- package/lib/__tests__/engine/passwordless/social_or_email_login_screen.js +7 -28
- package/lib/__tests__/engine/passwordless/social_or_phone_number_login_screen.js +7 -28
- package/lib/__tests__/engine/passwordless.js +2 -5
- package/lib/__tests__/field/captcha/recaptcha_enterprise.js +27 -27
- package/lib/__tests__/field/captcha/recaptchav2.js +27 -27
- package/lib/__tests__/field/captcha.js +39 -51
- package/lib/__tests__/field/custom_input.js +23 -47
- package/lib/__tests__/field/email.js +2 -3
- package/lib/__tests__/field/email_pane.js +25 -48
- package/lib/__tests__/field/field.js +9 -13
- package/lib/__tests__/field/login_pane.js +30 -34
- package/lib/__tests__/field/mfa_code_pane.js +13 -28
- package/lib/__tests__/field/option_selection_pane.js +7 -25
- package/lib/__tests__/field/password.js +6 -12
- package/lib/__tests__/field/password_pane.js +29 -46
- package/lib/__tests__/field/phone_number_pane.js +18 -41
- package/lib/__tests__/field/social_buttons_pane.js +30 -47
- package/lib/__tests__/field/username.js +27 -48
- package/lib/__tests__/field/username_pane.js +30 -47
- package/lib/__tests__/field/vcode.js +5 -13
- package/lib/__tests__/field/vcode_pane.js +20 -44
- package/lib/__tests__/i18n.js +28 -53
- package/lib/__tests__/quick-auth/actions.js +4 -27
- package/lib/__tests__/setup-tests.js +7 -9
- package/lib/__tests__/testUtils.js +41 -58
- package/lib/__tests__/ui/box/chrome.js +24 -49
- package/lib/__tests__/ui/box/confirmation_pane.js +23 -42
- package/lib/__tests__/ui/box/container.js +21 -46
- package/lib/__tests__/ui/box/global_message.js +60 -37
- package/lib/__tests__/ui/input/email_input.js +6 -17
- package/lib/__tests__/ui/input/input_wrap.js +6 -19
- package/lib/__tests__/ui/input/password/password_strength.js +13 -15
- package/lib/__tests__/ui/input/password_input.js +22 -27
- package/lib/__tests__/utils/format.js +10 -17
- package/lib/__tests__/utils/url_utils.js +2 -5
- package/lib/avatar/gravatar_provider.js +13 -28
- package/lib/avatar.js +22 -41
- package/lib/browser.js +372 -23
- package/lib/connection/captcha.js +15 -34
- package/lib/connection/database/actions.js +39 -108
- package/lib/connection/database/index.js +90 -191
- package/lib/connection/database/login_pane.js +107 -147
- package/lib/connection/database/login_sign_up_tabs.js +106 -125
- package/lib/connection/database/mfa_pane.js +50 -69
- package/lib/connection/database/password_reset_confirmation.js +51 -73
- package/lib/connection/database/reset_password.js +116 -132
- package/lib/connection/database/reset_password_pane.js +45 -56
- package/lib/connection/database/sign_up_terms.js +17 -23
- package/lib/connection/database/signed_up_confirmation.js +52 -75
- package/lib/connection/enterprise/actions.js +23 -52
- package/lib/connection/enterprise/hrd_pane.js +60 -76
- package/lib/connection/enterprise/hrd_screen.js +60 -75
- package/lib/connection/enterprise/kerberos_screen.js +46 -60
- package/lib/connection/enterprise/quick_auth_screen.js +46 -64
- package/lib/connection/enterprise/single_sign_on_notice.js +14 -26
- package/lib/connection/enterprise.js +51 -84
- package/lib/connection/passwordless/actions.js +29 -65
- package/lib/connection/passwordless/ask_vcode.js +53 -60
- package/lib/connection/passwordless/email_sent_confirmation.js +129 -179
- package/lib/connection/passwordless/index.js +36 -68
- package/lib/connection/social/index.js +12 -15
- package/lib/core/actions.js +33 -85
- package/lib/core/client/index.js +38 -58
- package/lib/core/client/settings.js +12 -20
- package/lib/core/error_screen.js +38 -52
- package/lib/core/index.js +154 -305
- package/lib/core/loading_screen.js +61 -71
- package/lib/core/pane_separator.js +10 -10
- package/lib/core/remote_data.js +30 -51
- package/lib/core/screen.js +85 -79
- package/lib/core/signed_in_confirmation.js +51 -73
- package/lib/core/sso/data.js +9 -17
- package/lib/core/sso/index.js +5 -6
- package/lib/core/sso/last_login_screen.js +46 -63
- package/lib/core/tenant/index.js +37 -59
- package/lib/core/tenant/settings.js +11 -15
- package/lib/core/web_api/helper.js +22 -28
- package/lib/core/web_api/p2_api.js +162 -171
- package/lib/core/web_api.js +106 -94
- package/lib/core.js +126 -160
- package/lib/engine/classic/login.js +92 -144
- package/lib/engine/classic/mfa_login_screen.js +61 -67
- package/lib/engine/classic/sign_up_pane.js +89 -123
- package/lib/engine/classic/sign_up_screen.js +112 -158
- package/lib/engine/classic.js +122 -183
- package/lib/engine/passwordless/social_or_email_login_screen.js +80 -116
- package/lib/engine/passwordless/social_or_phone_number_login_screen.js +79 -110
- package/lib/engine/passwordless.js +75 -104
- package/lib/field/actions.js +11 -17
- package/lib/field/captcha/captcha_pane.js +83 -103
- package/lib/field/captcha/recaptcha.js +140 -145
- package/lib/field/captcha.js +7 -10
- package/lib/field/custom_input.js +37 -50
- package/lib/field/email/email_pane.js +90 -109
- package/lib/field/email.js +17 -35
- package/lib/field/index.js +50 -87
- package/lib/field/mfa-code/mfa_code_pane.js +57 -71
- package/lib/field/mfa_code.js +15 -21
- package/lib/field/option_selection_pane.js +16 -22
- package/lib/field/password/password_pane.js +79 -91
- package/lib/field/password.js +8 -14
- package/lib/field/phone-number/locations.js +7 -3
- package/lib/field/phone-number/phone_number_pane.js +87 -124
- package/lib/field/phone_number.js +16 -30
- package/lib/field/social/event.js +9 -12
- package/lib/field/social/social_buttons_pane.js +93 -121
- package/lib/field/username/username_pane.js +105 -123
- package/lib/field/username.js +16 -26
- package/lib/field/vcode/vcode_pane.js +67 -93
- package/lib/field/vcode.js +5 -5
- package/lib/i18n/af.js +7 -4
- package/lib/i18n/ar.js +7 -4
- package/lib/i18n/az.js +7 -4
- package/lib/i18n/bg.js +7 -4
- package/lib/i18n/ca.js +7 -4
- package/lib/i18n/cs.js +7 -4
- package/lib/i18n/da.js +7 -4
- package/lib/i18n/de.js +7 -3
- package/lib/i18n/el.js +7 -4
- package/lib/i18n/en.js +9 -4
- package/lib/i18n/es.js +7 -3
- package/lib/i18n/et.js +7 -4
- package/lib/i18n/fa.js +7 -4
- package/lib/i18n/fi.js +7 -4
- package/lib/i18n/fr.js +7 -4
- package/lib/i18n/he.js +7 -4
- package/lib/i18n/hr.js +7 -4
- package/lib/i18n/hu.js +7 -4
- package/lib/i18n/id.js +7 -4
- package/lib/i18n/it.js +7 -3
- package/lib/i18n/ja.js +7 -4
- package/lib/i18n/ko.js +7 -4
- package/lib/i18n/lt.js +7 -4
- package/lib/i18n/lv.js +7 -4
- package/lib/i18n/ms.js +7 -4
- package/lib/i18n/nb.js +7 -4
- package/lib/i18n/nl.js +7 -4
- package/lib/i18n/nn.js +7 -4
- package/lib/i18n/no.js +7 -4
- package/lib/i18n/pl.js +7 -4
- package/lib/i18n/pt-br.js +7 -3
- package/lib/i18n/pt.js +7 -4
- package/lib/i18n/ro.js +7 -4
- package/lib/i18n/ru.js +7 -4
- package/lib/i18n/sk.js +7 -4
- package/lib/i18n/sl.js +7 -4
- package/lib/i18n/sr.js +7 -4
- package/lib/i18n/sv.js +7 -4
- package/lib/i18n/tr.js +7 -4
- package/lib/i18n/ua.js +7 -4
- package/lib/i18n/uk.js +7 -4
- package/lib/i18n/vi.js +7 -4
- package/lib/i18n/zh-tw.js +7 -4
- package/lib/i18n/zh.js +7 -4
- package/lib/i18n.js +38 -75
- package/lib/index.js +14 -17
- package/lib/lock.js +29 -32
- package/lib/passwordless.js +29 -31
- package/lib/quick-auth/actions.js +19 -26
- package/lib/quick_auth.js +8 -10
- package/lib/sanitizer.js +5 -5
- package/lib/store/index.js +22 -42
- package/lib/sync.js +21 -42
- package/lib/ui/box/button.js +85 -105
- package/lib/ui/box/chrome.js +463 -548
- package/lib/ui/box/confirmation_pane.js +34 -48
- package/lib/ui/box/container.js +305 -339
- package/lib/ui/box/global_message.js +51 -60
- package/lib/ui/box/header.js +155 -177
- package/lib/ui/box/multisize_slide.js +233 -229
- package/lib/ui/box/success_pane.js +34 -37
- package/lib/ui/box.js +88 -93
- package/lib/ui/button/auth_button.js +44 -51
- package/lib/ui/input/captcha_input.js +162 -181
- package/lib/ui/input/checkbox_input.js +57 -59
- package/lib/ui/input/email_input.js +117 -124
- package/lib/ui/input/input_wrap.js +65 -80
- package/lib/ui/input/location_input.js +130 -150
- package/lib/ui/input/mfa_code_input.js +98 -98
- package/lib/ui/input/password/password_strength.js +103 -127
- package/lib/ui/input/password_input.js +141 -147
- package/lib/ui/input/phone_number_input.js +101 -109
- package/lib/ui/input/select_input.js +120 -132
- package/lib/ui/input/text_input.js +89 -84
- package/lib/ui/input/username_input.js +109 -115
- package/lib/ui/input/vcode_input.js +110 -118
- package/lib/ui/list.js +224 -247
- package/lib/ui/pane/quick_auth_pane.js +55 -80
- package/lib/utils/atom.js +55 -48
- package/lib/utils/cache.js +54 -43
- package/lib/utils/cdn_utils.js +17 -31
- package/lib/utils/createRef.js +3 -1
- package/lib/utils/data_utils.js +10 -16
- package/lib/utils/fn_utils.js +5 -4
- package/lib/utils/format.js +6 -8
- package/lib/utils/id_utils.js +4 -3
- package/lib/utils/jsonp_utils.js +20 -17
- package/lib/utils/media_utils.js +4 -2
- package/lib/utils/preload_utils.js +4 -3
- package/lib/utils/string_utils.js +4 -4
- package/lib/utils/url_utils.js +4 -3
- package/package.json +48 -34
- package/webpack.config.js +36 -3
|
@@ -1,25 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
|
|
4
|
-
|
|
5
|
-
var _react = require('react');
|
|
6
|
-
|
|
7
|
-
var _react2 = _interopRequireDefault(_react);
|
|
8
|
-
|
|
9
|
-
var _enzyme = require('enzyme');
|
|
10
|
-
|
|
11
|
-
var _testUtils = require('testUtils');
|
|
1
|
+
"use strict";
|
|
12
2
|
|
|
3
|
+
var _react = _interopRequireDefault(require("react"));
|
|
4
|
+
var _enzyme = require("enzyme");
|
|
5
|
+
var _testUtils = require("testUtils");
|
|
13
6
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
14
|
-
|
|
7
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
15
8
|
jest.mock('ui/button/auth_button', function () {
|
|
16
9
|
return (0, _testUtils.mockComponent)('auth_button');
|
|
17
10
|
});
|
|
18
|
-
|
|
19
11
|
var getComponent = function getComponent() {
|
|
20
12
|
return require('field/social/social_buttons_pane').default;
|
|
21
13
|
};
|
|
22
|
-
|
|
23
14
|
describe('SocialButtonsPane', function () {
|
|
24
15
|
var defaultProps = {
|
|
25
16
|
lock: {
|
|
@@ -29,44 +20,46 @@ describe('SocialButtonsPane', function () {
|
|
|
29
20
|
}
|
|
30
21
|
},
|
|
31
22
|
labelFn: function labelFn() {
|
|
32
|
-
for (var _len = arguments.length, keys = Array(_len), _key = 0; _key < _len; _key++) {
|
|
23
|
+
for (var _len = arguments.length, keys = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
33
24
|
keys[_key] = arguments[_key];
|
|
34
25
|
}
|
|
35
|
-
|
|
36
26
|
return keys.join(',');
|
|
37
27
|
},
|
|
38
28
|
showLoading: false,
|
|
39
29
|
signUp: false,
|
|
40
30
|
disabled: false
|
|
41
31
|
};
|
|
42
|
-
|
|
43
32
|
beforeEach(function () {
|
|
44
33
|
jest.resetModules();
|
|
45
|
-
|
|
46
34
|
jest.mock('quick-auth/actions', function () {
|
|
47
35
|
return {
|
|
48
36
|
logIn: jest.fn()
|
|
49
37
|
};
|
|
50
38
|
});
|
|
51
|
-
|
|
52
39
|
jest.mock('connection/social/index', function () {
|
|
53
40
|
return {
|
|
54
41
|
displayName: function displayName() {
|
|
55
42
|
return 'displayName';
|
|
56
43
|
},
|
|
57
44
|
socialConnections: function socialConnections() {
|
|
58
|
-
return [{
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
return
|
|
62
|
-
}
|
|
45
|
+
return [{
|
|
46
|
+
item: 1,
|
|
47
|
+
get: function get(key) {
|
|
48
|
+
return "socialConnections1-".concat(key);
|
|
49
|
+
}
|
|
50
|
+
}, {
|
|
51
|
+
item: 2,
|
|
52
|
+
get: function get(key) {
|
|
53
|
+
return "socialConnections2-".concat(key);
|
|
54
|
+
}
|
|
55
|
+
}];
|
|
63
56
|
},
|
|
64
57
|
authButtonsTheme: function authButtonsTheme() {
|
|
65
58
|
return {
|
|
66
59
|
get: function get() {
|
|
67
60
|
return {
|
|
68
61
|
get: function get(key) {
|
|
69
|
-
return
|
|
62
|
+
return "authButtonsTheme-".concat(key);
|
|
70
63
|
}
|
|
71
64
|
};
|
|
72
65
|
}
|
|
@@ -74,7 +67,6 @@ describe('SocialButtonsPane', function () {
|
|
|
74
67
|
}
|
|
75
68
|
};
|
|
76
69
|
});
|
|
77
|
-
|
|
78
70
|
jest.mock('connection/database/index', function () {
|
|
79
71
|
return {
|
|
80
72
|
termsAccepted: function termsAccepted() {
|
|
@@ -82,13 +74,11 @@ describe('SocialButtonsPane', function () {
|
|
|
82
74
|
}
|
|
83
75
|
};
|
|
84
76
|
});
|
|
85
|
-
|
|
86
77
|
jest.mock('connection/database/actions', function () {
|
|
87
78
|
return {
|
|
88
79
|
signUpError: jest.fn()
|
|
89
80
|
};
|
|
90
81
|
});
|
|
91
|
-
|
|
92
82
|
jest.mock('core/index', function () {
|
|
93
83
|
return {
|
|
94
84
|
id: function id() {
|
|
@@ -98,55 +88,48 @@ describe('SocialButtonsPane', function () {
|
|
|
98
88
|
};
|
|
99
89
|
});
|
|
100
90
|
});
|
|
101
|
-
|
|
102
91
|
it('renders correctly', function () {
|
|
103
92
|
var SocialButtonsPane = getComponent();
|
|
104
|
-
(0, _testUtils.expectComponent)(
|
|
93
|
+
(0, _testUtils.expectComponent)( /*#__PURE__*/_react.default.createElement(SocialButtonsPane, defaultProps)).toMatchSnapshot();
|
|
105
94
|
});
|
|
106
95
|
it('calls signUpError when isSignUp===true and terms were not accepted', function () {
|
|
107
96
|
var SocialButtonsPane = getComponent();
|
|
108
|
-
|
|
109
|
-
|
|
97
|
+
var wrapper = (0, _enzyme.mount)( /*#__PURE__*/_react.default.createElement(SocialButtonsPane, _extends({}, defaultProps, {
|
|
98
|
+
signUp: true
|
|
99
|
+
})));
|
|
110
100
|
var props = (0, _testUtils.extractPropsFromWrapper)(wrapper, 2);
|
|
111
|
-
|
|
112
101
|
props.onClick();
|
|
113
|
-
|
|
114
102
|
var mock = require('connection/database/actions').signUpError.mock;
|
|
115
|
-
|
|
116
103
|
expect(mock.calls.length).toBe(1);
|
|
117
104
|
expect(mock.calls[0]).toMatchSnapshot();
|
|
118
105
|
});
|
|
119
106
|
it('shows loading when showLoading === true', function () {
|
|
120
107
|
var SocialButtonsPane = getComponent();
|
|
121
|
-
(0, _testUtils.expectComponent)(
|
|
108
|
+
(0, _testUtils.expectComponent)( /*#__PURE__*/_react.default.createElement(SocialButtonsPane, _extends({}, defaultProps, {
|
|
109
|
+
showLoading: true
|
|
110
|
+
}))).toMatchSnapshot();
|
|
122
111
|
});
|
|
123
112
|
it('shows header when instructions are available', function () {
|
|
124
113
|
var SocialButtonsPane = getComponent();
|
|
125
|
-
(0, _testUtils.expectComponent)(
|
|
114
|
+
(0, _testUtils.expectComponent)( /*#__PURE__*/_react.default.createElement(SocialButtonsPane, _extends({}, defaultProps, {
|
|
115
|
+
instructions: "instructions"
|
|
116
|
+
}))).toMatchSnapshot();
|
|
126
117
|
});
|
|
127
118
|
it('calls `logIn` with social connection 1 when first button is clicked', function () {
|
|
128
119
|
var SocialButtonsPane = getComponent();
|
|
129
|
-
|
|
130
|
-
var wrapper = (0, _enzyme.mount)(_react2.default.createElement(SocialButtonsPane, defaultProps));
|
|
120
|
+
var wrapper = (0, _enzyme.mount)( /*#__PURE__*/_react.default.createElement(SocialButtonsPane, defaultProps));
|
|
131
121
|
var props = (0, _testUtils.extractPropsFromWrapper)(wrapper, 2);
|
|
132
|
-
|
|
133
122
|
props.onClick();
|
|
134
|
-
|
|
135
123
|
var mock = require('quick-auth/actions').logIn.mock;
|
|
136
|
-
|
|
137
124
|
expect(mock.calls.length).toBe(1);
|
|
138
125
|
expect(mock.calls[0]).toMatchSnapshot();
|
|
139
126
|
});
|
|
140
127
|
it('calls `logIn` with social connection 2 when second button is clicked', function () {
|
|
141
128
|
var SocialButtonsPane = getComponent();
|
|
142
|
-
|
|
143
|
-
var wrapper = (0, _enzyme.mount)(_react2.default.createElement(SocialButtonsPane, defaultProps));
|
|
129
|
+
var wrapper = (0, _enzyme.mount)( /*#__PURE__*/_react.default.createElement(SocialButtonsPane, defaultProps));
|
|
144
130
|
var props = (0, _testUtils.extractPropsFromWrapper)(wrapper, 3);
|
|
145
|
-
|
|
146
131
|
props.onClick();
|
|
147
|
-
|
|
148
132
|
var mock = require('quick-auth/actions').logIn.mock;
|
|
149
|
-
|
|
150
133
|
expect(mock.calls.length).toBe(1);
|
|
151
134
|
expect(mock.calls[0]).toMatchSnapshot();
|
|
152
135
|
});
|
|
@@ -1,23 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var _immutable = require('immutable');
|
|
4
|
-
|
|
5
|
-
var _immutable2 = _interopRequireDefault(_immutable);
|
|
1
|
+
"use strict";
|
|
6
2
|
|
|
3
|
+
var _immutable = _interopRequireDefault(require("immutable"));
|
|
7
4
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
8
|
-
|
|
9
5
|
describe('field/username', function () {
|
|
10
|
-
var username
|
|
11
|
-
var dbConnection
|
|
6
|
+
var username;
|
|
7
|
+
var dbConnection;
|
|
12
8
|
beforeEach(function () {
|
|
13
9
|
jest.resetModules();
|
|
14
|
-
|
|
15
10
|
jest.mock('field/index', function () {
|
|
16
11
|
return {
|
|
17
12
|
setField: jest.fn()
|
|
18
13
|
};
|
|
19
14
|
});
|
|
20
|
-
|
|
21
15
|
jest.mock('field/email', function () {
|
|
22
16
|
return {
|
|
23
17
|
validateEmail: function validateEmail(s) {
|
|
@@ -25,7 +19,6 @@ describe('field/username', function () {
|
|
|
25
19
|
}
|
|
26
20
|
};
|
|
27
21
|
});
|
|
28
|
-
|
|
29
22
|
jest.mock('connection/database', function () {
|
|
30
23
|
return {
|
|
31
24
|
databaseConnection: function databaseConnection(m) {
|
|
@@ -33,9 +26,8 @@ describe('field/username', function () {
|
|
|
33
26
|
}
|
|
34
27
|
};
|
|
35
28
|
});
|
|
36
|
-
|
|
37
29
|
username = require('field/username');
|
|
38
|
-
dbConnection =
|
|
30
|
+
dbConnection = _immutable.default.fromJS({
|
|
39
31
|
validation: null
|
|
40
32
|
});
|
|
41
33
|
});
|
|
@@ -48,23 +40,24 @@ describe('field/username', function () {
|
|
|
48
40
|
});
|
|
49
41
|
});
|
|
50
42
|
describe('getUsernameValidation()', function () {
|
|
51
|
-
it(
|
|
52
|
-
expect(username.getUsernameValidation(
|
|
43
|
+
it("returns database connection's username validation", function () {
|
|
44
|
+
expect(username.getUsernameValidation(_immutable.default.fromJS({
|
|
53
45
|
validation: {
|
|
54
|
-
username: {
|
|
46
|
+
username: {
|
|
47
|
+
min: 1,
|
|
48
|
+
max: 2
|
|
49
|
+
}
|
|
55
50
|
}
|
|
56
51
|
}))).toMatchSnapshot();
|
|
57
52
|
});
|
|
58
|
-
it(
|
|
53
|
+
it("returns null there's no db connection username validation", function () {
|
|
59
54
|
expect(username.getUsernameValidation(dbConnection)).toBe(null);
|
|
60
55
|
});
|
|
61
56
|
});
|
|
62
57
|
describe('setUsername()', function () {
|
|
63
|
-
it(
|
|
58
|
+
it("calls setField", function () {
|
|
64
59
|
username.setUsername(dbConnection, 'a-username', 'username', true);
|
|
65
|
-
|
|
66
60
|
var mock = require('field/index').setField.mock;
|
|
67
|
-
|
|
68
61
|
expect(mock.calls.length).toBe(1);
|
|
69
62
|
expect(mock.calls[0]).toMatchSnapshot();
|
|
70
63
|
});
|
|
@@ -72,94 +65,80 @@ describe('field/username', function () {
|
|
|
72
65
|
it('validates when usernameStyle is `email`', function () {
|
|
73
66
|
var email = 'a@a.com';
|
|
74
67
|
username.setUsername(dbConnection, email, 'email', true);
|
|
75
|
-
|
|
76
68
|
var mock = require('field/index').setField.mock;
|
|
77
|
-
|
|
78
69
|
expect(mock.calls[0][3](email)).toBe(email);
|
|
79
70
|
});
|
|
80
71
|
it('validates when usernameStyle is `username`', function () {
|
|
81
72
|
var theUsername = 'the_user';
|
|
82
73
|
username.setUsername(dbConnection, theUsername, 'username', true);
|
|
83
|
-
|
|
84
74
|
var mock = require('field/index').setField.mock;
|
|
85
|
-
|
|
86
75
|
expect(mock.calls[0][3](theUsername)).toBe(true);
|
|
87
76
|
});
|
|
88
77
|
it('validates when username looks like an email', function () {
|
|
89
78
|
var email = 'a@a.com';
|
|
90
79
|
username.setUsername(dbConnection, email, null, true);
|
|
91
|
-
|
|
92
80
|
var mock = require('field/index').setField.mock;
|
|
93
|
-
|
|
94
81
|
expect(mock.calls[0][3](email)).toBe(email);
|
|
95
82
|
});
|
|
96
83
|
it('validates when username does not look like an email', function () {
|
|
97
84
|
var theUsername = 'the_user';
|
|
98
85
|
username.setUsername(dbConnection, theUsername, null, true);
|
|
99
|
-
|
|
100
86
|
var mock = require('field/index').setField.mock;
|
|
101
|
-
|
|
102
87
|
expect(mock.calls[0][3](theUsername)).toBe(true);
|
|
103
88
|
});
|
|
104
89
|
it('defaults usernameStyle to `username`', function () {
|
|
105
90
|
var theUsername = 'the_user';
|
|
106
91
|
username.setUsername(dbConnection, theUsername, undefined, true);
|
|
107
|
-
|
|
108
92
|
var mock = require('field/index').setField.mock;
|
|
109
|
-
|
|
110
93
|
expect(mock.calls[0][3](theUsername)).toBe(true);
|
|
111
94
|
});
|
|
112
95
|
it('defaults validateUsernameFormat to `true`', function () {
|
|
113
96
|
var theUsername = 'the_user';
|
|
114
97
|
username.setUsername(dbConnection, theUsername, 'username', undefined);
|
|
115
|
-
|
|
116
98
|
var mock = require('field/index').setField.mock;
|
|
117
|
-
|
|
118
99
|
expect(mock.calls[0][3](theUsername)).toBe(true);
|
|
119
100
|
});
|
|
120
101
|
describe('when in username mode', function () {
|
|
121
102
|
var expectToFailWith = function expectToFailWith(theUsername) {
|
|
122
103
|
username.setUsername(dbConnection, theUsername, 'username', true);
|
|
123
|
-
|
|
124
104
|
var mock = require('field/index').setField.mock;
|
|
125
|
-
|
|
126
105
|
expect(mock.calls[0][3](theUsername)).toBe(false);
|
|
127
106
|
};
|
|
128
107
|
var expectToSuccedWith = function expectToSuccedWith(theUsername) {
|
|
129
108
|
username.setUsername(dbConnection, theUsername, 'username', true);
|
|
130
|
-
|
|
131
109
|
var mock = require('field/index').setField.mock;
|
|
132
|
-
|
|
133
110
|
expect(mock.calls[0][3](theUsername)).toBe(true);
|
|
134
111
|
};
|
|
135
112
|
describe('validates if the username is not empty', function () {
|
|
136
113
|
it('when `validateUsernameFormat` is true but there is no db connection validation', function () {
|
|
137
114
|
var theUsername = '';
|
|
138
115
|
username.setUsername(dbConnection, theUsername, 'username', true);
|
|
139
|
-
|
|
140
116
|
var mock = require('field/index').setField.mock;
|
|
141
|
-
|
|
142
117
|
expect(mock.calls[0][3](theUsername)).toBe(false);
|
|
143
118
|
});
|
|
144
119
|
it('when `validateUsernameFormat` is false and there is db connection validation', function () {
|
|
145
120
|
var theUsername = '';
|
|
146
|
-
var customDbConnection =
|
|
121
|
+
var customDbConnection = _immutable.default.fromJS({
|
|
147
122
|
validation: {
|
|
148
|
-
username: {
|
|
123
|
+
username: {
|
|
124
|
+
min: 1,
|
|
125
|
+
max: 2
|
|
126
|
+
}
|
|
149
127
|
}
|
|
150
128
|
});
|
|
151
129
|
username.setUsername(customDbConnection, theUsername, 'username', false);
|
|
152
|
-
|
|
153
130
|
var mock = require('field/index').setField.mock;
|
|
154
|
-
|
|
155
131
|
expect(mock.calls[0][3](theUsername)).toBe(false);
|
|
156
132
|
});
|
|
157
133
|
});
|
|
158
134
|
describe('with a db connection validation', function () {
|
|
159
135
|
beforeEach(function () {
|
|
160
|
-
dbConnection =
|
|
136
|
+
dbConnection = _immutable.default.fromJS({
|
|
161
137
|
validation: {
|
|
162
|
-
username: {
|
|
138
|
+
username: {
|
|
139
|
+
min: 3,
|
|
140
|
+
max: 5
|
|
141
|
+
}
|
|
163
142
|
}
|
|
164
143
|
});
|
|
165
144
|
});
|
|
@@ -173,15 +152,15 @@ describe('field/username', function () {
|
|
|
173
152
|
expectToFailWith('a@a.com');
|
|
174
153
|
});
|
|
175
154
|
it('validates invalid chars', function () {
|
|
176
|
-
var invalidChars =
|
|
155
|
+
var invalidChars = "{}[],;?/\\%\xA8&*()\xB9\xB2\xB3\xAA\xBA\xA7\xA3\xA2\xAC<>|\" ".split('');
|
|
177
156
|
invalidChars.forEach(function (i) {
|
|
178
|
-
return expectToFailWith(
|
|
157
|
+
return expectToFailWith("aa".concat(i));
|
|
179
158
|
});
|
|
180
159
|
});
|
|
181
160
|
it('accepts letters, numbers, `_`, `-`, `+` and `.`', function () {
|
|
182
|
-
var validChars =
|
|
161
|
+
var validChars = "_+-.!#$'^`~@".split('');
|
|
183
162
|
validChars.forEach(function (i) {
|
|
184
|
-
return expectToSuccedWith(
|
|
163
|
+
return expectToSuccedWith("aa".concat(i));
|
|
185
164
|
});
|
|
186
165
|
});
|
|
187
166
|
});
|
|
@@ -1,33 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
|
|
4
|
-
|
|
5
|
-
var _react = require('react');
|
|
6
|
-
|
|
7
|
-
var _react2 = _interopRequireDefault(_react);
|
|
8
|
-
|
|
9
|
-
var _enzyme = require('enzyme');
|
|
10
|
-
|
|
11
|
-
var _testUtils = require('testUtils');
|
|
1
|
+
"use strict";
|
|
12
2
|
|
|
3
|
+
var _react = _interopRequireDefault(require("react"));
|
|
4
|
+
var _enzyme = require("enzyme");
|
|
5
|
+
var _testUtils = require("testUtils");
|
|
13
6
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
14
|
-
|
|
7
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
15
8
|
jest.mock('ui/input/username_input', function () {
|
|
16
9
|
return (0, _testUtils.mockComponent)('username_input');
|
|
17
10
|
});
|
|
18
|
-
|
|
19
11
|
var getComponent = function getComponent() {
|
|
20
12
|
return require('field/username/username_pane').default;
|
|
21
13
|
};
|
|
22
|
-
|
|
23
14
|
describe('UsernamePane', function () {
|
|
24
15
|
var defaultProps = {
|
|
25
16
|
i18n: {
|
|
26
17
|
str: function str() {
|
|
27
|
-
for (var _len = arguments.length, keys = Array(_len), _key = 0; _key < _len; _key++) {
|
|
18
|
+
for (var _len = arguments.length, keys = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
28
19
|
keys[_key] = arguments[_key];
|
|
29
20
|
}
|
|
30
|
-
|
|
31
21
|
return keys.join(',');
|
|
32
22
|
}
|
|
33
23
|
},
|
|
@@ -40,10 +30,8 @@ describe('UsernamePane', function () {
|
|
|
40
30
|
usernameInputPlaceholder: 'usernameInputPlaceholder',
|
|
41
31
|
strictValidation: false
|
|
42
32
|
};
|
|
43
|
-
|
|
44
33
|
beforeEach(function () {
|
|
45
34
|
jest.resetModules();
|
|
46
|
-
|
|
47
35
|
var mockUsername = 'username';
|
|
48
36
|
jest.mock('field/index', function () {
|
|
49
37
|
return {
|
|
@@ -58,7 +46,6 @@ describe('UsernamePane', function () {
|
|
|
58
46
|
}
|
|
59
47
|
};
|
|
60
48
|
});
|
|
61
|
-
|
|
62
49
|
jest.mock('field/username', function () {
|
|
63
50
|
return {
|
|
64
51
|
getUsernameValidation: function getUsernameValidation() {
|
|
@@ -70,7 +57,6 @@ describe('UsernamePane', function () {
|
|
|
70
57
|
setUsername: 'setUsername'
|
|
71
58
|
};
|
|
72
59
|
});
|
|
73
|
-
|
|
74
60
|
jest.mock('core/index', function () {
|
|
75
61
|
return {
|
|
76
62
|
id: function id() {
|
|
@@ -89,14 +75,12 @@ describe('UsernamePane', function () {
|
|
|
89
75
|
}
|
|
90
76
|
};
|
|
91
77
|
});
|
|
92
|
-
|
|
93
78
|
jest.mock('avatar', function () {
|
|
94
79
|
return {
|
|
95
80
|
requestAvatar: jest.fn(),
|
|
96
81
|
debouncedRequestAvatar: jest.fn()
|
|
97
82
|
};
|
|
98
83
|
});
|
|
99
|
-
|
|
100
84
|
jest.mock('store/index', function () {
|
|
101
85
|
return {
|
|
102
86
|
swap: jest.fn(),
|
|
@@ -104,10 +88,9 @@ describe('UsernamePane', function () {
|
|
|
104
88
|
};
|
|
105
89
|
});
|
|
106
90
|
});
|
|
107
|
-
|
|
108
91
|
it('renders correctly', function () {
|
|
109
92
|
var UsernamePane = getComponent();
|
|
110
|
-
(0, _testUtils.expectComponent)(
|
|
93
|
+
(0, _testUtils.expectComponent)( /*#__PURE__*/_react.default.createElement(UsernamePane, defaultProps)).toMatchSnapshot();
|
|
111
94
|
});
|
|
112
95
|
it('sets `blankErrorHint` when username is empty', function () {
|
|
113
96
|
var fieldIndexMock = require('field/index');
|
|
@@ -118,47 +101,45 @@ describe('UsernamePane', function () {
|
|
|
118
101
|
return undefined;
|
|
119
102
|
};
|
|
120
103
|
var UsernamePane = getComponent();
|
|
121
|
-
|
|
122
|
-
(0, _testUtils.expectComponent)(_react2.default.createElement(UsernamePane, defaultProps)).toMatchSnapshot();
|
|
104
|
+
(0, _testUtils.expectComponent)( /*#__PURE__*/_react.default.createElement(UsernamePane, defaultProps)).toMatchSnapshot();
|
|
123
105
|
});
|
|
124
106
|
it('sets `usernameFormatErrorHint` when usernameLooksLikeEmail() returns false and `validateFormat` is true', function () {
|
|
125
107
|
var fieldUsernameMock = require('field/username');
|
|
126
108
|
fieldUsernameMock.getUsernameValidation = function () {
|
|
127
|
-
return {
|
|
109
|
+
return {
|
|
110
|
+
min: 'min',
|
|
111
|
+
max: 'max'
|
|
112
|
+
};
|
|
128
113
|
};
|
|
129
114
|
fieldUsernameMock.usernameLooksLikeEmail = function () {
|
|
130
115
|
return false;
|
|
131
116
|
};
|
|
132
117
|
var UsernamePane = getComponent();
|
|
133
|
-
|
|
134
|
-
|
|
118
|
+
(0, _testUtils.expectComponent)( /*#__PURE__*/_react.default.createElement(UsernamePane, _extends({}, defaultProps, {
|
|
119
|
+
validateFormat: true
|
|
120
|
+
}))).toMatchSnapshot();
|
|
135
121
|
});
|
|
136
122
|
it('sets isValid as true when `isFieldVisiblyInvalid` is false', function () {
|
|
137
123
|
require('field/index').isFieldVisiblyInvalid = function () {
|
|
138
124
|
return false;
|
|
139
125
|
};
|
|
140
126
|
var UsernamePane = getComponent();
|
|
141
|
-
|
|
142
|
-
(0, _testUtils.expectComponent)(_react2.default.createElement(UsernamePane, defaultProps)).toMatchSnapshot();
|
|
127
|
+
(0, _testUtils.expectComponent)( /*#__PURE__*/_react.default.createElement(UsernamePane, defaultProps)).toMatchSnapshot();
|
|
143
128
|
});
|
|
144
129
|
it('sets autoComplete to true when `allowAutocomplete` is true', function () {
|
|
145
130
|
require('core/index').ui.allowAutocomplete = function () {
|
|
146
131
|
return true;
|
|
147
132
|
};
|
|
148
133
|
var UsernamePane = getComponent();
|
|
149
|
-
|
|
150
|
-
(0, _testUtils.expectComponent)(_react2.default.createElement(UsernamePane, defaultProps)).toMatchSnapshot();
|
|
134
|
+
(0, _testUtils.expectComponent)( /*#__PURE__*/_react.default.createElement(UsernamePane, defaultProps)).toMatchSnapshot();
|
|
151
135
|
});
|
|
152
136
|
it('fetches the avatar on componentDidMount if ui.avatar is true and there is a username', function () {
|
|
153
137
|
require('core/index').ui.avatar = function () {
|
|
154
138
|
return true;
|
|
155
139
|
};
|
|
156
140
|
var UsernamePane = getComponent();
|
|
157
|
-
|
|
158
|
-
(0, _enzyme.mount)(_react2.default.createElement(UsernamePane, defaultProps));
|
|
159
|
-
|
|
141
|
+
(0, _enzyme.mount)( /*#__PURE__*/_react.default.createElement(UsernamePane, defaultProps));
|
|
160
142
|
var mock = require('avatar').requestAvatar.mock;
|
|
161
|
-
|
|
162
143
|
expect(mock.calls.length).toBe(1);
|
|
163
144
|
});
|
|
164
145
|
it('fetches the avatar onChange if ui.avatar is true', function () {
|
|
@@ -166,24 +147,26 @@ describe('UsernamePane', function () {
|
|
|
166
147
|
return true;
|
|
167
148
|
};
|
|
168
149
|
var UsernamePane = getComponent();
|
|
169
|
-
|
|
170
|
-
var wrapper = (0, _enzyme.mount)(_react2.default.createElement(UsernamePane, defaultProps));
|
|
150
|
+
var wrapper = (0, _enzyme.mount)( /*#__PURE__*/_react.default.createElement(UsernamePane, defaultProps));
|
|
171
151
|
var props = (0, _testUtils.extractPropsFromWrapper)(wrapper);
|
|
172
|
-
props.onChange({
|
|
173
|
-
|
|
152
|
+
props.onChange({
|
|
153
|
+
target: {
|
|
154
|
+
value: 'newUser'
|
|
155
|
+
}
|
|
156
|
+
});
|
|
174
157
|
var mock = require('avatar').debouncedRequestAvatar.mock;
|
|
175
|
-
|
|
176
158
|
expect(mock.calls.length).toBe(1);
|
|
177
159
|
});
|
|
178
160
|
it('calls `swap` onChange', function () {
|
|
179
161
|
var UsernamePane = getComponent();
|
|
180
|
-
|
|
181
|
-
var wrapper = (0, _enzyme.mount)(_react2.default.createElement(UsernamePane, defaultProps));
|
|
162
|
+
var wrapper = (0, _enzyme.mount)( /*#__PURE__*/_react.default.createElement(UsernamePane, defaultProps));
|
|
182
163
|
var props = (0, _testUtils.extractPropsFromWrapper)(wrapper);
|
|
183
|
-
props.onChange({
|
|
184
|
-
|
|
164
|
+
props.onChange({
|
|
165
|
+
target: {
|
|
166
|
+
value: 'newUser'
|
|
167
|
+
}
|
|
168
|
+
});
|
|
185
169
|
var mock = require('store/index').swap.mock;
|
|
186
|
-
|
|
187
170
|
expect(mock.calls.length).toBe(2);
|
|
188
171
|
expect(mock.calls[1]).toMatchSnapshot();
|
|
189
172
|
});
|
|
@@ -1,30 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var _immutable = require('immutable');
|
|
4
|
-
|
|
5
|
-
var _immutable2 = _interopRequireDefault(_immutable);
|
|
1
|
+
"use strict";
|
|
6
2
|
|
|
3
|
+
var _immutable = _interopRequireDefault(require("immutable"));
|
|
7
4
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
8
|
-
|
|
9
5
|
describe('field/vcode', function () {
|
|
10
|
-
var vcode
|
|
6
|
+
var vcode;
|
|
11
7
|
beforeEach(function () {
|
|
12
8
|
jest.resetModules();
|
|
13
|
-
|
|
14
9
|
jest.mock('field/index', function () {
|
|
15
10
|
return {
|
|
16
11
|
setField: jest.fn()
|
|
17
12
|
};
|
|
18
13
|
});
|
|
19
|
-
|
|
20
14
|
vcode = require('field/vcode');
|
|
21
15
|
});
|
|
22
16
|
describe('setVcode()', function () {
|
|
23
|
-
it(
|
|
24
|
-
vcode.setVcode(
|
|
25
|
-
|
|
17
|
+
it("removes spaces from code", function () {
|
|
18
|
+
vcode.setVcode(_immutable.default.fromJS({}), ' 123 456 ');
|
|
26
19
|
var mock = require('field/index').setField.mock;
|
|
27
|
-
|
|
28
20
|
expect(mock.calls.length).toBe(1);
|
|
29
21
|
expect(mock.calls[0]).toMatchSnapshot();
|
|
30
22
|
});
|