@ukhomeoffice/cop-react-form-renderer 5.58.0 → 5.58.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -157,7 +157,7 @@ var getCYARowsForChildPages = function getCYARowsForChildPages(childPages, item,
|
|
|
157
157
|
}
|
|
158
158
|
var container = getContainerForPage(childPage, item, labelCount, fullPath);
|
|
159
159
|
var rowChangeAction = getChangeActionForPage(childPage, onAction, activeIds);
|
|
160
|
-
var containerRows = (0, _getCYARowsForContainer.default)(childPage, container, item, rowChangeAction, fnOverride);
|
|
160
|
+
var containerRows = (0, _getCYARowsForContainer.default)(childPage, container, _objectSpread(_objectSpread({}, childPage.formData), item), rowChangeAction, fnOverride);
|
|
161
161
|
rows = rows.concat(containerRows);
|
|
162
162
|
}
|
|
163
163
|
}
|
|
@@ -170,6 +170,41 @@ describe('utils.CheckYourAnswers.getCYARowsForCollectionPage', function () {
|
|
|
170
170
|
key: 'Test date'
|
|
171
171
|
});
|
|
172
172
|
});
|
|
173
|
+
it('should use values from top-level formData if they don\'t exist in the item', function () {
|
|
174
|
+
var FORM_DATA = {
|
|
175
|
+
testText: 'value',
|
|
176
|
+
collection: [{
|
|
177
|
+
id: '01'
|
|
178
|
+
}]
|
|
179
|
+
};
|
|
180
|
+
var PAGE = _objectSpread(_objectSpread({}, MASTER_PAGE), {}, {
|
|
181
|
+
childPages: [_objectSpread(_objectSpread({}, PAGES[0]), {}, {
|
|
182
|
+
formData: FORM_DATA
|
|
183
|
+
}), PAGES[1]],
|
|
184
|
+
formData: FORM_DATA
|
|
185
|
+
});
|
|
186
|
+
var ROWS = (0, _getCYARowsForCollectionPage.default)(PAGE, null, null, FORM_DATA);
|
|
187
|
+
expect(ROWS.length).toEqual(7); // Title row + component row for each item
|
|
188
|
+
expect(ROWS[0]).toMatchObject({
|
|
189
|
+
type: 'heading',
|
|
190
|
+
key: 'Collection'
|
|
191
|
+
});
|
|
192
|
+
expect(ROWS[1]).toMatchObject({
|
|
193
|
+
type: 'heading',
|
|
194
|
+
key: 'Collection entry 1'
|
|
195
|
+
});
|
|
196
|
+
expect(ROWS[2].action.label).toEqual('Change');
|
|
197
|
+
expect(ROWS[3].action.label).toEqual('custom remove label');
|
|
198
|
+
expect(ROWS[4].action.label).toEqual('custom change label');
|
|
199
|
+
expect(ROWS[5]).toMatchObject({
|
|
200
|
+
value: 'value',
|
|
201
|
+
key: 'Test text'
|
|
202
|
+
});
|
|
203
|
+
expect(ROWS[6]).toMatchObject({
|
|
204
|
+
value: '',
|
|
205
|
+
key: 'Test date'
|
|
206
|
+
});
|
|
207
|
+
});
|
|
173
208
|
it('should return correctly formatted rows for only the active entry when page.collection.onlyShowActiveEntryOnCYA is defined', function () {
|
|
174
209
|
var FORM_DATA = {
|
|
175
210
|
collectionActiveId: '02',
|