@ukhomeoffice/cop-react-form-renderer 5.20.1 → 5.23.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/CheckYourAnswers/Answer.test.js +1 -1
- package/dist/components/CheckYourAnswers/CheckYourAnswers.test.js +1 -1
- package/dist/components/CollectionPage/CollectionPage.js +26 -10
- package/dist/components/CollectionPage/CollectionPage.test.js +256 -107
- package/dist/components/FormComponent/Collection.js +1 -1
- package/dist/components/FormComponent/Collection.test.js +1 -1
- package/dist/components/FormComponent/Container.test.js +1 -1
- package/dist/components/FormComponent/FormComponent.test.js +1 -1
- package/dist/components/FormPage/FormPage.test.js +1 -1
- package/dist/components/FormRenderer/FormRenderer.test.js +1 -1
- package/dist/components/FormRenderer/onCYAAction.js +59 -60
- package/dist/components/FormRenderer/onCYAAction.test.js +31 -0
- package/dist/components/FormRenderer/onPageAction.js +1 -1
- package/dist/components/FormRenderer/onPageAction.test.js +12 -0
- package/dist/components/PageActions/ActionButton.test.js +1 -1
- package/dist/components/PageActions/PageActions.test.js +1 -1
- package/dist/context/HooksContext/HooksContext.test.js +1 -1
- package/dist/context/ValidationContext/ValidationContext.js +1 -1
- package/dist/context/ValidationContext/ValidationContext.test.js +1 -1
- package/dist/hooks/useAxios.js +1 -1
- package/dist/hooks/useGetRequest.js +1 -1
- package/dist/utils/CollectionPage/addCollectionPageEntry.js +22 -0
- package/dist/utils/CollectionPage/addCollectionPageEntry.test.js +16 -0
- package/dist/utils/CollectionPage/duplicateCollectionPageActiveEntry.js +9 -4
- package/dist/utils/CollectionPage/duplicateCollectionPageActiveEntry.test.js +30 -0
- package/dist/utils/CollectionPage/getCollectionPageActiveId.js +24 -0
- package/dist/utils/CollectionPage/getCollectionPageActiveId.test.js +25 -0
- package/dist/utils/CollectionPage/getCollectionPageActiveIndex.js +35 -15
- package/dist/utils/CollectionPage/getCollectionPageActiveIndex.test.js +34 -0
- package/dist/utils/CollectionPage/getCollectionPageData.js +57 -0
- package/dist/utils/CollectionPage/getCollectionPageData.test.js +102 -0
- package/dist/utils/CollectionPage/index.js +9 -1
- package/dist/utils/CollectionPage/setCollectionPageData.js +52 -0
- package/dist/utils/CollectionPage/setCollectionPageData.test.js +112 -0
- package/dist/utils/Component/getComponentTests/getComponent.calculation.test.js +1 -1
- package/dist/utils/Component/getComponentTests/getComponent.nested.test.js +1 -1
- package/dist/utils/Validate/additional/mustBeEarlierDateTime.js +8 -3
- package/dist/utils/Validate/additional/mustBeEarlierDateTime.test.js +21 -0
- package/dist/utils/Validate/validatePage.js +2 -2
- package/dist/utils/Validate/validatePage.test.js +268 -18
- package/package.json +2 -2
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _getCollectionPageActiveId = _interopRequireDefault(require("./getCollectionPageActiveId"));
|
|
4
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
5
|
+
describe('Utils.CollectionPage.getCollectionPageActiveId', function () {
|
|
6
|
+
it('should return null if no active ID exists for the collection', function () {
|
|
7
|
+
var FORM_DATA = {};
|
|
8
|
+
var activeId = (0, _getCollectionPageActiveId.default)('testCollection', FORM_DATA);
|
|
9
|
+
expect(activeId).toEqual(null);
|
|
10
|
+
});
|
|
11
|
+
it('should correctly get an existing active ID for a top-level collection name', function () {
|
|
12
|
+
var FORM_DATA = {
|
|
13
|
+
testCollectionActiveId: '1'
|
|
14
|
+
};
|
|
15
|
+
var activeId = (0, _getCollectionPageActiveId.default)('testCollection', FORM_DATA);
|
|
16
|
+
expect(activeId).toEqual(FORM_DATA.testCollectionActiveId);
|
|
17
|
+
});
|
|
18
|
+
it('should correctly get an existing active ID for a nested collection name', function () {
|
|
19
|
+
var FORM_DATA = {
|
|
20
|
+
grandchildActiveId: '1'
|
|
21
|
+
};
|
|
22
|
+
var activeId = (0, _getCollectionPageActiveId.default)('parent.child.grandchild', FORM_DATA);
|
|
23
|
+
expect(activeId).toEqual(FORM_DATA.grandchildActiveId);
|
|
24
|
+
});
|
|
25
|
+
});
|
|
@@ -4,25 +4,45 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
var
|
|
14
|
-
|
|
15
|
-
if (!collectionName) {
|
|
7
|
+
var isValidIndex = function isValidIndex(value) {
|
|
8
|
+
return typeof value === 'number' && value >= 0;
|
|
9
|
+
};
|
|
10
|
+
var getLastActiveIndexInChain = function getLastActiveIndexInChain(collectionNames, data, formData) {
|
|
11
|
+
var _data$currentName;
|
|
12
|
+
var currentName = collectionNames[0];
|
|
13
|
+
var activeId = (formData === null || formData === void 0 ? void 0 : formData["".concat(currentName, "ActiveId")]) || null;
|
|
14
|
+
if (!activeId) {
|
|
16
15
|
return null;
|
|
17
16
|
}
|
|
18
|
-
var
|
|
19
|
-
|
|
17
|
+
var activeIndex = (_data$currentName = data[currentName]) === null || _data$currentName === void 0 ? void 0 : _data$currentName.findIndex(function (item) {
|
|
18
|
+
return item.id === activeId;
|
|
19
|
+
});
|
|
20
|
+
if (!isValidIndex(activeIndex)) {
|
|
20
21
|
return null;
|
|
21
22
|
}
|
|
22
|
-
|
|
23
|
-
return
|
|
24
|
-
}
|
|
25
|
-
|
|
23
|
+
if (collectionNames.length === 1) {
|
|
24
|
+
return activeIndex;
|
|
25
|
+
}
|
|
26
|
+
collectionNames.shift();
|
|
27
|
+
return getLastActiveIndexInChain(collectionNames, data[currentName][activeIndex], formData);
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Takes the name of a collection and returns its active index.
|
|
32
|
+
* This function supports collectionName being a dot-separated string
|
|
33
|
+
* of collection names for nested collections:
|
|
34
|
+
*
|
|
35
|
+
* e.g. collectionName being 'flights.people.documents' would return
|
|
36
|
+
* the active index in the nested documents collection, or null if there
|
|
37
|
+
* isn't one or the path is broken.
|
|
38
|
+
*
|
|
39
|
+
* @param {string} collectionName The name of the collection, or dot-separated path.
|
|
40
|
+
* @param {object} data Top-level formData.
|
|
41
|
+
* @returns The active index for the collection, or null if it doesn't exist.
|
|
42
|
+
*/
|
|
43
|
+
var getCollectionPageActiveIndex = function getCollectionPageActiveIndex(collectionName, formData) {
|
|
44
|
+
var nameParts = collectionName.split('.');
|
|
45
|
+
return getLastActiveIndexInChain(nameParts, formData, formData);
|
|
26
46
|
};
|
|
27
47
|
var _default = getCollectionPageActiveIndex;
|
|
28
48
|
exports.default = _default;
|
|
@@ -24,6 +24,24 @@ describe('utils.CollectionPage.getCollectionPageActiveIndex', function () {
|
|
|
24
24
|
};
|
|
25
25
|
expect((0, _getCollectionPageActiveIndex.default)(PAGE.collection.name, PAGE.formData)).toEqual(1);
|
|
26
26
|
});
|
|
27
|
+
it('should return the index of the active item in the nested collection, if one exists', function () {
|
|
28
|
+
var COLLECTION_NAME = 'parent.child';
|
|
29
|
+
var ACTIVE_ID = '001';
|
|
30
|
+
var FORM_DATA = {
|
|
31
|
+
parentActiveId: '001',
|
|
32
|
+
childActiveId: ACTIVE_ID,
|
|
33
|
+
parent: [{
|
|
34
|
+
id: '001',
|
|
35
|
+
child: [{
|
|
36
|
+
id: '001',
|
|
37
|
+
value: 'Alpha'
|
|
38
|
+
}]
|
|
39
|
+
}, {
|
|
40
|
+
id: '002'
|
|
41
|
+
}]
|
|
42
|
+
};
|
|
43
|
+
expect((0, _getCollectionPageActiveIndex.default)(COLLECTION_NAME, FORM_DATA)).toEqual(0);
|
|
44
|
+
});
|
|
27
45
|
it('should return null if no active item can be found in the collection', function () {
|
|
28
46
|
var COLLECTION_NAME = 'test';
|
|
29
47
|
var ACTIVE_ID = '002';
|
|
@@ -41,6 +59,22 @@ describe('utils.CollectionPage.getCollectionPageActiveIndex', function () {
|
|
|
41
59
|
};
|
|
42
60
|
expect((0, _getCollectionPageActiveIndex.default)(PAGE.collection.name, PAGE.formData)).toEqual(null);
|
|
43
61
|
});
|
|
62
|
+
it('should return null if no active item can be found in the nested collection', function () {
|
|
63
|
+
var COLLECTION_NAME = 'parent.child';
|
|
64
|
+
var ACTIVE_ID = '002';
|
|
65
|
+
var FORM_DATA = {
|
|
66
|
+
parentActiveId: '001',
|
|
67
|
+
childActiveId: ACTIVE_ID,
|
|
68
|
+
parent: [{
|
|
69
|
+
id: '001',
|
|
70
|
+
child: [{
|
|
71
|
+
id: '001',
|
|
72
|
+
value: 'Alpha'
|
|
73
|
+
}]
|
|
74
|
+
}]
|
|
75
|
+
};
|
|
76
|
+
expect((0, _getCollectionPageActiveIndex.default)(COLLECTION_NAME, FORM_DATA)).toEqual(null);
|
|
77
|
+
});
|
|
44
78
|
it('should return null if formData is null', function () {
|
|
45
79
|
var COLLECTION_NAME = 'test';
|
|
46
80
|
var PAGE = {
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var isValidIndex = function isValidIndex(value) {
|
|
8
|
+
return typeof value === 'number' && value >= 0;
|
|
9
|
+
};
|
|
10
|
+
var getLastDataInChain = function getLastDataInChain(collectionNames, data, formData) {
|
|
11
|
+
var _data$currentName;
|
|
12
|
+
var currentName = collectionNames[0];
|
|
13
|
+
// If we're at the last collection in the chain, then just
|
|
14
|
+
// try and grab its data.
|
|
15
|
+
if (collectionNames.length === 1) {
|
|
16
|
+
return data[currentName] || null;
|
|
17
|
+
}
|
|
18
|
+
var activeId = (formData === null || formData === void 0 ? void 0 : formData["".concat(currentName, "ActiveId")]) || null;
|
|
19
|
+
// No active ID for the current collection - the chain
|
|
20
|
+
// has been broken!
|
|
21
|
+
if (!activeId) {
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
var activeIndex = (_data$currentName = data[currentName]) === null || _data$currentName === void 0 ? void 0 : _data$currentName.findIndex(function (item) {
|
|
25
|
+
return item.id === activeId;
|
|
26
|
+
});
|
|
27
|
+
// No entry that matches the active ID - the chain
|
|
28
|
+
// has been broken!
|
|
29
|
+
if (!isValidIndex(activeIndex)) {
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
collectionNames.shift();
|
|
33
|
+
// We're not at the last collection yet, so recurse and try
|
|
34
|
+
// to get data for the next one.
|
|
35
|
+
return getLastDataInChain(collectionNames, data[currentName][activeIndex], formData);
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Takes the name of a collection and returns its active index.
|
|
40
|
+
* This function supports collectionName being a dot-separated string
|
|
41
|
+
* of collection names for nested collections:
|
|
42
|
+
*
|
|
43
|
+
* e.g. collectionName being 'flights.people.documents' would return
|
|
44
|
+
* the active index in the nested documents collection, or null if there
|
|
45
|
+
* isn't one or the path is broken.
|
|
46
|
+
*
|
|
47
|
+
* @param {string} collectionName The name of the collection, or dot-separated path.
|
|
48
|
+
* @param {object} data The top level formData object.
|
|
49
|
+
* @returns The active index for the collection, or null if it doesn't exist.
|
|
50
|
+
*/
|
|
51
|
+
var getCollectionPageData = function getCollectionPageData(collectionName, formData) {
|
|
52
|
+
var nameParts = collectionName.split('.');
|
|
53
|
+
var result = getLastDataInChain(nameParts, formData, formData);
|
|
54
|
+
return result;
|
|
55
|
+
};
|
|
56
|
+
var _default = getCollectionPageData;
|
|
57
|
+
exports.default = _default;
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _getCollectionPageData = _interopRequireDefault(require("./getCollectionPageData"));
|
|
4
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
5
|
+
describe('utils.CollectionPage.getCollectionPageData', function () {
|
|
6
|
+
it('should return null if the collection does not exist', function () {
|
|
7
|
+
var data = (0, _getCollectionPageData.default)('testCollection', {});
|
|
8
|
+
expect(data).toEqual(null);
|
|
9
|
+
});
|
|
10
|
+
describe('when failing to retrieve a nested collection', function () {
|
|
11
|
+
it('should return null if a parent collection does not exist', function () {
|
|
12
|
+
var FORM_DATA = {
|
|
13
|
+
parentsActiveId: '1',
|
|
14
|
+
childrenActiveId: '1',
|
|
15
|
+
grandchildrenActiveId: '1',
|
|
16
|
+
parents: [{
|
|
17
|
+
id: '1',
|
|
18
|
+
children: [{
|
|
19
|
+
id: '1',
|
|
20
|
+
grandchildren: [{
|
|
21
|
+
id: '1',
|
|
22
|
+
value: 'Alpha'
|
|
23
|
+
}]
|
|
24
|
+
}]
|
|
25
|
+
}]
|
|
26
|
+
};
|
|
27
|
+
var data = (0, _getCollectionPageData.default)('parents.chainbreak.grandchildren', FORM_DATA);
|
|
28
|
+
expect(data).toEqual(null);
|
|
29
|
+
});
|
|
30
|
+
it('should return null if there is no active entry in a parent collection', function () {
|
|
31
|
+
var FORM_DATA = {
|
|
32
|
+
parentsActiveId: '1',
|
|
33
|
+
grandchildrenActiveId: '1',
|
|
34
|
+
parents: [{
|
|
35
|
+
id: '1',
|
|
36
|
+
children: [{
|
|
37
|
+
id: '1',
|
|
38
|
+
grandchildren: [{
|
|
39
|
+
id: '1',
|
|
40
|
+
value: 'Alpha'
|
|
41
|
+
}]
|
|
42
|
+
}]
|
|
43
|
+
}]
|
|
44
|
+
};
|
|
45
|
+
var data = (0, _getCollectionPageData.default)('parents.children.grandchildren', FORM_DATA);
|
|
46
|
+
expect(data).toEqual(null);
|
|
47
|
+
});
|
|
48
|
+
it('should return null if the target collection does not exist', function () {
|
|
49
|
+
var FORM_DATA = {
|
|
50
|
+
parentsActiveId: '1',
|
|
51
|
+
grandchildrenActiveId: '1',
|
|
52
|
+
parents: [{
|
|
53
|
+
id: '1',
|
|
54
|
+
children: [{
|
|
55
|
+
id: '1'
|
|
56
|
+
}]
|
|
57
|
+
}]
|
|
58
|
+
};
|
|
59
|
+
var data = (0, _getCollectionPageData.default)('parents.children.grandchildren', FORM_DATA);
|
|
60
|
+
expect(data).toEqual(null);
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
it('should get data for top-level collections correctly', function () {
|
|
64
|
+
var FORM_DATA = {
|
|
65
|
+
testCollection: [{
|
|
66
|
+
id: '1',
|
|
67
|
+
value: 'Alpha'
|
|
68
|
+
}]
|
|
69
|
+
};
|
|
70
|
+
var data = (0, _getCollectionPageData.default)('testCollection', FORM_DATA);
|
|
71
|
+
expect(Array.isArray(data)).toBeTruthy();
|
|
72
|
+
expect(data.length).toEqual(1);
|
|
73
|
+
expect(data[0]).toMatchObject({
|
|
74
|
+
id: '1',
|
|
75
|
+
value: 'Alpha'
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
it('should get data for nested collections correctly', function () {
|
|
79
|
+
var FORM_DATA = {
|
|
80
|
+
parentsActiveId: '1',
|
|
81
|
+
childrenActiveId: '1',
|
|
82
|
+
grandchildrenActiveId: '1',
|
|
83
|
+
parents: [{
|
|
84
|
+
id: '1',
|
|
85
|
+
children: [{
|
|
86
|
+
id: '1',
|
|
87
|
+
grandchildren: [{
|
|
88
|
+
id: '1',
|
|
89
|
+
value: 'Alpha'
|
|
90
|
+
}]
|
|
91
|
+
}]
|
|
92
|
+
}]
|
|
93
|
+
};
|
|
94
|
+
var data = (0, _getCollectionPageData.default)('parents.children.grandchildren', FORM_DATA);
|
|
95
|
+
expect(Array.isArray(data)).toBeTruthy();
|
|
96
|
+
expect(data.length).toEqual(1);
|
|
97
|
+
expect(data[0]).toMatchObject({
|
|
98
|
+
id: '1',
|
|
99
|
+
value: 'Alpha'
|
|
100
|
+
});
|
|
101
|
+
});
|
|
102
|
+
});
|
|
@@ -4,16 +4,24 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
+
var _addCollectionPageEntry = _interopRequireDefault(require("./addCollectionPageEntry"));
|
|
7
8
|
var _duplicateCollectionPageActiveEntry = _interopRequireDefault(require("./duplicateCollectionPageActiveEntry"));
|
|
9
|
+
var _getCollectionPageActiveId = _interopRequireDefault(require("./getCollectionPageActiveId"));
|
|
8
10
|
var _getCollectionPageActiveIndex = _interopRequireDefault(require("./getCollectionPageActiveIndex"));
|
|
11
|
+
var _getCollectionPageData = _interopRequireDefault(require("./getCollectionPageData"));
|
|
9
12
|
var _mergeCollectionPages = _interopRequireDefault(require("./mergeCollectionPages"));
|
|
13
|
+
var _setCollectionPageData = _interopRequireDefault(require("./setCollectionPageData"));
|
|
10
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
15
|
// Local imports
|
|
12
16
|
|
|
13
17
|
var CollectionPage = {
|
|
18
|
+
addEntry: _addCollectionPageEntry.default,
|
|
14
19
|
duplicateActiveEntry: _duplicateCollectionPageActiveEntry.default,
|
|
20
|
+
getActiveId: _getCollectionPageActiveId.default,
|
|
15
21
|
getActiveIndex: _getCollectionPageActiveIndex.default,
|
|
16
|
-
|
|
22
|
+
getData: _getCollectionPageData.default,
|
|
23
|
+
mergePages: _mergeCollectionPages.default,
|
|
24
|
+
setData: _setCollectionPageData.default
|
|
17
25
|
};
|
|
18
26
|
var _default = CollectionPage;
|
|
19
27
|
exports.default = _default;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var isValidIndex = function isValidIndex(value) {
|
|
8
|
+
return typeof value === 'number' && value >= 0;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* This function sets the data for a given collection in formData.
|
|
13
|
+
*
|
|
14
|
+
* This functions handles collectionName being a dot-separated string
|
|
15
|
+
* by drilling down through each active entry in each parent collection.
|
|
16
|
+
* If at any point this path is broken, either because a collection in
|
|
17
|
+
* the chain doesn't exist or doesn't have an active entry, then this
|
|
18
|
+
* function does nothing.
|
|
19
|
+
*
|
|
20
|
+
* @param {string} collectionName The page's collection name. Can be dot-separated for nested collections.
|
|
21
|
+
* @param {Array} newData The new data to set for the collection.
|
|
22
|
+
* @param {Object} formData Top level formData object.
|
|
23
|
+
*/
|
|
24
|
+
var setCollectionPageData = function setCollectionPageData(collectionName, newData, formData) {
|
|
25
|
+
var nameParts = collectionName.split('.');
|
|
26
|
+
var targetCollection = nameParts[nameParts.length - 1];
|
|
27
|
+
var data = formData;
|
|
28
|
+
nameParts.some(function (name) {
|
|
29
|
+
var _data$name;
|
|
30
|
+
if (!data) {
|
|
31
|
+
return true;
|
|
32
|
+
}
|
|
33
|
+
// We're at the target collection's level, so
|
|
34
|
+
// set the new data.
|
|
35
|
+
if (name === targetCollection) {
|
|
36
|
+
// eslint-disable-next-line no-param-reassign
|
|
37
|
+
data[targetCollection] = newData;
|
|
38
|
+
return true;
|
|
39
|
+
}
|
|
40
|
+
var activeId = formData["".concat(name, "ActiveId")];
|
|
41
|
+
var activeIndex = (_data$name = data[name]) === null || _data$name === void 0 ? void 0 : _data$name.findIndex(function (item) {
|
|
42
|
+
return item.id === activeId;
|
|
43
|
+
});
|
|
44
|
+
if (!isValidIndex(activeIndex)) {
|
|
45
|
+
return true;
|
|
46
|
+
}
|
|
47
|
+
data = data[name][activeIndex];
|
|
48
|
+
return false;
|
|
49
|
+
});
|
|
50
|
+
};
|
|
51
|
+
var _default = setCollectionPageData;
|
|
52
|
+
exports.default = _default;
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _setCollectionPageData = _interopRequireDefault(require("./setCollectionPageData"));
|
|
4
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
5
|
+
describe('Utils.CollectionPage.setCollectionPageData', function () {
|
|
6
|
+
it('should do nothing if the collection does not exist', function () {
|
|
7
|
+
var FORM_DATA = {};
|
|
8
|
+
var NEW_DATA = [{
|
|
9
|
+
id: '1',
|
|
10
|
+
value: 'Alpha'
|
|
11
|
+
}];
|
|
12
|
+
(0, _setCollectionPageData.default)('testCollection', NEW_DATA, FORM_DATA);
|
|
13
|
+
expect(FORM_DATA).toMatchObject({});
|
|
14
|
+
});
|
|
15
|
+
describe('when failing to set data for a nested collection', function () {
|
|
16
|
+
it('should do nothing if one of the parent collections does not exist', function () {
|
|
17
|
+
var FORM_DATA = {
|
|
18
|
+
parentActiveId: '1',
|
|
19
|
+
childActiveId: '1',
|
|
20
|
+
grandchildActiveId: '1',
|
|
21
|
+
parent: [{
|
|
22
|
+
id: '1',
|
|
23
|
+
child: [{
|
|
24
|
+
id: '1',
|
|
25
|
+
grandchild: [{
|
|
26
|
+
id: '1',
|
|
27
|
+
value: 'oldValue'
|
|
28
|
+
}]
|
|
29
|
+
}]
|
|
30
|
+
}]
|
|
31
|
+
};
|
|
32
|
+
var NEW_DATA = [{
|
|
33
|
+
id: '1',
|
|
34
|
+
value: 'newValue'
|
|
35
|
+
}];
|
|
36
|
+
(0, _setCollectionPageData.default)('parent.breakhere.grandchild', NEW_DATA, FORM_DATA);
|
|
37
|
+
expect(FORM_DATA.parent[0].child[0].grandchild[0]).toMatchObject({
|
|
38
|
+
id: '1',
|
|
39
|
+
value: 'oldValue'
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
it('should do nothing if an active ID does not exist for a parent collection', function () {
|
|
43
|
+
var FORM_DATA = {
|
|
44
|
+
parentActiveId: '1',
|
|
45
|
+
grandchildActiveId: '1',
|
|
46
|
+
parent: [{
|
|
47
|
+
id: '1',
|
|
48
|
+
child: [{
|
|
49
|
+
id: '1',
|
|
50
|
+
grandchild: [{
|
|
51
|
+
id: '1',
|
|
52
|
+
value: 'oldValue'
|
|
53
|
+
}]
|
|
54
|
+
}]
|
|
55
|
+
}]
|
|
56
|
+
};
|
|
57
|
+
var NEW_DATA = [{
|
|
58
|
+
id: '1',
|
|
59
|
+
value: 'newValue'
|
|
60
|
+
}];
|
|
61
|
+
(0, _setCollectionPageData.default)('parent.child.grandchild', NEW_DATA, FORM_DATA);
|
|
62
|
+
expect(FORM_DATA.parent[0].child[0].grandchild[0]).toMatchObject({
|
|
63
|
+
id: '1',
|
|
64
|
+
value: 'oldValue'
|
|
65
|
+
});
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
it('should correctly set the value for a top-level collection', function () {
|
|
69
|
+
var FORM_DATA = {
|
|
70
|
+
testCollectionActiveId: '1',
|
|
71
|
+
testCollection: [{
|
|
72
|
+
id: '1',
|
|
73
|
+
value: 'oldValue'
|
|
74
|
+
}]
|
|
75
|
+
};
|
|
76
|
+
var NEW_DATA = [{
|
|
77
|
+
id: '1',
|
|
78
|
+
value: 'newValue'
|
|
79
|
+
}];
|
|
80
|
+
(0, _setCollectionPageData.default)('testCollection', NEW_DATA, FORM_DATA);
|
|
81
|
+
expect(FORM_DATA.testCollection[0]).toMatchObject({
|
|
82
|
+
id: '1',
|
|
83
|
+
value: 'newValue'
|
|
84
|
+
});
|
|
85
|
+
});
|
|
86
|
+
it('should correctly set the data for a nested collection', function () {
|
|
87
|
+
var FORM_DATA = {
|
|
88
|
+
parentActiveId: '1',
|
|
89
|
+
childActiveId: '1',
|
|
90
|
+
grandchildActiveId: '1',
|
|
91
|
+
parent: [{
|
|
92
|
+
id: '1',
|
|
93
|
+
child: [{
|
|
94
|
+
id: '1',
|
|
95
|
+
grandchild: [{
|
|
96
|
+
id: '1',
|
|
97
|
+
value: 'oldValue'
|
|
98
|
+
}]
|
|
99
|
+
}]
|
|
100
|
+
}]
|
|
101
|
+
};
|
|
102
|
+
var NEW_DATA = [{
|
|
103
|
+
id: '1',
|
|
104
|
+
value: 'newValue'
|
|
105
|
+
}];
|
|
106
|
+
(0, _setCollectionPageData.default)('parent.child.grandchild', NEW_DATA, FORM_DATA);
|
|
107
|
+
expect(FORM_DATA.parent[0].child[0].grandchild[0]).toMatchObject({
|
|
108
|
+
id: '1',
|
|
109
|
+
value: 'newValue'
|
|
110
|
+
});
|
|
111
|
+
});
|
|
112
|
+
});
|
|
@@ -5,7 +5,7 @@ var _react = require("@testing-library/react");
|
|
|
5
5
|
var _models = require("../../../models");
|
|
6
6
|
var _getComponent = _interopRequireDefault(require("../getComponent"));
|
|
7
7
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
8
|
-
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel; var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) keys.push(key); return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, catch: function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
|
|
8
|
+
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return { value: void 0, done: !0 }; } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel; var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable || "" === iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; return next.value = undefined, next.done = !0, next; }; return next.next = next; } } throw new TypeError(_typeof(iterable) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) keys.push(key); return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, catch: function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
|
|
9
9
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
10
10
|
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
11
11
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
@@ -4,7 +4,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
|
|
|
4
4
|
var _react = require("@testing-library/react");
|
|
5
5
|
var _getComponent = require("../getComponent");
|
|
6
6
|
var _setupTests = require("../../../setupTests");
|
|
7
|
-
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel; var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) keys.push(key); return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, catch: function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
|
|
7
|
+
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return { value: void 0, done: !0 }; } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel; var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable || "" === iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; return next.value = undefined, next.done = !0, next; }; return next.next = next; } } throw new TypeError(_typeof(iterable) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) keys.push(key); return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, catch: function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
|
|
8
8
|
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; }
|
|
9
9
|
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
10
10
|
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); }
|