@ukhomeoffice/cop-react-form-renderer 4.32.0 → 4.32.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.
@@ -5,7 +5,8 @@
5
5
  margin-bottom: 0.75rem;
6
6
  }
7
7
  &__item {
8
- margin-top: 0;
8
+ margin-top: 15px;
9
+ margin-bottom: 15px;
9
10
  position: relative;
10
11
  }
11
12
  &__item-title {
@@ -584,7 +584,7 @@ describe('components', function () {
584
584
  }, _callee18);
585
585
  })));
586
586
  it('should handle navigating between task list pages', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee20() {
587
- var ON_SUBMIT_CALLS, ON_SUBMIT, HOOKS, taskList, firstTaskStatus, secondTaskStatus, firstTask, newPage, continueButton, cyaPageChange, modeChangeLink, changePage, cyaPage, finalSubmit;
587
+ var ON_SUBMIT_CALLS, ON_SUBMIT, HOOKS, taskList, firstTaskStatus, secondTaskStatus, firstTask, newPage, continueButton, seaButton, cyaPageChange, modeChangeLink, changePage, airButton, cyaPage, finalSubmit;
588
588
  return regeneratorRuntime.wrap(function _callee20$(_context20) {
589
589
  while (1) {
590
590
  switch (_context20.prev = _context20.next) {
@@ -662,8 +662,10 @@ describe('components', function () {
662
662
 
663
663
  newPage = container.childNodes[0].childNodes[0];
664
664
  expect(newPage.childNodes[0].textContent).toEqual('Event Mode');
665
+ seaButton = newPage.childNodes[1].childNodes[0].childNodes[2].childNodes[0];
666
+ expect(seaButton.textContent).toEqual('Sea');
665
667
 
666
- _react.fireEvent.click(newPage.childNodes[1].childNodes[0].childNodes[1], {});
668
+ _react.fireEvent.click(seaButton.childNodes[0], {});
667
669
 
668
670
  continueButton = newPage.childNodes[2].childNodes[0];
669
671
 
@@ -671,17 +673,23 @@ describe('components', function () {
671
673
 
672
674
 
673
675
  cyaPageChange = container.childNodes[0].childNodes[0];
674
- modeChangeLink = cyaPageChange.childNodes[0].childNodes[1].childNodes[0].childNodes[0];
676
+ expect(cyaPageChange.childNodes[0].textContent).toEqual('Check your answers');
677
+ modeChangeLink = cyaPageChange.childNodes[4].childNodes[0].childNodes[0].childNodes[2].childNodes[0];
678
+ expect(modeChangeLink.textContent).toEqual('Change Event Mode');
675
679
 
676
680
  _react.fireEvent.click(modeChangeLink, {});
677
681
 
678
682
  changePage = container.childNodes[0].childNodes[0];
679
- expect(changePage.childNodes[1].textContent).toEqual('Event Mode'); // Click on radio for 'Air'
683
+ expect(changePage.childNodes[0].textContent).toEqual('Event Mode'); // Click on radio for 'Air'
680
684
 
681
- _react.fireEvent.click(changePage.childNodes[2].childNodes[0].childNodes[3].childNodes[1].childNodes[0]); // Continue again to CYA page
685
+ airButton = changePage.childNodes[1].childNodes[0].childNodes[2].childNodes[1];
686
+ expect(airButton.textContent).toEqual('Air');
682
687
 
688
+ _react.fireEvent.click(airButton.childNodes[0]); // Continue again to CYA page
683
689
 
684
- continueButton = changePage.childNodes[3].childNodes[0];
690
+
691
+ expect(changePage.childNodes[2].childNodes[0].textContent).toEqual('Save and continue');
692
+ continueButton = changePage.childNodes[2].childNodes[0];
685
693
 
686
694
  _react.fireEvent.click(continueButton, {}); //Continue on from CYA page
687
695
 
@@ -706,7 +714,7 @@ describe('components', function () {
706
714
  expect(finalSubmit.mode).toEqual('air');
707
715
  expect(finalSubmit.formStatus.tasks['Date, location and mode details'].complete).toEqual(true);
708
716
 
709
- case 47:
717
+ case 54:
710
718
  case "end":
711
719
  return _context20.stop();
712
720
  }
@@ -36,7 +36,7 @@ var addShowWhen = function addShowWhen(component, condition) {
36
36
  if (result.show_when) {
37
37
  result.show_when = Array.isArray(result.show_when) ? [].concat(result.show_when, [_objectSpread({}, condition)]) : [result.show_when, _objectSpread({}, condition)];
38
38
  } else {
39
- result.show_when = [_objectSpread({}, condition)];
39
+ result.show_when = condition.type === 'or' ? result.show_when = _objectSpread({}, condition) : result.show_when = [_objectSpread({}, condition)];
40
40
  }
41
41
 
42
42
  return result;
@@ -93,4 +93,26 @@ describe('utils.Component.addShowWhen', function () {
93
93
  }, NEW_SHOW_WHEN]
94
94
  });
95
95
  });
96
+ it('should add the or type show_when to a component with no existing show_whens in an object not an array', function () {
97
+ var COMPONENT = {
98
+ alpha: 'bravo'
99
+ };
100
+ var SHOW_WHEN_OR = {
101
+ type: 'or',
102
+ condition: [{
103
+ field: 'field1',
104
+ op: '=',
105
+ values: 1
106
+ }, {
107
+ field: 'field2',
108
+ op: '=',
109
+ value: 2
110
+ }]
111
+ };
112
+ var result = (0, _addShowWhen.default)(COMPONENT, SHOW_WHEN_OR);
113
+ expect(result).toEqual({
114
+ alpha: 'bravo',
115
+ show_when: SHOW_WHEN_OR
116
+ });
117
+ });
96
118
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ukhomeoffice/cop-react-form-renderer",
3
- "version": "4.32.0",
3
+ "version": "4.32.2",
4
4
  "private": false,
5
5
  "scripts": {
6
6
  "clean": "rimraf dist",