auth0-lock 11.34.1 → 12.0.0-beta.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 +4 -2
- package/.eslintrc.json +5 -5
- package/.github/workflows/codeql.yml +41 -0
- package/.shiprc +4 -5
- package/CHANGELOG.md +32 -0
- package/EXAMPLES.md +626 -0
- package/README.md +77 -649
- 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 +20 -41
- package/lib/__tests__/connection/database/password_reset_confirmation.js +19 -26
- package/lib/__tests__/connection/database/reset_password.js +17 -39
- package/lib/__tests__/connection/database/signed_up_confirmation.js +19 -26
- 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 +27 -68
- package/lib/__tests__/connection/passwordless/ask_vcode.js +29 -51
- package/lib/__tests__/connection/passwordless/email_sent_confirmation.js +19 -26
- 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 +19 -26
- 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.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 +19 -36
- 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 +14 -32
- 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 -62
- 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 +152 -301
- package/lib/core/loading_screen.js +61 -71
- package/lib/core/pane_separator.js +10 -10
- package/lib/core/remote_data.js +28 -48
- 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 +24 -30
- package/lib/core/web_api/p2_api.js +156 -165
- package/lib/core/web_api.js +101 -90
- 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 +71 -106
- package/lib/engine/passwordless/social_or_phone_number_login_screen.js +70 -100
- package/lib/engine/passwordless.js +75 -104
- package/lib/field/actions.js +11 -17
- package/lib/field/captcha/captcha_pane.js +82 -102
- 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 +51 -88
- 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/opslevel.yml +6 -0
- package/package.json +53 -38
- package/webpack.config.js +36 -3
package/lib/__tests__/i18n.js
CHANGED
|
@@ -1,102 +1,77 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var
|
|
6
|
-
|
|
7
|
-
var
|
|
8
|
-
|
|
9
|
-
var
|
|
10
|
-
|
|
11
|
-
var
|
|
12
|
-
|
|
13
|
-
var _en2 = _interopRequireDefault(_en);
|
|
14
|
-
|
|
15
|
-
var _es = require('../i18n/es');
|
|
16
|
-
|
|
17
|
-
var _es2 = _interopRequireDefault(_es);
|
|
18
|
-
|
|
19
|
-
var _sync = require('../sync');
|
|
20
|
-
|
|
21
|
-
var sync = _interopRequireWildcard(_sync);
|
|
22
|
-
|
|
23
|
-
var _index = require('../core/index');
|
|
24
|
-
|
|
25
|
-
var l = _interopRequireWildcard(_index);
|
|
26
|
-
|
|
27
|
-
var _sanitizer = require('../sanitizer');
|
|
28
|
-
|
|
29
|
-
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
|
|
30
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
4
|
+
var _immutable = _interopRequireDefault(require("immutable"));
|
|
5
|
+
var _flat = _interopRequireDefault(require("flat"));
|
|
6
|
+
var _en = _interopRequireDefault(require("../i18n/en"));
|
|
7
|
+
var _es = _interopRequireDefault(require("../i18n/es"));
|
|
8
|
+
var sync = _interopRequireWildcard(require("../sync"));
|
|
9
|
+
var l = _interopRequireWildcard(require("../core/index"));
|
|
10
|
+
var _sanitizer = require("../sanitizer");
|
|
11
|
+
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); }
|
|
12
|
+
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; }
|
|
31
13
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
32
|
-
|
|
33
14
|
describe('i18n', function () {
|
|
34
|
-
var syncSpy
|
|
35
|
-
var langSpy
|
|
36
|
-
|
|
15
|
+
var syncSpy;
|
|
16
|
+
var langSpy;
|
|
37
17
|
beforeEach(function () {
|
|
38
18
|
syncSpy = jest.spyOn(sync, 'default');
|
|
39
|
-
|
|
40
19
|
langSpy = jest.spyOn(l.ui, 'language').mockImplementation(function () {
|
|
41
20
|
return 'en';
|
|
42
21
|
});
|
|
43
22
|
});
|
|
44
|
-
|
|
45
23
|
afterEach(function () {
|
|
46
24
|
syncSpy.mockRestore();
|
|
47
25
|
langSpy.mockRestore();
|
|
48
26
|
});
|
|
49
|
-
|
|
50
27
|
describe('load i18n configuration', function () {
|
|
51
28
|
it('should have a defaultDictionary', function () {
|
|
52
29
|
var i18n = require('../i18n');
|
|
53
30
|
|
|
54
31
|
// We need to initialize the state
|
|
55
|
-
var m =
|
|
32
|
+
var m = _immutable.default.fromJS({});
|
|
56
33
|
|
|
57
34
|
// Initialize i18n.
|
|
58
35
|
var initialized = i18n.initI18n(m);
|
|
59
|
-
|
|
60
|
-
var
|
|
61
|
-
var en = (0, _flat2.default)(_en2.default);
|
|
62
|
-
|
|
36
|
+
var language = (0, _flat.default)(initialized.getIn(['i18n', 'strings']).toJS());
|
|
37
|
+
var en = (0, _flat.default)(_en.default);
|
|
63
38
|
expect(language).toEqual(en);
|
|
64
39
|
});
|
|
65
40
|
});
|
|
66
|
-
|
|
67
41
|
describe('when en language is selected', function () {
|
|
68
42
|
it('should allow check for external en dictionaries', function () {
|
|
69
43
|
var i18n = require('../i18n');
|
|
70
|
-
|
|
71
|
-
i18n.initI18n(_immutable2.default.fromJS({}));
|
|
44
|
+
i18n.initI18n(_immutable.default.fromJS({}));
|
|
72
45
|
expect(syncSpy).toHaveBeenCalledTimes(1);
|
|
73
46
|
});
|
|
74
47
|
});
|
|
75
|
-
|
|
76
48
|
describe('when html is called', function () {
|
|
77
49
|
it('should sanitize the input and not allow for javascript to be passed through', function () {
|
|
78
50
|
var i18n = require('../i18n');
|
|
79
51
|
var strings = {
|
|
80
52
|
test: '<img src=1 href=1 onerror="javascript:alert(1)"></img>'
|
|
81
53
|
};
|
|
82
|
-
var m =
|
|
54
|
+
var m = _immutable.default.fromJS({
|
|
55
|
+
i18n: {
|
|
56
|
+
strings: strings
|
|
57
|
+
}
|
|
58
|
+
});
|
|
83
59
|
var html = i18n.html(m, 'test');
|
|
84
60
|
expect(html.props.dangerouslySetInnerHTML.__html).not.toMatch(/javascript:alert/);
|
|
85
61
|
expect(html.props.dangerouslySetInnerHTML.__html).toEqual('<img href="1" src="1">');
|
|
86
62
|
});
|
|
87
|
-
|
|
88
63
|
it('should allow target=_blank with noopener noreferrer attributes', function () {
|
|
89
64
|
(0, _sanitizer.initSanitizer)();
|
|
90
|
-
|
|
91
65
|
var i18n = require('../i18n');
|
|
92
|
-
|
|
93
66
|
var strings = {
|
|
94
67
|
test: '<a href="#" target="_blank">link</a>'
|
|
95
68
|
};
|
|
96
|
-
|
|
97
|
-
|
|
69
|
+
var m = _immutable.default.fromJS({
|
|
70
|
+
i18n: {
|
|
71
|
+
strings: strings
|
|
72
|
+
}
|
|
73
|
+
});
|
|
98
74
|
var html = i18n.html(m, 'test');
|
|
99
|
-
|
|
100
75
|
expect(html.props.dangerouslySetInnerHTML.__html).toEqual('<a href="#" target="_blank" rel="noopener noreferrer">link</a>');
|
|
101
76
|
});
|
|
102
77
|
});
|
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var _actions = require('../../quick-auth/actions');
|
|
1
|
+
"use strict";
|
|
4
2
|
|
|
3
|
+
var _actions = require("../../quick-auth/actions");
|
|
5
4
|
jest.mock('../../core/actions', function () {
|
|
6
5
|
return {
|
|
7
6
|
logIn: jest.fn()
|
|
8
7
|
};
|
|
9
8
|
});
|
|
10
|
-
|
|
11
9
|
jest.mock('store/index', function () {
|
|
12
10
|
return {
|
|
13
11
|
read: jest.fn(function () {
|
|
@@ -18,7 +16,6 @@ jest.mock('store/index', function () {
|
|
|
18
16
|
updateEntity: 'updateEntity'
|
|
19
17
|
};
|
|
20
18
|
});
|
|
21
|
-
|
|
22
19
|
jest.mock('../../core/index', function () {
|
|
23
20
|
return {
|
|
24
21
|
id: function id() {
|
|
@@ -37,12 +34,10 @@ jest.mock('../../core/index', function () {
|
|
|
37
34
|
setSuppressSubmitOverlay: jest.fn()
|
|
38
35
|
};
|
|
39
36
|
});
|
|
40
|
-
|
|
41
37
|
describe('quick-auth.actions', function () {
|
|
42
38
|
beforeEach(function () {
|
|
43
39
|
jest.clearAllMocks();
|
|
44
40
|
});
|
|
45
|
-
|
|
46
41
|
it('calls logIn with the correct parameters', function () {
|
|
47
42
|
var connection = {
|
|
48
43
|
get: jest.fn(function (key) {
|
|
@@ -54,15 +49,11 @@ describe('quick-auth.actions', function () {
|
|
|
54
49
|
}
|
|
55
50
|
})
|
|
56
51
|
};
|
|
57
|
-
|
|
58
52
|
(0, _actions.logIn)('id', connection, 'hint', 'prompt');
|
|
59
|
-
|
|
60
53
|
var coreActions = require('../../core/actions');
|
|
61
|
-
|
|
62
54
|
expect(coreActions.logIn.mock.calls.length).toBe(1);
|
|
63
55
|
expect(coreActions.logIn.mock.calls[0]).toMatchSnapshot();
|
|
64
56
|
});
|
|
65
|
-
|
|
66
57
|
it('sets display to "popup" when using facebook and there\'s no redirect', function () {
|
|
67
58
|
var connection = {
|
|
68
59
|
get: jest.fn(function (key) {
|
|
@@ -74,20 +65,15 @@ describe('quick-auth.actions', function () {
|
|
|
74
65
|
}
|
|
75
66
|
})
|
|
76
67
|
};
|
|
77
|
-
|
|
78
68
|
var core = require('../../core/index');
|
|
79
69
|
core.auth.redirect = jest.fn(function () {
|
|
80
70
|
return false;
|
|
81
71
|
});
|
|
82
|
-
|
|
83
72
|
(0, _actions.logIn)('id', connection);
|
|
84
|
-
|
|
85
73
|
var coreActions = require('../../core/actions');
|
|
86
|
-
|
|
87
74
|
expect(coreActions.logIn.mock.calls.length).toBe(1);
|
|
88
75
|
expect(coreActions.logIn.mock.calls[0]).toMatchSnapshot();
|
|
89
76
|
});
|
|
90
|
-
|
|
91
77
|
it('calls setSuppressSubmitOverlay with true when using Apple connection', function () {
|
|
92
78
|
var connection = {
|
|
93
79
|
get: jest.fn(function (key) {
|
|
@@ -99,19 +85,14 @@ describe('quick-auth.actions', function () {
|
|
|
99
85
|
}
|
|
100
86
|
})
|
|
101
87
|
};
|
|
102
|
-
|
|
103
88
|
(0, _actions.logIn)('id', connection);
|
|
104
|
-
|
|
105
89
|
var _require = require('store/index'),
|
|
106
|
-
|
|
107
|
-
|
|
90
|
+
swap = _require.swap;
|
|
108
91
|
var l = require('../../core/index');
|
|
109
|
-
|
|
110
92
|
expect(swap.mock.calls.length).toBe(1);
|
|
111
93
|
expect(swap.mock.calls[0][3]).toBe(l.setSupressSubmitOverlay);
|
|
112
94
|
expect(swap.mock.calls[0][4]).toBe(true);
|
|
113
95
|
});
|
|
114
|
-
|
|
115
96
|
it('calls setSuppressSubmitOverlay with false when not using Apple connection', function () {
|
|
116
97
|
var connection = {
|
|
117
98
|
get: jest.fn(function (key) {
|
|
@@ -123,14 +104,10 @@ describe('quick-auth.actions', function () {
|
|
|
123
104
|
}
|
|
124
105
|
})
|
|
125
106
|
};
|
|
126
|
-
|
|
127
107
|
(0, _actions.logIn)('id', connection);
|
|
128
|
-
|
|
129
108
|
var _require2 = require('store/index'),
|
|
130
|
-
|
|
131
|
-
|
|
109
|
+
swap = _require2.swap;
|
|
132
110
|
var l = require('../../core/index');
|
|
133
|
-
|
|
134
111
|
expect(swap.mock.calls.length).toBe(1);
|
|
135
112
|
expect(swap.mock.calls[0][3]).toBe(l.setSupressSubmitOverlay);
|
|
136
113
|
expect(swap.mock.calls[0][4]).toBe(false);
|
|
@@ -1,15 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var _enzyme = require('enzyme');
|
|
4
|
-
|
|
5
|
-
var _enzymeAdapterReact = require('enzyme-adapter-react-15');
|
|
6
|
-
|
|
7
|
-
var _enzymeAdapterReact2 = _interopRequireDefault(_enzymeAdapterReact);
|
|
1
|
+
"use strict";
|
|
8
2
|
|
|
3
|
+
var _enzyme = require("enzyme");
|
|
4
|
+
var _enzymeAdapterReact = _interopRequireDefault(require("@cfaester/enzyme-adapter-react-18"));
|
|
9
5
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
10
|
-
|
|
11
6
|
// setup file
|
|
12
|
-
|
|
7
|
+
|
|
8
|
+
(0, _enzyme.configure)({
|
|
9
|
+
adapter: new _enzymeAdapterReact.default()
|
|
10
|
+
});
|
|
13
11
|
|
|
14
12
|
//jest polyfills
|
|
15
13
|
window.requestAnimationFrame = function (callback) {
|
|
@@ -1,52 +1,46 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
var _react = require(
|
|
9
|
-
|
|
10
|
-
var
|
|
11
|
-
|
|
12
|
-
var
|
|
13
|
-
|
|
14
|
-
var _reactTestRenderer2 = _interopRequireDefault(_reactTestRenderer);
|
|
15
|
-
|
|
16
|
-
var _shallow = require('react-test-renderer/shallow');
|
|
17
|
-
|
|
18
|
-
var _shallow2 = _interopRequireDefault(_shallow);
|
|
19
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.setURL = exports.renderShallowComponent = exports.mockComponent = exports.extractPropsFromWrapper = exports.expectShallowComponent = exports.expectMockToMatch = exports.expectComponent = void 0;
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
var _reactTestRenderer = _interopRequireDefault(require("react-test-renderer"));
|
|
10
|
+
var _shallow = _interopRequireDefault(require("react-test-renderer/shallow"));
|
|
11
|
+
var _webpack = require("webpack");
|
|
12
|
+
var _excluded = ["children"];
|
|
20
13
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
21
|
-
|
|
22
|
-
function
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
var
|
|
26
|
-
|
|
14
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
15
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
16
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
17
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
18
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
19
|
+
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
20
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
21
|
+
var expectComponent = function expectComponent(children, opts) {
|
|
22
|
+
var component = _reactTestRenderer.default.create(children, opts);
|
|
27
23
|
return expect(component);
|
|
28
24
|
};
|
|
29
|
-
|
|
30
|
-
var expectShallowComponent =
|
|
25
|
+
exports.expectComponent = expectComponent;
|
|
26
|
+
var expectShallowComponent = function expectShallowComponent(children) {
|
|
31
27
|
var component = renderShallowComponent(children);
|
|
32
28
|
return expect(component);
|
|
33
29
|
};
|
|
34
|
-
|
|
35
|
-
var renderShallowComponent =
|
|
36
|
-
var renderer = new
|
|
37
|
-
|
|
30
|
+
exports.expectShallowComponent = expectShallowComponent;
|
|
31
|
+
var renderShallowComponent = function renderShallowComponent(children) {
|
|
32
|
+
var renderer = new _shallow.default();
|
|
38
33
|
renderer.render(children);
|
|
39
34
|
return renderer.getRenderOutput();
|
|
40
35
|
};
|
|
41
|
-
|
|
36
|
+
exports.renderShallowComponent = renderShallowComponent;
|
|
42
37
|
var addDataToProps = function addDataToProps(props) {
|
|
43
38
|
var returnedProps = {};
|
|
44
39
|
Object.keys(props).forEach(function (k) {
|
|
45
|
-
return returnedProps[
|
|
40
|
+
return returnedProps["data-".concat(k)] = props[k];
|
|
46
41
|
});
|
|
47
42
|
return returnedProps;
|
|
48
43
|
};
|
|
49
|
-
|
|
50
44
|
var removeDataFromProps = function removeDataFromProps(props) {
|
|
51
45
|
var returnedProps = {};
|
|
52
46
|
Object.keys(props).forEach(function (k) {
|
|
@@ -54,48 +48,37 @@ var removeDataFromProps = function removeDataFromProps(props) {
|
|
|
54
48
|
});
|
|
55
49
|
return returnedProps;
|
|
56
50
|
};
|
|
57
|
-
|
|
58
51
|
var mockComponent = function mockComponent(type) {
|
|
59
52
|
var domElement = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'div';
|
|
60
53
|
return function (_ref) {
|
|
61
54
|
var children = _ref.children,
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
return _react2.default.createElement(domElement, _extends({
|
|
55
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
56
|
+
return /*#__PURE__*/_react.default.createElement(domElement, _objectSpread({
|
|
65
57
|
'data-__type': type
|
|
66
58
|
}, addDataToProps(props)), children);
|
|
67
59
|
};
|
|
68
60
|
};
|
|
69
|
-
|
|
70
61
|
exports.mockComponent = mockComponent;
|
|
71
|
-
var extractPropsFromWrapper =
|
|
62
|
+
var extractPropsFromWrapper = function extractPropsFromWrapper(wrapper) {
|
|
72
63
|
var index = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
73
64
|
return removeDataFromProps(wrapper.find('div').at(index).props());
|
|
74
65
|
};
|
|
75
66
|
|
|
76
|
-
//
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
var value = parser[prop];
|
|
84
|
-
if (prop === 'origin' && options.noOrigin) {
|
|
85
|
-
value = null;
|
|
86
|
-
}
|
|
87
|
-
Object.defineProperty(window.location, prop, {
|
|
88
|
-
value: value,
|
|
89
|
-
writable: true
|
|
90
|
-
});
|
|
67
|
+
// Newer (> Jest v22) versions don't allow modification of location.href
|
|
68
|
+
// but can use `jsdom.reconfigure` when `jsdom` is exposed globally.
|
|
69
|
+
// https://www.npmjs.com/package/jest-environment-jsdom-global
|
|
70
|
+
exports.extractPropsFromWrapper = extractPropsFromWrapper;
|
|
71
|
+
var setURL = function setURL(url) {
|
|
72
|
+
jsdom.reconfigure({
|
|
73
|
+
url: url
|
|
91
74
|
});
|
|
92
75
|
};
|
|
93
|
-
|
|
94
|
-
var expectMockToMatch =
|
|
76
|
+
exports.setURL = setURL;
|
|
77
|
+
var expectMockToMatch = function expectMockToMatch(_ref2, numberOfCalls) {
|
|
95
78
|
var mock = _ref2.mock;
|
|
96
|
-
|
|
97
79
|
expect(mock.calls.length).toBe(numberOfCalls);
|
|
98
80
|
for (var i = 0; i < numberOfCalls; i++) {
|
|
99
81
|
expect(mock.calls[i]).toMatchSnapshot();
|
|
100
82
|
}
|
|
101
83
|
};
|
|
84
|
+
exports.expectMockToMatch = expectMockToMatch;
|
|
@@ -1,23 +1,18 @@
|
|
|
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 _immutable = require('immutable');
|
|
10
|
-
|
|
11
|
-
var _immutable2 = _interopRequireDefault(_immutable);
|
|
12
|
-
|
|
13
|
-
var _testUtils = require('testUtils');
|
|
1
|
+
"use strict";
|
|
14
2
|
|
|
3
|
+
var _react = _interopRequireDefault(require("react"));
|
|
4
|
+
var _immutable = _interopRequireDefault(require("immutable"));
|
|
5
|
+
var _testUtils = require("testUtils");
|
|
15
6
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
16
|
-
|
|
7
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
8
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
9
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
10
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
11
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
12
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
17
13
|
var getComponent = function getComponent() {
|
|
18
14
|
return require('ui/box/chrome').default;
|
|
19
15
|
};
|
|
20
|
-
|
|
21
16
|
jest.mock('ui/box/header', function () {
|
|
22
17
|
return (0, _testUtils.mockComponent)('header');
|
|
23
18
|
});
|
|
@@ -27,17 +22,13 @@ jest.mock('ui/box/multisize_slide', function () {
|
|
|
27
22
|
jest.mock('ui/box/global_message', function () {
|
|
28
23
|
return (0, _testUtils.mockComponent)('div');
|
|
29
24
|
});
|
|
30
|
-
|
|
31
25
|
var mockEventRegister = {};
|
|
32
|
-
|
|
33
26
|
var triggerEvent = function triggerEvent(name) {
|
|
34
27
|
if (name in mockEventRegister) {
|
|
35
28
|
return mockEventRegister[name]();
|
|
36
29
|
}
|
|
37
|
-
|
|
38
|
-
throw new Error('Unknown event \'' + name + '\'');
|
|
30
|
+
throw new Error("Unknown event '".concat(name, "'"));
|
|
39
31
|
};
|
|
40
|
-
|
|
41
32
|
jest.mock('core/index', function () {
|
|
42
33
|
return {
|
|
43
34
|
handleEvent: jest.fn(function (_, event, fn) {
|
|
@@ -51,11 +42,10 @@ jest.mock('core/index', function () {
|
|
|
51
42
|
})
|
|
52
43
|
};
|
|
53
44
|
});
|
|
54
|
-
|
|
55
45
|
var defaultProps = {
|
|
56
46
|
contentComponent: (0, _testUtils.mockComponent)('content'),
|
|
57
47
|
contentProps: {
|
|
58
|
-
model:
|
|
48
|
+
model: _immutable.default.fromJS({
|
|
59
49
|
id: '__lock_id__'
|
|
60
50
|
})
|
|
61
51
|
},
|
|
@@ -67,66 +57,51 @@ var defaultProps = {
|
|
|
67
57
|
classNames: '',
|
|
68
58
|
color: 'black'
|
|
69
59
|
};
|
|
70
|
-
|
|
71
60
|
describe('Chrome', function () {
|
|
72
|
-
var Chrome
|
|
73
|
-
|
|
61
|
+
var Chrome;
|
|
74
62
|
beforeEach(function () {
|
|
75
63
|
Chrome = getComponent();
|
|
76
64
|
Chrome.prototype.getHeaderSize = jest.fn(function () {
|
|
77
65
|
return 200;
|
|
78
66
|
});
|
|
79
|
-
|
|
80
67
|
mockEventRegister = {};
|
|
81
68
|
});
|
|
82
|
-
|
|
83
69
|
it('renders correctly with basic props', function () {
|
|
84
|
-
(0, _testUtils.expectComponent)(
|
|
70
|
+
(0, _testUtils.expectComponent)( /*#__PURE__*/_react.default.createElement(Chrome, defaultProps)).toMatchSnapshot();
|
|
85
71
|
});
|
|
86
|
-
|
|
87
72
|
it('renders correctly when there is a global message', function () {
|
|
88
|
-
var props =
|
|
73
|
+
var props = _objectSpread(_objectSpread({}, defaultProps), {}, {
|
|
89
74
|
error: 'There is an error'
|
|
90
75
|
});
|
|
91
|
-
|
|
92
|
-
(0, _testUtils.expectComponent)(_react2.default.createElement(Chrome, props)).toMatchSnapshot();
|
|
76
|
+
(0, _testUtils.expectComponent)( /*#__PURE__*/_react.default.createElement(Chrome, props)).toMatchSnapshot();
|
|
93
77
|
});
|
|
94
|
-
|
|
95
78
|
it('renders correctly when there is a global success message', function () {
|
|
96
|
-
var props =
|
|
79
|
+
var props = _objectSpread(_objectSpread({}, defaultProps), {}, {
|
|
97
80
|
success: 'This is a success message'
|
|
98
81
|
});
|
|
99
|
-
|
|
100
|
-
(0, _testUtils.expectComponent)(_react2.default.createElement(Chrome, props)).toMatchSnapshot();
|
|
82
|
+
(0, _testUtils.expectComponent)( /*#__PURE__*/_react.default.createElement(Chrome, props)).toMatchSnapshot();
|
|
101
83
|
});
|
|
102
|
-
|
|
103
84
|
it('renders correctly when there is a global information message', function () {
|
|
104
|
-
var props =
|
|
85
|
+
var props = _objectSpread(_objectSpread({}, defaultProps), {}, {
|
|
105
86
|
info: 'This is an information message'
|
|
106
87
|
});
|
|
107
|
-
|
|
108
|
-
(0, _testUtils.expectComponent)(_react2.default.createElement(Chrome, props)).toMatchSnapshot();
|
|
88
|
+
(0, _testUtils.expectComponent)( /*#__PURE__*/_react.default.createElement(Chrome, props)).toMatchSnapshot();
|
|
109
89
|
});
|
|
110
|
-
|
|
111
90
|
it('can dislay all global messages together', function () {
|
|
112
|
-
var props =
|
|
91
|
+
var props = _objectSpread(_objectSpread({}, defaultProps), {}, {
|
|
113
92
|
info: 'This is an information message',
|
|
114
93
|
success: 'This is a success message',
|
|
115
94
|
error: 'There is an error'
|
|
116
95
|
});
|
|
117
|
-
|
|
118
|
-
(0, _testUtils.expectComponent)(_react2.default.createElement(Chrome, props)).toMatchSnapshot();
|
|
96
|
+
(0, _testUtils.expectComponent)( /*#__PURE__*/_react.default.createElement(Chrome, props)).toMatchSnapshot();
|
|
119
97
|
});
|
|
120
|
-
|
|
121
98
|
it('adds the auto-height class when forceAutoHeight UI prop is true', function () {
|
|
122
99
|
require('core/index').ui.forceAutoHeight.mockReturnValue(true);
|
|
123
|
-
|
|
124
|
-
var props = _extends({}, defaultProps, {
|
|
100
|
+
var props = _objectSpread(_objectSpread({}, defaultProps), {}, {
|
|
125
101
|
info: 'This is an information message',
|
|
126
102
|
success: 'This is a success message',
|
|
127
103
|
error: 'There is an error'
|
|
128
104
|
});
|
|
129
|
-
|
|
130
|
-
(0, _testUtils.expectComponent)(_react2.default.createElement(Chrome, props)).toMatchSnapshot();
|
|
105
|
+
(0, _testUtils.expectComponent)( /*#__PURE__*/_react.default.createElement(Chrome, props)).toMatchSnapshot();
|
|
131
106
|
});
|
|
132
107
|
});
|