@aws-amplify/ui-react-core 1.0.1 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Authenticator/hooks/useAuthenticator/constants.js +1 -0
- package/dist/Authenticator/hooks/useAuthenticator/utils.js +3 -1
- package/dist/esm/Authenticator/hooks/useAuthenticator/constants.js +1 -0
- package/dist/esm/Authenticator/hooks/useAuthenticator/utils.js +3 -1
- package/dist/types/Authenticator/hooks/useAuthenticator/types.d.ts +1 -1
- package/package.json +4 -3
- package/dist/Authenticator/hooks/useAuthenticator/__tests__/useAuthenticator.spec.js +0 -70
- package/dist/Authenticator/hooks/useAuthenticator/__tests__/utils.spec.js +0 -79
- package/dist/esm/Authenticator/hooks/useAuthenticator/__tests__/useAuthenticator.spec.js +0 -67
- package/dist/esm/Authenticator/hooks/useAuthenticator/__tests__/utils.spec.js +0 -77
- package/dist/esm/utils/__tests__/index.spec.js +0 -23
- package/dist/types/Authenticator/hooks/useAuthenticator/__tests__/useAuthenticator.spec.d.ts +0 -1
- package/dist/types/Authenticator/hooks/useAuthenticator/__tests__/utils.spec.d.ts +0 -1
- package/dist/types/utils/__tests__/index.spec.d.ts +0 -1
- package/dist/utils/__tests__/index.spec.js +0 -25
|
@@ -45,7 +45,9 @@ const flattenFormFields = (fields) => fields.flatMap(([name, options]) => (Objec
|
|
|
45
45
|
/**
|
|
46
46
|
* Retrieves legacy form field values from state machine for routes that have fields
|
|
47
47
|
*/
|
|
48
|
-
const getLegacyFields = (route, state) =>
|
|
48
|
+
const getLegacyFields = (route, state) =>
|
|
49
|
+
// verifyUser is a component route, but does not have form fields
|
|
50
|
+
(0, exports.isComponentRouteKey)(route) && route !== 'verifyUser'
|
|
49
51
|
? flattenFormFields((0, ui_1.getSortedFormFields)(route, state))
|
|
50
52
|
: [];
|
|
51
53
|
exports.getLegacyFields = getLegacyFields;
|
|
@@ -37,6 +37,8 @@ const flattenFormFields = (fields) => fields.flatMap(([name, options]) => (Objec
|
|
|
37
37
|
/**
|
|
38
38
|
* Retrieves legacy form field values from state machine for routes that have fields
|
|
39
39
|
*/
|
|
40
|
-
export const getLegacyFields = (route, state) =>
|
|
40
|
+
export const getLegacyFields = (route, state) =>
|
|
41
|
+
// verifyUser is a component route, but does not have form fields
|
|
42
|
+
isComponentRouteKey(route) && route !== 'verifyUser'
|
|
41
43
|
? flattenFormFields(getSortedFormFields(route, state))
|
|
42
44
|
: [];
|
|
@@ -5,7 +5,7 @@ import { AuthMachineSend, AuthMachineState, AuthenticatorServiceFacade, LegacyFo
|
|
|
5
5
|
*/
|
|
6
6
|
declare type AuthenticatorMachineContext = AuthenticatorServiceFacade;
|
|
7
7
|
declare type AuthenticatorMachineContextKey = keyof AuthenticatorMachineContext;
|
|
8
|
-
export declare type AuthenticatorRouteComponentKey = 'signIn' | 'signUp' | 'forceNewPassword' | 'confirmResetPassword' | 'confirmSignIn' | 'confirmSignUp' | 'confirmVerifyUser' | 'resetPassword' | 'setupTOTP';
|
|
8
|
+
export declare type AuthenticatorRouteComponentKey = 'signIn' | 'signUp' | 'forceNewPassword' | 'confirmResetPassword' | 'confirmSignIn' | 'confirmSignUp' | 'confirmVerifyUser' | 'resetPassword' | 'setupTOTP' | 'verifyUser';
|
|
9
9
|
export declare type AuthenticatorLegacyFields = LegacyFormFieldOptions[];
|
|
10
10
|
/**
|
|
11
11
|
* Inspired from https://xstate.js.org/docs/packages/xstate-react/#useselector-actor-selector-compare-getsnapshot.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aws-amplify/ui-react-core",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"module": "dist/esm/index.js",
|
|
6
6
|
"exports": {
|
|
@@ -28,8 +28,9 @@
|
|
|
28
28
|
"test:watch": "yarn test --watch"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@aws-amplify/ui": "
|
|
32
|
-
"@xstate/react": "3.0.
|
|
31
|
+
"@aws-amplify/ui": "4.0.0",
|
|
32
|
+
"@xstate/react": "3.0.1",
|
|
33
|
+
"xstate": "^4.33.6"
|
|
33
34
|
},
|
|
34
35
|
"peerDependencies": {
|
|
35
36
|
"aws-amplify": "3.x.x || 4.x.x",
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
|
-
const react_1 = tslib_1.__importDefault(require("react"));
|
|
5
|
-
const react_hooks_1 = require("@testing-library/react-hooks");
|
|
6
|
-
const UIModule = tslib_1.__importStar(require("@aws-amplify/ui"));
|
|
7
|
-
const context_1 = require("../../../context");
|
|
8
|
-
const constants_1 = require("../constants");
|
|
9
|
-
const utils = tslib_1.__importStar(require("../utils"));
|
|
10
|
-
const __1 = require("..");
|
|
11
|
-
const mockServiceFacade = {
|
|
12
|
-
authStatus: 'authenticated',
|
|
13
|
-
codeDeliveryDetails: {},
|
|
14
|
-
error: undefined,
|
|
15
|
-
hasValidationErrors: false,
|
|
16
|
-
isPending: false,
|
|
17
|
-
route: 'idle',
|
|
18
|
-
socialProviders: [],
|
|
19
|
-
unverifiedContactMethods: [],
|
|
20
|
-
user: {},
|
|
21
|
-
validationErrors: undefined,
|
|
22
|
-
initializeMachine: jest.fn,
|
|
23
|
-
resendCode: jest.fn,
|
|
24
|
-
signOut: jest.fn,
|
|
25
|
-
submitForm: jest.fn,
|
|
26
|
-
updateForm: jest.fn,
|
|
27
|
-
updateBlur: jest.fn,
|
|
28
|
-
toFederatedSignIn: jest.fn,
|
|
29
|
-
toResetPassword: jest.fn,
|
|
30
|
-
toSignIn: jest.fn,
|
|
31
|
-
toSignUp: jest.fn,
|
|
32
|
-
skipVerification: jest.fn,
|
|
33
|
-
};
|
|
34
|
-
const getServiceFacadeSpy = jest
|
|
35
|
-
.spyOn(UIModule, 'getServiceFacade')
|
|
36
|
-
.mockReturnValue(mockServiceFacade);
|
|
37
|
-
// test setup
|
|
38
|
-
jest.mock('@xstate/react', () => (Object.assign(Object.assign({}, jest.requireActual('@xstate/react')), { useSelector: jest.fn((_, selector) => selector()) })));
|
|
39
|
-
// mock `aws-amplify` to prevent logging auth errors during test runs
|
|
40
|
-
jest.mock('aws-amplify');
|
|
41
|
-
jest.mock('../utils');
|
|
42
|
-
const getComparatorSpy = jest.spyOn(utils, 'getComparator');
|
|
43
|
-
const Wrapper = ({ children }) => (react_1.default.createElement(context_1.AuthenticatorProvider, null, children));
|
|
44
|
-
describe('useAuthenticator', () => {
|
|
45
|
-
beforeEach(() => {
|
|
46
|
-
getComparatorSpy.mockClear();
|
|
47
|
-
getServiceFacadeSpy.mockClear();
|
|
48
|
-
});
|
|
49
|
-
it('throws an error when used outside an AuthenticatorProvider', () => {
|
|
50
|
-
var _a;
|
|
51
|
-
const { result } = (0, react_hooks_1.renderHook)(__1.useAuthenticator);
|
|
52
|
-
expect((_a = result.error) === null || _a === void 0 ? void 0 : _a.message).toBe(constants_1.USE_AUTHENTICATOR_ERROR);
|
|
53
|
-
});
|
|
54
|
-
it('returns the expected values', () => {
|
|
55
|
-
const { result } = (0, react_hooks_1.renderHook)(__1.useAuthenticator, {
|
|
56
|
-
wrapper: Wrapper,
|
|
57
|
-
});
|
|
58
|
-
expect(getServiceFacadeSpy).toHaveBeenCalled();
|
|
59
|
-
expect(result.current).toMatchSnapshot();
|
|
60
|
-
});
|
|
61
|
-
it('calls getComparator with the selector argument', () => {
|
|
62
|
-
const mockSelector = jest.fn();
|
|
63
|
-
(0, react_hooks_1.renderHook)(() => (0, __1.useAuthenticator)(mockSelector), { wrapper: Wrapper });
|
|
64
|
-
expect(getComparatorSpy).toHaveBeenLastCalledWith(mockSelector);
|
|
65
|
-
});
|
|
66
|
-
it('does not call getComparator when no selector argument passed', () => {
|
|
67
|
-
(0, react_hooks_1.renderHook)(__1.useAuthenticator, { wrapper: Wrapper });
|
|
68
|
-
expect(getComparatorSpy).not.toBeCalled();
|
|
69
|
-
});
|
|
70
|
-
});
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
|
-
const aws_amplify_1 = require("aws-amplify");
|
|
5
|
-
const UIModule = tslib_1.__importStar(require("@aws-amplify/ui"));
|
|
6
|
-
const constants_1 = require("../constants");
|
|
7
|
-
const utils_1 = require("../utils");
|
|
8
|
-
const setupTOTPSpy = jest.spyOn(aws_amplify_1.Auth, 'setupTOTP').mockImplementation();
|
|
9
|
-
const getSortedFormFieldsSpy = jest
|
|
10
|
-
.spyOn(UIModule, 'getSortedFormFields')
|
|
11
|
-
.mockImplementation(() => [['name', { required: true }]]);
|
|
12
|
-
describe('areSelectorDepsEqual', () => {
|
|
13
|
-
it('returns false when dep arrays have different lengths', () => {
|
|
14
|
-
const output = (0, utils_1.areSelectorDepsEqual)([0, {}], [0]);
|
|
15
|
-
expect(output).toBe(false);
|
|
16
|
-
});
|
|
17
|
-
it('returns false when comparing an empty array and an empty object', () => {
|
|
18
|
-
const output = (0, utils_1.areSelectorDepsEqual)([{}], [[]]);
|
|
19
|
-
expect(output).toBe(false);
|
|
20
|
-
});
|
|
21
|
-
it('returns false when dep arrays have similar object values', () => {
|
|
22
|
-
const output = (0, utils_1.areSelectorDepsEqual)([0, { id: 4 }], [0, { id: 4 }]);
|
|
23
|
-
expect(output).toBe(false);
|
|
24
|
-
});
|
|
25
|
-
it('returns false when nested object values are different', () => {
|
|
26
|
-
const output = (0, utils_1.areSelectorDepsEqual)([0, { options: {} }], [0, { options: {} }]);
|
|
27
|
-
expect(output).toBe(false);
|
|
28
|
-
});
|
|
29
|
-
it('returns true when arrays are equal length and have same deps', () => {
|
|
30
|
-
const output = (0, utils_1.areSelectorDepsEqual)([{}, 0], [{}, 0]);
|
|
31
|
-
expect(output).toBe(true);
|
|
32
|
-
});
|
|
33
|
-
});
|
|
34
|
-
describe('getComparator', () => {
|
|
35
|
-
it('returns a comparator that compares arrays', () => {
|
|
36
|
-
const comparator = (0, utils_1.getComparator)(({ route }) => [route]);
|
|
37
|
-
expect(comparator).toEqual(expect.any(Function));
|
|
38
|
-
expect(comparator({ route: 'autoSignIn' }, { route: 'confirmSignIn' })).toBe(false);
|
|
39
|
-
expect(comparator({ route: 'idle' }, { route: 'idle' })).toBe(true);
|
|
40
|
-
});
|
|
41
|
-
});
|
|
42
|
-
describe('defaultComparator', () => {
|
|
43
|
-
it('returns false', () => {
|
|
44
|
-
expect((0, utils_1.defaultComparator)()).toBe(false);
|
|
45
|
-
});
|
|
46
|
-
});
|
|
47
|
-
describe('isComponentRouteKey', () => {
|
|
48
|
-
it.each(constants_1.COMPONENT_ROUTE_KEYS)('returns true for a %s value', (route) => {
|
|
49
|
-
const output = (0, utils_1.isComponentRouteKey)(route);
|
|
50
|
-
expect(output).toBe(true);
|
|
51
|
-
});
|
|
52
|
-
it('returns false for a non-component route key value', () => {
|
|
53
|
-
const output = (0, utils_1.isComponentRouteKey)('route');
|
|
54
|
-
expect(output).toBe(false);
|
|
55
|
-
});
|
|
56
|
-
});
|
|
57
|
-
describe('getTotpSecretCodeCallback', () => {
|
|
58
|
-
const user = {};
|
|
59
|
-
it('returns a getTotpSecretCode function', () => {
|
|
60
|
-
const getTotpSecretCode = (0, utils_1.getTotpSecretCodeCallback)(user);
|
|
61
|
-
expect(getTotpSecretCode).toStrictEqual(expect.any(Function));
|
|
62
|
-
});
|
|
63
|
-
it('returns a function that calls Auth.setupTOTP with the user', () => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
64
|
-
const getTotpSecretCode = (0, utils_1.getTotpSecretCodeCallback)(user);
|
|
65
|
-
yield getTotpSecretCode();
|
|
66
|
-
expect(setupTOTPSpy).toBeCalledWith(user);
|
|
67
|
-
}));
|
|
68
|
-
});
|
|
69
|
-
describe('getLegacyFields', () => {
|
|
70
|
-
const state = {};
|
|
71
|
-
it('calls getSortedFormFields when route is a valid component route', () => {
|
|
72
|
-
(0, utils_1.getLegacyFields)('signIn', state);
|
|
73
|
-
expect(getSortedFormFieldsSpy).toHaveBeenCalledWith('signIn', state);
|
|
74
|
-
});
|
|
75
|
-
it('returns an empty array for a non-component route', () => {
|
|
76
|
-
const output = (0, utils_1.getLegacyFields)('idle', state);
|
|
77
|
-
expect(output).toHaveLength(0);
|
|
78
|
-
});
|
|
79
|
-
});
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { renderHook } from '@testing-library/react-hooks';
|
|
3
|
-
import * as UIModule from '@aws-amplify/ui';
|
|
4
|
-
import { AuthenticatorProvider } from '../../../context';
|
|
5
|
-
import { USE_AUTHENTICATOR_ERROR } from '../constants';
|
|
6
|
-
import * as utils from '../utils';
|
|
7
|
-
import { useAuthenticator } from '..';
|
|
8
|
-
const mockServiceFacade = {
|
|
9
|
-
authStatus: 'authenticated',
|
|
10
|
-
codeDeliveryDetails: {},
|
|
11
|
-
error: undefined,
|
|
12
|
-
hasValidationErrors: false,
|
|
13
|
-
isPending: false,
|
|
14
|
-
route: 'idle',
|
|
15
|
-
socialProviders: [],
|
|
16
|
-
unverifiedContactMethods: [],
|
|
17
|
-
user: {},
|
|
18
|
-
validationErrors: undefined,
|
|
19
|
-
initializeMachine: jest.fn,
|
|
20
|
-
resendCode: jest.fn,
|
|
21
|
-
signOut: jest.fn,
|
|
22
|
-
submitForm: jest.fn,
|
|
23
|
-
updateForm: jest.fn,
|
|
24
|
-
updateBlur: jest.fn,
|
|
25
|
-
toFederatedSignIn: jest.fn,
|
|
26
|
-
toResetPassword: jest.fn,
|
|
27
|
-
toSignIn: jest.fn,
|
|
28
|
-
toSignUp: jest.fn,
|
|
29
|
-
skipVerification: jest.fn,
|
|
30
|
-
};
|
|
31
|
-
const getServiceFacadeSpy = jest
|
|
32
|
-
.spyOn(UIModule, 'getServiceFacade')
|
|
33
|
-
.mockReturnValue(mockServiceFacade);
|
|
34
|
-
// test setup
|
|
35
|
-
jest.mock('@xstate/react', () => (Object.assign(Object.assign({}, jest.requireActual('@xstate/react')), { useSelector: jest.fn((_, selector) => selector()) })));
|
|
36
|
-
// mock `aws-amplify` to prevent logging auth errors during test runs
|
|
37
|
-
jest.mock('aws-amplify');
|
|
38
|
-
jest.mock('../utils');
|
|
39
|
-
const getComparatorSpy = jest.spyOn(utils, 'getComparator');
|
|
40
|
-
const Wrapper = ({ children }) => (React.createElement(AuthenticatorProvider, null, children));
|
|
41
|
-
describe('useAuthenticator', () => {
|
|
42
|
-
beforeEach(() => {
|
|
43
|
-
getComparatorSpy.mockClear();
|
|
44
|
-
getServiceFacadeSpy.mockClear();
|
|
45
|
-
});
|
|
46
|
-
it('throws an error when used outside an AuthenticatorProvider', () => {
|
|
47
|
-
var _a;
|
|
48
|
-
const { result } = renderHook(useAuthenticator);
|
|
49
|
-
expect((_a = result.error) === null || _a === void 0 ? void 0 : _a.message).toBe(USE_AUTHENTICATOR_ERROR);
|
|
50
|
-
});
|
|
51
|
-
it('returns the expected values', () => {
|
|
52
|
-
const { result } = renderHook(useAuthenticator, {
|
|
53
|
-
wrapper: Wrapper,
|
|
54
|
-
});
|
|
55
|
-
expect(getServiceFacadeSpy).toHaveBeenCalled();
|
|
56
|
-
expect(result.current).toMatchSnapshot();
|
|
57
|
-
});
|
|
58
|
-
it('calls getComparator with the selector argument', () => {
|
|
59
|
-
const mockSelector = jest.fn();
|
|
60
|
-
renderHook(() => useAuthenticator(mockSelector), { wrapper: Wrapper });
|
|
61
|
-
expect(getComparatorSpy).toHaveBeenLastCalledWith(mockSelector);
|
|
62
|
-
});
|
|
63
|
-
it('does not call getComparator when no selector argument passed', () => {
|
|
64
|
-
renderHook(useAuthenticator, { wrapper: Wrapper });
|
|
65
|
-
expect(getComparatorSpy).not.toBeCalled();
|
|
66
|
-
});
|
|
67
|
-
});
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import { __awaiter } from "tslib";
|
|
2
|
-
import { Auth } from 'aws-amplify';
|
|
3
|
-
import * as UIModule from '@aws-amplify/ui';
|
|
4
|
-
import { COMPONENT_ROUTE_KEYS } from '../constants';
|
|
5
|
-
import { areSelectorDepsEqual, defaultComparator, getComparator, getLegacyFields, getTotpSecretCodeCallback, isComponentRouteKey, } from '../utils';
|
|
6
|
-
const setupTOTPSpy = jest.spyOn(Auth, 'setupTOTP').mockImplementation();
|
|
7
|
-
const getSortedFormFieldsSpy = jest
|
|
8
|
-
.spyOn(UIModule, 'getSortedFormFields')
|
|
9
|
-
.mockImplementation(() => [['name', { required: true }]]);
|
|
10
|
-
describe('areSelectorDepsEqual', () => {
|
|
11
|
-
it('returns false when dep arrays have different lengths', () => {
|
|
12
|
-
const output = areSelectorDepsEqual([0, {}], [0]);
|
|
13
|
-
expect(output).toBe(false);
|
|
14
|
-
});
|
|
15
|
-
it('returns false when comparing an empty array and an empty object', () => {
|
|
16
|
-
const output = areSelectorDepsEqual([{}], [[]]);
|
|
17
|
-
expect(output).toBe(false);
|
|
18
|
-
});
|
|
19
|
-
it('returns false when dep arrays have similar object values', () => {
|
|
20
|
-
const output = areSelectorDepsEqual([0, { id: 4 }], [0, { id: 4 }]);
|
|
21
|
-
expect(output).toBe(false);
|
|
22
|
-
});
|
|
23
|
-
it('returns false when nested object values are different', () => {
|
|
24
|
-
const output = areSelectorDepsEqual([0, { options: {} }], [0, { options: {} }]);
|
|
25
|
-
expect(output).toBe(false);
|
|
26
|
-
});
|
|
27
|
-
it('returns true when arrays are equal length and have same deps', () => {
|
|
28
|
-
const output = areSelectorDepsEqual([{}, 0], [{}, 0]);
|
|
29
|
-
expect(output).toBe(true);
|
|
30
|
-
});
|
|
31
|
-
});
|
|
32
|
-
describe('getComparator', () => {
|
|
33
|
-
it('returns a comparator that compares arrays', () => {
|
|
34
|
-
const comparator = getComparator(({ route }) => [route]);
|
|
35
|
-
expect(comparator).toEqual(expect.any(Function));
|
|
36
|
-
expect(comparator({ route: 'autoSignIn' }, { route: 'confirmSignIn' })).toBe(false);
|
|
37
|
-
expect(comparator({ route: 'idle' }, { route: 'idle' })).toBe(true);
|
|
38
|
-
});
|
|
39
|
-
});
|
|
40
|
-
describe('defaultComparator', () => {
|
|
41
|
-
it('returns false', () => {
|
|
42
|
-
expect(defaultComparator()).toBe(false);
|
|
43
|
-
});
|
|
44
|
-
});
|
|
45
|
-
describe('isComponentRouteKey', () => {
|
|
46
|
-
it.each(COMPONENT_ROUTE_KEYS)('returns true for a %s value', (route) => {
|
|
47
|
-
const output = isComponentRouteKey(route);
|
|
48
|
-
expect(output).toBe(true);
|
|
49
|
-
});
|
|
50
|
-
it('returns false for a non-component route key value', () => {
|
|
51
|
-
const output = isComponentRouteKey('route');
|
|
52
|
-
expect(output).toBe(false);
|
|
53
|
-
});
|
|
54
|
-
});
|
|
55
|
-
describe('getTotpSecretCodeCallback', () => {
|
|
56
|
-
const user = {};
|
|
57
|
-
it('returns a getTotpSecretCode function', () => {
|
|
58
|
-
const getTotpSecretCode = getTotpSecretCodeCallback(user);
|
|
59
|
-
expect(getTotpSecretCode).toStrictEqual(expect.any(Function));
|
|
60
|
-
});
|
|
61
|
-
it('returns a function that calls Auth.setupTOTP with the user', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
62
|
-
const getTotpSecretCode = getTotpSecretCodeCallback(user);
|
|
63
|
-
yield getTotpSecretCode();
|
|
64
|
-
expect(setupTOTPSpy).toBeCalledWith(user);
|
|
65
|
-
}));
|
|
66
|
-
});
|
|
67
|
-
describe('getLegacyFields', () => {
|
|
68
|
-
const state = {};
|
|
69
|
-
it('calls getSortedFormFields when route is a valid component route', () => {
|
|
70
|
-
getLegacyFields('signIn', state);
|
|
71
|
-
expect(getSortedFormFieldsSpy).toHaveBeenCalledWith('signIn', state);
|
|
72
|
-
});
|
|
73
|
-
it('returns an empty array for a non-component route', () => {
|
|
74
|
-
const output = getLegacyFields('idle', state);
|
|
75
|
-
expect(output).toHaveLength(0);
|
|
76
|
-
});
|
|
77
|
-
});
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { areEmptyArrays, areEmptyObjects } from '..';
|
|
2
|
-
const validArrays = [[], [], [], []];
|
|
3
|
-
const invalidArrays = [[7]];
|
|
4
|
-
const validObjects = [{}, {}];
|
|
5
|
-
const invalidObjects = [{ id: 7 }, {}, {}];
|
|
6
|
-
describe('areEmptyArrays', () => {
|
|
7
|
-
it.each([
|
|
8
|
-
[true, validArrays],
|
|
9
|
-
[false, invalidArrays],
|
|
10
|
-
])('returns %s as expected', (expected, input) => {
|
|
11
|
-
const output = areEmptyArrays(...input);
|
|
12
|
-
expect(output).toBe(expected);
|
|
13
|
-
});
|
|
14
|
-
});
|
|
15
|
-
describe('areEmptyObjects', () => {
|
|
16
|
-
it.each([
|
|
17
|
-
[true, validObjects],
|
|
18
|
-
[false, invalidObjects],
|
|
19
|
-
])('returns %s as expected', (expected, input) => {
|
|
20
|
-
const output = areEmptyObjects(...input);
|
|
21
|
-
expect(output).toBe(expected);
|
|
22
|
-
});
|
|
23
|
-
});
|
package/dist/types/Authenticator/hooks/useAuthenticator/__tests__/useAuthenticator.spec.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const __1 = require("..");
|
|
4
|
-
const validArrays = [[], [], [], []];
|
|
5
|
-
const invalidArrays = [[7]];
|
|
6
|
-
const validObjects = [{}, {}];
|
|
7
|
-
const invalidObjects = [{ id: 7 }, {}, {}];
|
|
8
|
-
describe('areEmptyArrays', () => {
|
|
9
|
-
it.each([
|
|
10
|
-
[true, validArrays],
|
|
11
|
-
[false, invalidArrays],
|
|
12
|
-
])('returns %s as expected', (expected, input) => {
|
|
13
|
-
const output = (0, __1.areEmptyArrays)(...input);
|
|
14
|
-
expect(output).toBe(expected);
|
|
15
|
-
});
|
|
16
|
-
});
|
|
17
|
-
describe('areEmptyObjects', () => {
|
|
18
|
-
it.each([
|
|
19
|
-
[true, validObjects],
|
|
20
|
-
[false, invalidObjects],
|
|
21
|
-
])('returns %s as expected', (expected, input) => {
|
|
22
|
-
const output = (0, __1.areEmptyObjects)(...input);
|
|
23
|
-
expect(output).toBe(expected);
|
|
24
|
-
});
|
|
25
|
-
});
|