@ohos-ports/focuson-lenstest 1.44.3-beta.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.
Files changed (88) hide show
  1. package/README.md +6 -0
  2. package/dist/index.d.ts +1 -0
  3. package/dist/index.js +18 -0
  4. package/dist/src/DataDrivenFixedOptionDropDownAndDetails.spec.d.ts +1 -0
  5. package/dist/src/DataDrivenFixedOptionDropDownAndDetails.spec.js +70 -0
  6. package/dist/src/DatePicker.spec.d.ts +1 -0
  7. package/dist/src/DatePicker.spec.js +315 -0
  8. package/dist/src/DisplayStringWithLookup.spec.d.ts +1 -0
  9. package/dist/src/DisplayStringWithLookup.spec.js +42 -0
  10. package/dist/src/Label.spec.d.ts +1 -0
  11. package/dist/src/Label.spec.js +79 -0
  12. package/dist/src/Lens.spec.d.ts +1 -0
  13. package/dist/src/Lens.spec.js +164 -0
  14. package/dist/src/LensFixture.d.ts +28 -0
  15. package/dist/src/LensFixture.js +15 -0
  16. package/dist/src/LensState.spec.d.ts +1 -0
  17. package/dist/src/LensState.spec.js +100 -0
  18. package/dist/src/MonthYearDataPickerWithLength.spec.d.ts +1 -0
  19. package/dist/src/MonthYearDataPickerWithLength.spec.js +21 -0
  20. package/dist/src/WithTextLayout.spec.d.ts +1 -0
  21. package/dist/src/WithTextLayout.spec.js +29 -0
  22. package/dist/src/actions.spec.d.ts +1 -0
  23. package/dist/src/actions.spec.js +40 -0
  24. package/dist/src/composition.spec.d.ts +1 -0
  25. package/dist/src/composition.spec.js +28 -0
  26. package/dist/src/context.fixture.d.ts +6 -0
  27. package/dist/src/context.fixture.js +9 -0
  28. package/dist/src/dateutils.spec.d.ts +1 -0
  29. package/dist/src/dateutils.spec.js +166 -0
  30. package/dist/src/deleteState.spec.d.ts +1 -0
  31. package/dist/src/deleteState.spec.js +36 -0
  32. package/dist/src/dropdown.spec.d.ts +1 -0
  33. package/dist/src/dropdown.spec.js +46 -0
  34. package/dist/src/enzymeAdapterSetup.d.ts +1 -0
  35. package/dist/src/enzymeAdapterSetup.js +12 -0
  36. package/dist/src/fetcher.fixture.d.ts +38 -0
  37. package/dist/src/fetcher.fixture.js +20 -0
  38. package/dist/src/fetchers.spec.d.ts +1 -0
  39. package/dist/src/fetchers.spec.js +346 -0
  40. package/dist/src/focusedPage.spec.d.ts +1 -0
  41. package/dist/src/focusedPage.spec.js +70 -0
  42. package/dist/src/labelAnd.spec.d.ts +1 -0
  43. package/dist/src/labelAnd.spec.js +105 -0
  44. package/dist/src/labelAndDateInput.spec.d.ts +1 -0
  45. package/dist/src/labelAndDateInput.spec.js +26 -0
  46. package/dist/src/lenspath.spec.d.ts +1 -0
  47. package/dist/src/lenspath.spec.js +171 -0
  48. package/dist/src/memoisation.spec.d.ts +1 -0
  49. package/dist/src/memoisation.spec.js +11 -0
  50. package/dist/src/messages.spec.d.ts +1 -0
  51. package/dist/src/messages.spec.js +34 -0
  52. package/dist/src/modalButton.integration.spec.d.ts +23 -0
  53. package/dist/src/modalButton.integration.spec.js +299 -0
  54. package/dist/src/modalButton.spec.d.ts +1 -0
  55. package/dist/src/modalButton.spec.js +147 -0
  56. package/dist/src/newFetchers.spec.d.ts +1 -0
  57. package/dist/src/newFetchers.spec.js +214 -0
  58. package/dist/src/optics.spec.d.ts +2 -0
  59. package/dist/src/optics.spec.js +195 -0
  60. package/dist/src/page.fixture.d.ts +30 -0
  61. package/dist/src/page.fixture.js +55 -0
  62. package/dist/src/pageSelection.spec.d.ts +1 -0
  63. package/dist/src/pageSelection.spec.js +146 -0
  64. package/dist/src/post.spec.d.ts +1 -0
  65. package/dist/src/post.spec.js +84 -0
  66. package/dist/src/postButton.spec.d.ts +2 -0
  67. package/dist/src/postButton.spec.js +26 -0
  68. package/dist/src/preMutate.spec.d.ts +1 -0
  69. package/dist/src/preMutate.spec.js +63 -0
  70. package/dist/src/radioButton.spec.d.ts +1 -0
  71. package/dist/src/radioButton.spec.js +48 -0
  72. package/dist/src/restButton.spec.d.ts +13 -0
  73. package/dist/src/restButton.spec.js +95 -0
  74. package/dist/src/selectedItem.spec.d.ts +1 -0
  75. package/dist/src/selectedItem.spec.js +50 -0
  76. package/dist/src/stateAndFromApiTagFetcher.spec.d.ts +1 -0
  77. package/dist/src/stateAndFromApiTagFetcher.spec.js +59 -0
  78. package/dist/src/table.spec.d.ts +1 -0
  79. package/dist/src/table.spec.js +215 -0
  80. package/dist/src/tagFetcher.fixture.d.ts +7 -0
  81. package/dist/src/tagFetcher.fixture.js +16 -0
  82. package/dist/src/tagFetcher.spec.d.ts +1 -0
  83. package/dist/src/tagFetcher.spec.js +67 -0
  84. package/dist/src/template.spec.d.ts +1 -0
  85. package/dist/src/template.spec.js +58 -0
  86. package/dist/src/utils.spec.d.ts +1 -0
  87. package/dist/src/utils.spec.js +61 -0
  88. package/package.json +96 -0
package/README.md ADDED
@@ -0,0 +1,6 @@
1
+ This project holds the tests for
2
+
3
+ * [@focuson/lens: Easy - perhaps even beautiful - code for editing deep immutable objects](modules/lens/README.md)
4
+ * [@focuson/state: State management for projects (including React) using the lens in the above project](modules/state/README.md)
5
+
6
+ They have been moved here to keep the main projects small
@@ -0,0 +1 @@
1
+ export * from './src/LensFixture';
package/dist/index.js ADDED
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ //Copyright (c)2020-2022 Philip Rice. <br />Permission is hereby granted, free of charge, to any person obtaining a copyof this software and associated documentation files (the Software), to dealin the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: <br />The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED AS
3
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
+ if (k2 === undefined) k2 = k;
5
+ var desc = Object.getOwnPropertyDescriptor(m, k);
6
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
+ desc = { enumerable: true, get: function() { return m[k]; } };
8
+ }
9
+ Object.defineProperty(o, k2, desc);
10
+ }) : (function(o, m, k, k2) {
11
+ if (k2 === undefined) k2 = k;
12
+ o[k2] = m[k];
13
+ }));
14
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
16
+ };
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ __exportStar(require("./src/LensFixture"), exports);
@@ -0,0 +1,70 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const jsx_runtime_1 = require("react/jsx-runtime");
4
+ const state_1 = require("@focuson/state");
5
+ const enzyme_1 = require("enzyme");
6
+ const rest_1 = require("@focuson/rest");
7
+ const pages_1 = require("@focuson/pages");
8
+ const form_components_1 = require("@focuson/form_components");
9
+ const utils_1 = require("@focuson/utils");
10
+ const enzymeAdapterSetup_1 = require("./enzymeAdapterSetup");
11
+ const lens_1 = require("@focuson/lens");
12
+ (0, enzymeAdapterSetup_1.enzymeSetup)();
13
+ const context = {
14
+ restL: (0, rest_1.restL)(),
15
+ dateFn: utils_1.testDateFn,
16
+ combine: (state, pages) => (0, jsx_runtime_1.jsx)("div", { children: pages.map(p => p.element) }),
17
+ pageSelectionL: (0, pages_1.pageSelectionlens)(),
18
+ simpleMessagesL: (0, pages_1.simpleMessagesL)(),
19
+ closeOnePageTxs: pages_1.rawCloseOnePageTxs,
20
+ // @ts-ignore
21
+ pathToLens: () => path => lens_1.Lenses.identity().focusQuery(path.slice(1)), //trims the / off the front
22
+ pages: {},
23
+ // commonIds: {}
24
+ };
25
+ function display(s, setMain, fn) {
26
+ const comp = (0, enzyme_1.shallow)(fn((0, state_1.lensState)(s, setMain, 'DataDriven', context)));
27
+ return comp;
28
+ }
29
+ const empty = {
30
+ messages: [], pageSelection: [], restCommands: [],
31
+ mainOrJointOrNew: 'M',
32
+ mainName: 'theMainName',
33
+ jointName: 'theJointName',
34
+ mainData: 'theMainData',
35
+ jointData: 'theJointData'
36
+ };
37
+ function displayString(props) {
38
+ return (0, jsx_runtime_1.jsxs)("p", { children: ["Label: ", props.label, " Id: ", props.id, " Mode: ", props.mode, " Data: ", props.state.optJson()] });
39
+ }
40
+ const details = {
41
+ M: { valuePath: '/mainName', dataPath: '/mainData', display: displayString },
42
+ J: { valuePath: '/jointName', dataPath: '/jointData', display: displayString },
43
+ N: { value: 'New Bank' },
44
+ };
45
+ describe('DataDrivenFixedOptionDropDownAndDetails', () => {
46
+ it('should display main', () => {
47
+ const comp = display(empty, s => { }, s => (0, jsx_runtime_1.jsx)(form_components_1.DataDrivenFixedOptionDropDownAndDetails, { parentState: s, state: s.focusOn('mainOrJointOrNew'), id: 'someId', allButtons: {}, mode: 'view', label: 'someLabel', details: details }));
48
+ expect(comp.html()).toEqual('<div style="display:flex"><div style="flex:50%"><div class="dropdown-container "><label for="someId" class="input-label">someLabel</label><div class=""><select class="select " data-validationmessage="someLabel" disabled="" id="someId" required=""><option selected="" value="M">theMainName</option><option value="J">theJointName</option><option value="N">New Bank</option></select></div></div></div><div style="flex:50%"><p>Label: someLabel Id: someId Mode: view Data: theMainData</p></div></div>');
49
+ });
50
+ it('should display joint', () => {
51
+ const comp = display(Object.assign(Object.assign({}, empty), { mainOrJointOrNew: 'J' }), s => { }, s => (0, jsx_runtime_1.jsx)(form_components_1.DataDrivenFixedOptionDropDownAndDetails, { parentState: s, state: s.focusOn('mainOrJointOrNew'), id: 'someId', allButtons: {}, mode: 'view', label: 'someLabel', details: details }));
52
+ expect(comp.html()).toEqual('<div style="display:flex"><div style="flex:50%"><div class="dropdown-container "><label for="someId" class="input-label">someLabel</label><div class=""><select class="select " data-validationmessage="someLabel" disabled="" id="someId" required=""><option value="M">theMainName</option><option selected="" value="J">theJointName</option><option value="N">New Bank</option></select></div></div></div><div style="flex:50%"><p>Label: someLabel Id: someId Mode: view Data: theJointData</p></div></div>');
53
+ });
54
+ it('should display when no data path or display', () => {
55
+ const comp = display(Object.assign(Object.assign({}, empty), { mainOrJointOrNew: 'N' }), s => { }, s => (0, jsx_runtime_1.jsx)(form_components_1.DataDrivenFixedOptionDropDownAndDetails, { parentState: s, state: s.focusOn('mainOrJointOrNew'), id: 'someId', allButtons: {}, mode: 'view', label: 'someLabel', details: details }));
56
+ expect(comp.html()).toEqual('<div style="display:flex"><div style="flex:50%"><div class="dropdown-container "><label for="someId" class="input-label">someLabel</label><div class=""><select class="select " data-validationmessage="someLabel" disabled="" id="someId" required=""><option value="M">theMainName</option><option value="J">theJointName</option><option selected="" value="N">New Bank</option></select></div></div></div><div style="flex:50%"><div></div></div></div>');
57
+ });
58
+ it('should display when there is nothing at the value path', () => {
59
+ const comp = display(Object.assign(Object.assign({}, empty), { mainOrJointOrNew: 'J', jointName: undefined }), s => { }, s => (0, jsx_runtime_1.jsx)(form_components_1.DataDrivenFixedOptionDropDownAndDetails, { parentState: s, state: s.focusOn('mainOrJointOrNew'), id: 'someId', allButtons: {}, mode: 'view', label: 'someLabel', details: details }));
60
+ expect(comp.html()).toEqual('<div style="display:flex"><div style="flex:50%"><div class="dropdown-container "><label for="someId" class="input-label">someLabel</label><div class=""><select class="select " data-validationmessage="someLabel" disabled="" id="someId" required=""><option value="M">theMainName</option><option selected="" value="J"></option><option value="N">New Bank</option></select></div></div></div><div style="flex:50%"><p>Label: someLabel Id: someId Mode: view Data: theJointData</p></div></div>');
61
+ });
62
+ it('should display when there is nothing at the data path', () => {
63
+ const comp = display(Object.assign(Object.assign({}, empty), { mainOrJointOrNew: 'J', jointData: undefined }), s => { }, s => (0, jsx_runtime_1.jsx)(form_components_1.DataDrivenFixedOptionDropDownAndDetails, { parentState: s, state: s.focusOn('mainOrJointOrNew'), id: 'someId', allButtons: {}, mode: 'view', label: 'someLabel', details: details }));
64
+ expect(comp.html()).toEqual('<div style="display:flex"><div style="flex:50%"><div class="dropdown-container "><label for="someId" class="input-label">someLabel</label><div class=""><select class="select " data-validationmessage="someLabel" disabled="" id="someId" required=""><option value="M">theMainName</option><option selected="" value="J">theJointName</option><option value="N">New Bank</option></select></div></div></div><div style="flex:50%"><p>Label: someLabel Id: someId Mode: view Data: </p></div></div>');
65
+ });
66
+ it('should display when there is nothing at the data path and dontShowEmpty is true', () => {
67
+ const comp = display(Object.assign(Object.assign({}, empty), { jointName: undefined }), s => { }, s => (0, jsx_runtime_1.jsx)(form_components_1.DataDrivenFixedOptionDropDownAndDetails, { parentState: s, state: s.focusOn('mainOrJointOrNew'), id: 'someId', dontShowEmpty: true, allButtons: {}, mode: 'view', label: 'someLabel', details: details }));
68
+ expect(comp.html()).toEqual('<div style="display:flex"><div style="flex:50%"><div class="dropdown-container "><label for="someId" class="input-label">someLabel</label><div class=""><select class="select " data-validationmessage="someLabel" disabled="" id="someId" required=""><option selected="" value="M">theMainName</option><option value="N">New Bank</option></select></div></div></div><div style="flex:50%"><p>Label: someLabel Id: someId Mode: view Data: theMainData</p></div></div>');
69
+ });
70
+ });
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,315 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const form_components_1 = require("@focuson/form_components");
4
+ const state_1 = require("@focuson/state");
5
+ const enzyme_1 = require("enzyme");
6
+ const pages_1 = require("@focuson/pages");
7
+ const enzymeAdapterSetup_1 = require("./enzymeAdapterSetup");
8
+ const lens_1 = require("@focuson/lens");
9
+ (0, enzymeAdapterSetup_1.enzymeSetup)();
10
+ const dateFormat = 'dd/MM/yyyy';
11
+ const otherDateErrorMessage = {
12
+ isInPast: 'pastMsg',
13
+ isWeekend: 'weekendMsg',
14
+ isHoliday: 'holidayMsg',
15
+ beforeFirstValid: 'beforeFirstMsg'
16
+ };
17
+ const okDateInfo = {
18
+ dateFormat,
19
+ holidays: [
20
+ { date: '12/11/2022', jurisdiction: 'GB' },
21
+ { date: '12/11/2022', jurisdiction: 'I' },
22
+ { date: '15/11/2022', jurisdiction: 'GB' },
23
+ { date: '17/11/2022', jurisdiction: 'I' },
24
+ ],
25
+ "serverNow": "2022-07-01T05:25:32.077Z",
26
+ today: '7/11/2022',
27
+ };
28
+ const badDateInfo = {
29
+ dateFormat,
30
+ holidays: [
31
+ { date: 'bad1', jurisdiction: 'GB' },
32
+ { date: 'bad2', jurisdiction: 'I' },
33
+ ],
34
+ "serverNow": "2022-07-01T05:25:32.077Z",
35
+ today: '7/11/2022',
36
+ };
37
+ const nov7 = new Date('2022/11/7').toISOString(); // need this so that the tests can run in different places
38
+ const nov12 = new Date('2022/11/12').toISOString();
39
+ const nov15 = new Date('2022/11/15').toISOString();
40
+ const nov17 = new Date('2022/11/17').toISOString();
41
+ function date(d) {
42
+ if (Array.isArray(d))
43
+ throw Error();
44
+ return d;
45
+ }
46
+ const toDate = (0, form_components_1.parseDate)('', dateFormat);
47
+ describe("parseDate", () => {
48
+ it("should parse dates", () => {
49
+ expect(date((0, form_components_1.parseDate)('somePrefix', 'dd/MM/yyyy')('7/11/2022')).toISOString()).toEqual(nov7);
50
+ expect(date((0, form_components_1.parseDate)('somePrefix', 'yyyy/MM/dd')('2022/11/7')).toISOString()).toEqual(nov7);
51
+ });
52
+ it("should handle non dates", () => {
53
+ expect((0, form_components_1.parseDate)('somePrefix', 'yyyy/MM/dd')('someJunk')).toEqual(['somePrefixPlease use date format yyyy/mm/dd']);
54
+ expect((0, form_components_1.parseDate)('somePrefix', 'dd/MM/yyyy')('someJunk')).toEqual(['somePrefixPlease use date format dd/mm/yyyy']);
55
+ });
56
+ });
57
+ describe("validateDateInfo", () => {
58
+ it("should turn strings into dates", () => {
59
+ const [errors, [dateInfo]] = (0, form_components_1.errorsAnd)([(0, form_components_1.validateDateInfo)(okDateInfo, undefined, {}, undefined, form_components_1.defaultDateErrorMessage)]);
60
+ expect(errors).toHaveLength(0);
61
+ const { holidays, today } = dateInfo;
62
+ expect(today.toISOString()).toEqual(nov7);
63
+ expect(holidays.map(d => d.toISOString())).toEqual([
64
+ `${nov12}`,
65
+ `${nov12}`,
66
+ `${nov15}`,
67
+ `${nov17}`
68
+ ]);
69
+ });
70
+ describe("should return issues", () => {
71
+ it("should report issues with today", () => {
72
+ const [errors, [dateInfo]] = (0, form_components_1.errorsAnd)([(0, form_components_1.validateDateInfo)(Object.assign(Object.assign({}, okDateInfo), { today: 'junk' }), undefined, {}, undefined, form_components_1.defaultDateErrorMessage)]);
73
+ expect(errors).toEqual(["Please use date format dd/mm/yyyy"]);
74
+ });
75
+ it("should report issues with holidayDates", () => {
76
+ const [errors, [dateInfo]] = (0, form_components_1.errorsAnd)([(0, form_components_1.validateDateInfo)(badDateInfo, undefined, {}, undefined, form_components_1.defaultDateErrorMessage)]);
77
+ expect(errors).toEqual([
78
+ "holidays[0]: Please use date format dd/mm/yyyy",
79
+ "holidays[1]: Please use date format dd/mm/yyyy"
80
+ ]);
81
+ });
82
+ });
83
+ });
84
+ const state = {
85
+ firstDate: '9/11/2022'
86
+ };
87
+ const contextForState = {
88
+ pathToLens: (s, currentLens) => (path) => lens_1.Lenses.identity().focusQuery('firstDate')
89
+ };
90
+ const lenstate = (0, state_1.lensState)(state, s => { }, '', contextForState);
91
+ describe("acceptDate", () => {
92
+ describe("futureOk", () => {
93
+ it("should return empty errors if the date is in the future", () => {
94
+ const accept = (0, form_components_1.acceptDateForTest)(lenstate, 'GB', okDateInfo, { type: 'future' }, dateFormat, form_components_1.defaultDateErrorMessage);
95
+ expect(accept(new Date("2022/11/7"))).toEqual([]); //today
96
+ expect(accept(new Date("2022/12/1"))).toEqual([]);
97
+ expect(accept(new Date("2022/10/3"))).toEqual(["before first valid date"]);
98
+ });
99
+ it("should return empty errors if the date is in the future, custom message", () => {
100
+ const accept = (0, form_components_1.acceptDateForTest)(lenstate, 'GB', okDateInfo, { type: 'future' }, dateFormat, otherDateErrorMessage);
101
+ expect(accept(new Date("2022/11/7"))).toEqual([]); //today
102
+ expect(accept(new Date("2022/12/1"))).toEqual([]);
103
+ expect(accept(new Date("2022/10/3"))).toEqual(["beforeFirstMsg"]);
104
+ });
105
+ });
106
+ describe("pastOk", () => {
107
+ it("should return empty errors if the date is in the past", () => {
108
+ const accept = (0, form_components_1.acceptDateForTest)(lenstate, 'GB', okDateInfo, { type: 'past' }, dateFormat, form_components_1.defaultDateErrorMessage);
109
+ expect(accept(new Date("2022/11/7"))).toEqual([]); //today
110
+ expect(accept(new Date("2022/12/1"))).toEqual(['is in the future']);
111
+ expect(accept(new Date("2022/10/3"))).toEqual([]);
112
+ // @ts-ignore
113
+ expect(accept(undefined)).toEqual([]);
114
+ // @ts-ignore
115
+ expect(accept(null)).toEqual([]);
116
+ });
117
+ it("should return empty errors if the date is in the past, custom message", () => {
118
+ const accept = (0, form_components_1.acceptDateForTest)(lenstate, 'GB', okDateInfo, { type: 'past' }, dateFormat, otherDateErrorMessage);
119
+ expect(accept(new Date("2022/11/7"))).toEqual([]); //today
120
+ expect(accept(new Date("2022/12/1"))).toEqual(['pastMsg']);
121
+ expect(accept(new Date("2022/10/3"))).toEqual([]);
122
+ // @ts-ignore
123
+ expect(accept(undefined)).toEqual([]);
124
+ // @ts-ignore
125
+ expect(accept(null)).toEqual([]);
126
+ });
127
+ });
128
+ describe("weekendsOK", () => {
129
+ it("should return empty errors no matter the date if 'allowWeekends' is true", () => {
130
+ const accept = (0, form_components_1.acceptDateForTest)(lenstate, 'GB', okDateInfo, { type: 'future', allowWeekends: true }, dateFormat, form_components_1.defaultDateErrorMessage);
131
+ expect(accept(new Date("2022/11/7"))).toEqual([]); //today
132
+ expect(accept(new Date("2022/11/12"))).toEqual([]);
133
+ expect(accept(new Date("2022/11/8"))).toEqual([]);
134
+ });
135
+ it("should return errors if a weekend if 'allowWeekends' is false ", () => {
136
+ const accept = (0, form_components_1.acceptDateForTest)(lenstate, 'GB', okDateInfo, { type: 'future', allowWeekends: false }, dateFormat, form_components_1.defaultDateErrorMessage);
137
+ expect(accept(new Date("2022/11/7"))).toEqual([]); //today
138
+ expect(accept(new Date("2022/11/12"))).toEqual(["is a weekend"]);
139
+ expect(accept(new Date("2022/11/8"))).toEqual([]);
140
+ });
141
+ it("should return errors if a weekend if 'allowWeekends' is false, custom message", () => {
142
+ const accept = (0, form_components_1.acceptDateForTest)(lenstate, 'GB', okDateInfo, { type: 'future', allowWeekends: false }, dateFormat, otherDateErrorMessage);
143
+ expect(accept(new Date("2022/11/7"))).toEqual([]); //today
144
+ expect(accept(new Date("2022/11/12"))).toEqual(["weekendMsg"]);
145
+ expect(accept(new Date("2022/11/8"))).toEqual([]);
146
+ });
147
+ it("should default to allowWeekends true", () => {
148
+ const accept = (0, form_components_1.acceptDateForTest)(lenstate, 'GB', okDateInfo, { type: 'future', allowWeekends: undefined }, dateFormat, form_components_1.defaultDateErrorMessage);
149
+ expect(accept(new Date("2022/11/7"))).toEqual([]); //today
150
+ expect(accept(new Date("2022/11/12"))).toEqual([]);
151
+ expect(accept(new Date("2022/11/8"))).toEqual([]);
152
+ });
153
+ it("should default to allowWeekends true, custom message", () => {
154
+ const accept = (0, form_components_1.acceptDateForTest)(lenstate, 'GB', okDateInfo, { type: 'future', allowWeekends: undefined }, dateFormat, otherDateErrorMessage);
155
+ expect(accept(new Date("2022/11/7"))).toEqual([]); //today
156
+ expect(accept(new Date("2022/11/12"))).toEqual([]);
157
+ expect(accept(new Date("2022/11/8"))).toEqual([]);
158
+ });
159
+ it("should handle non dates", () => {
160
+ const accept = (0, form_components_1.acceptDateForTest)(lenstate, 'GB', okDateInfo, { type: 'future', allowWeekends: undefined }, dateFormat, form_components_1.defaultDateErrorMessage);
161
+ expect(accept(new Date("2022/11/7"))).toEqual([]); //today
162
+ // @ts-ignore
163
+ expect(accept(undefined)).toEqual([]);
164
+ // @ts-ignore
165
+ expect(accept(null)).toEqual([]);
166
+ });
167
+ });
168
+ });
169
+ describe('firstAllowedDate', () => {
170
+ function firstAllowed(dateRange, firstDefined) {
171
+ const udi = (0, form_components_1.validateDateInfo)(okDateInfo, 'GB', dateRange, firstDefined, form_components_1.defaultDateErrorMessage);
172
+ if (Array.isArray(udi))
173
+ throw Error('okDateInfo is actually not ok');
174
+ return (0, form_components_1.firstAllowedDate)(udi.today, udi.holidays, dateRange, firstDefined, form_components_1.defaultDateErrorMessage);
175
+ }
176
+ it("should use the first defined date is specified", () => {
177
+ expect(firstAllowed({ type: 'future' }, new Date(Date.parse('9 Nov 2022')))).toEqual(toDate('9/11/2022'));
178
+ });
179
+ it("should ignore weekends and holidays when those are ignored", () => {
180
+ var _a, _b, _c, _d;
181
+ expect((_a = firstAllowed({ type: 'future' })) === null || _a === void 0 ? void 0 : _a.toString()).toEqual(toDate('7/11/2022').toString());
182
+ expect((_b = firstAllowed({ type: 'future', minWorkingDaysBefore: 1 })) === null || _b === void 0 ? void 0 : _b.toString()).toEqual(toDate('8/11/2022').toString());
183
+ expect((_c = firstAllowed({ type: 'future', minWorkingDaysBefore: 2 })) === null || _c === void 0 ? void 0 : _c.toString()).toEqual(toDate('9/11/2022').toString());
184
+ expect((_d = firstAllowed({ type: 'future', minWorkingDaysBefore: 10 })) === null || _d === void 0 ? void 0 : _d.toString()).toEqual(toDate('17/11/2022').toString());
185
+ });
186
+ it("should take account of weekends when those are not allowed", () => {
187
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
188
+ expect((_a = firstAllowed({ type: 'future', allowWeekends: false })) === null || _a === void 0 ? void 0 : _a.toString()).toEqual(toDate('7/11/2022').toString());
189
+ expect((_b = firstAllowed({ type: 'future', allowWeekends: false, minWorkingDaysBefore: 1 })) === null || _b === void 0 ? void 0 : _b.toString()).toEqual(toDate('8/11/2022').toString());
190
+ expect((_c = firstAllowed({ type: 'future', allowWeekends: false, minWorkingDaysBefore: 2 })) === null || _c === void 0 ? void 0 : _c.toString()).toEqual(toDate('9/11/2022').toString());
191
+ expect((_d = firstAllowed({ type: 'future', allowWeekends: false, minWorkingDaysBefore: 3 })) === null || _d === void 0 ? void 0 : _d.toString()).toEqual(toDate('10/11/2022').toString());
192
+ expect((_e = firstAllowed({ type: 'future', allowWeekends: false, minWorkingDaysBefore: 4 })) === null || _e === void 0 ? void 0 : _e.toString()).toEqual(toDate('11/11/2022').toString());
193
+ //weekend
194
+ expect((_f = firstAllowed({ type: 'future', allowWeekends: false, minWorkingDaysBefore: 5 })) === null || _f === void 0 ? void 0 : _f.toString()).toEqual(toDate('14/11/2022').toString());
195
+ expect((_g = firstAllowed({ type: 'future', allowWeekends: false, minWorkingDaysBefore: 6 })) === null || _g === void 0 ? void 0 : _g.toString()).toEqual(toDate('15/11/2022').toString());
196
+ expect((_h = firstAllowed({ type: 'future', allowWeekends: false, minWorkingDaysBefore: 7 })) === null || _h === void 0 ? void 0 : _h.toString()).toEqual(toDate('16/11/2022').toString());
197
+ expect((_j = firstAllowed({ type: 'future', allowWeekends: false, minWorkingDaysBefore: 8 })) === null || _j === void 0 ? void 0 : _j.toString()).toEqual(toDate('17/11/2022').toString());
198
+ expect((_k = firstAllowed({ type: 'future', allowWeekends: false, minWorkingDaysBefore: 9 })) === null || _k === void 0 ? void 0 : _k.toString()).toEqual(toDate('18/11/2022').toString());
199
+ expect((_l = firstAllowed({ type: 'future', allowWeekends: false, minWorkingDaysBefore: 10 })) === null || _l === void 0 ? void 0 : _l.toString()).toEqual(toDate('21/11/2022').toString());
200
+ expect((_m = firstAllowed({ type: 'future', allowWeekends: false, minWorkingDaysBefore: 20 })) === null || _m === void 0 ? void 0 : _m.toString()).toEqual(toDate('5/12/2022').toString());
201
+ });
202
+ it("should take account of holidays when those are not allowed", () => {
203
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
204
+ expect((_a = firstAllowed({ type: 'future', allowHolidays: false })) === null || _a === void 0 ? void 0 : _a.toString()).toEqual(toDate('7/11/2022').toString());
205
+ expect((_b = firstAllowed({ type: 'future', allowHolidays: false, minWorkingDaysBefore: 1 })) === null || _b === void 0 ? void 0 : _b.toString()).toEqual(toDate('8/11/2022').toString());
206
+ expect((_c = firstAllowed({ type: 'future', allowHolidays: false, minWorkingDaysBefore: 2 })) === null || _c === void 0 ? void 0 : _c.toString()).toEqual(toDate('9/11/2022').toString());
207
+ expect((_d = firstAllowed({ type: 'future', allowHolidays: false, minWorkingDaysBefore: 3 })) === null || _d === void 0 ? void 0 : _d.toString()).toEqual(toDate('10/11/2022').toString());
208
+ expect((_e = firstAllowed({ type: 'future', allowHolidays: false, minWorkingDaysBefore: 4 })) === null || _e === void 0 ? void 0 : _e.toString()).toEqual(toDate('11/11/2022').toString());
209
+ //holiday
210
+ expect((_f = firstAllowed({ type: 'future', allowHolidays: false, minWorkingDaysBefore: 5 })) === null || _f === void 0 ? void 0 : _f.toString()).toEqual(toDate('13/11/2022').toString());
211
+ expect((_g = firstAllowed({ type: 'future', allowHolidays: false, minWorkingDaysBefore: 6 })) === null || _g === void 0 ? void 0 : _g.toString()).toEqual(toDate('14/11/2022').toString());
212
+ //holiday
213
+ expect((_h = firstAllowed({ type: 'future', allowHolidays: false, minWorkingDaysBefore: 7 })) === null || _h === void 0 ? void 0 : _h.toString()).toEqual(toDate('16/11/2022').toString());
214
+ expect((_j = firstAllowed({ type: 'future', allowHolidays: false, minWorkingDaysBefore: 8 })) === null || _j === void 0 ? void 0 : _j.toString()).toEqual(toDate('17/11/2022').toString());
215
+ expect((_k = firstAllowed({ type: 'future', allowHolidays: false, minWorkingDaysBefore: 9 })) === null || _k === void 0 ? void 0 : _k.toString()).toEqual(toDate('18/11/2022').toString());
216
+ expect((_l = firstAllowed({ type: 'future', allowHolidays: false, minWorkingDaysBefore: 10 })) === null || _l === void 0 ? void 0 : _l.toString()).toEqual(toDate('19/11/2022').toString());
217
+ expect((_m = firstAllowed({ type: 'future', allowHolidays: false, minWorkingDaysBefore: 20 })) === null || _m === void 0 ? void 0 : _m.toString()).toEqual(toDate('29/11/2022').toString());
218
+ });
219
+ it("should take account of weekends holidays when those are not allowed", () => {
220
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
221
+ expect((_a = firstAllowed({ type: 'future', allowHolidays: false, allowWeekends: false })) === null || _a === void 0 ? void 0 : _a.toString()).toEqual(toDate('7/11/2022').toString());
222
+ expect((_b = firstAllowed({ type: 'future', allowHolidays: false, allowWeekends: false, minWorkingDaysBefore: 1 })) === null || _b === void 0 ? void 0 : _b.toString()).toEqual(toDate('8/11/2022').toString());
223
+ expect((_c = firstAllowed({ type: 'future', allowHolidays: false, allowWeekends: false, minWorkingDaysBefore: 2 })) === null || _c === void 0 ? void 0 : _c.toString()).toEqual(toDate('9/11/2022').toString());
224
+ expect((_d = firstAllowed({ type: 'future', allowHolidays: false, allowWeekends: false, minWorkingDaysBefore: 3 })) === null || _d === void 0 ? void 0 : _d.toString()).toEqual(toDate('10/11/2022').toString());
225
+ expect((_e = firstAllowed({ type: 'future', allowHolidays: false, allowWeekends: false, minWorkingDaysBefore: 4 })) === null || _e === void 0 ? void 0 : _e.toString()).toEqual(toDate('11/11/2022').toString());
226
+ //holiday & weekend
227
+ expect((_f = firstAllowed({ type: 'future', allowHolidays: false, allowWeekends: false, minWorkingDaysBefore: 5 })) === null || _f === void 0 ? void 0 : _f.toString()).toEqual(toDate('14/11/2022').toString());
228
+ //holiday
229
+ expect((_g = firstAllowed({ type: 'future', allowHolidays: false, allowWeekends: false, minWorkingDaysBefore: 6 })) === null || _g === void 0 ? void 0 : _g.toString()).toEqual(toDate('16/11/2022').toString());
230
+ expect((_h = firstAllowed({ type: 'future', allowHolidays: false, allowWeekends: false, minWorkingDaysBefore: 7 })) === null || _h === void 0 ? void 0 : _h.toString()).toEqual(toDate('17/11/2022').toString());
231
+ expect((_j = firstAllowed({ type: 'future', allowHolidays: false, allowWeekends: false, minWorkingDaysBefore: 8 })) === null || _j === void 0 ? void 0 : _j.toString()).toEqual(toDate('18/11/2022').toString());
232
+ //weekend
233
+ expect((_k = firstAllowed({ type: 'future', allowHolidays: false, allowWeekends: false, minWorkingDaysBefore: 9 })) === null || _k === void 0 ? void 0 : _k.toString()).toEqual(toDate('21/11/2022').toString());
234
+ expect((_l = firstAllowed({ type: 'future', allowHolidays: false, allowWeekends: false, minWorkingDaysBefore: 10 })) === null || _l === void 0 ? void 0 : _l.toString()).toEqual(toDate('22/11/2022').toString());
235
+ expect((_m = firstAllowed({ type: 'future', allowHolidays: false, allowWeekends: false, minWorkingDaysBefore: 20 })) === null || _m === void 0 ? void 0 : _m.toString()).toEqual(toDate('6/12/2022').toString());
236
+ });
237
+ });
238
+ describe("holidaysOk", () => {
239
+ // { date: '12/11/2022', jurisdiction: 'GB' },
240
+ // { date: '12/11/2022', jurisdiction: 'I' },
241
+ // { date: '15/11/2022', jurisdiction: 'GB' },
242
+ // { date: '17/11/2022', jurisdiction: 'I' },
243
+ it("should accept a date after the first valid date", () => {
244
+ const accept = (0, form_components_1.acceptDateForTest)(lenstate, 'GB', okDateInfo, { type: 'future', firstSelectableDatePath: 'doesntmatter because lenstopath is hardcoded' }, dateFormat, form_components_1.defaultDateErrorMessage);
245
+ expect(accept(new Date("2022/11/7"))).toEqual(["before first valid date"]);
246
+ expect(accept(new Date("2022/11/12"))).toEqual([]);
247
+ expect(accept(new Date("2022/11/15"))).toEqual([]);
248
+ expect(accept(new Date("2022/11/17"))).toEqual([]);
249
+ });
250
+ it("should return empty errors no matter the date if 'allowHolidays'is true", () => {
251
+ const accept = (0, form_components_1.acceptDateForTest)(lenstate, 'GB', okDateInfo, { type: 'future', allowHolidays: true }, dateFormat, form_components_1.defaultDateErrorMessage);
252
+ expect(accept(new Date("2022/11/7"))).toEqual([]); //today
253
+ expect(accept(new Date("2022/11/12"))).toEqual([]);
254
+ expect(accept(new Date("2022/11/15"))).toEqual([]);
255
+ expect(accept(new Date("2022/11/17"))).toEqual([]);
256
+ });
257
+ it("should return empty errors no matter the date if 'allowHolidays'is undefined", () => {
258
+ const accept = (0, form_components_1.acceptDateForTest)(lenstate, 'GB', okDateInfo, { type: 'future', allowHolidays: undefined }, dateFormat, form_components_1.defaultDateErrorMessage);
259
+ expect(accept(new Date("2022/11/7"))).toEqual([]); //today
260
+ expect(accept(new Date("2022/11/12"))).toEqual([]);
261
+ expect(accept(new Date("2022/11/15"))).toEqual([]);
262
+ expect(accept(new Date("2022/11/17"))).toEqual([]);
263
+ });
264
+ it("should return an error if 'allowHolidays'is false, and the date is a holiday in the jurisdiction", () => {
265
+ const accept = (0, form_components_1.acceptDateForTest)(lenstate, 'GB', okDateInfo, { type: 'future', allowHolidays: false }, dateFormat, form_components_1.defaultDateErrorMessage);
266
+ expect(accept(new Date("2022/11/7"))).toEqual([]); //today
267
+ expect(accept(new Date("2022/11/12"))).toEqual(["is a holiday"]);
268
+ expect(accept(new Date("2022/11/15"))).toEqual(["is a holiday"]);
269
+ expect(accept(new Date("2022/11/17"))).toEqual([]);
270
+ });
271
+ it("should return an error if 'allowHolidays'is false, and the date is a holiday in the jurisdiction, custom error message", () => {
272
+ const accept = (0, form_components_1.acceptDateForTest)(lenstate, 'GB', okDateInfo, { type: 'future', allowHolidays: false }, dateFormat, otherDateErrorMessage);
273
+ expect(accept(new Date("2022/11/7"))).toEqual([]); //today
274
+ expect(accept(new Date("2022/11/12"))).toEqual(["holidayMsg"]);
275
+ expect(accept(new Date("2022/11/15"))).toEqual(["holidayMsg"]);
276
+ expect(accept(new Date("2022/11/17"))).toEqual([]);
277
+ });
278
+ it("should return an error if 'allowHolidays'is false, and the date is a holiday in any jurisdiction when the jurisdiction is undefined", () => {
279
+ const accept = (0, form_components_1.acceptDateForTest)(lenstate, undefined, okDateInfo, { type: 'future', allowHolidays: false }, dateFormat, form_components_1.defaultDateErrorMessage);
280
+ expect(accept(new Date("2022/11/7"))).toEqual([]); //today
281
+ expect(accept(new Date("2022/11/12"))).toEqual(["is a holiday"]);
282
+ expect(accept(new Date("2022/11/15"))).toEqual(["is a holiday"]);
283
+ expect(accept(new Date("2022/11/17"))).toEqual(["is a holiday"]);
284
+ });
285
+ it("should return an error if 'allowHolidays'is false, and the date is a holiday in any jurisdiction when the jurisdiction is undefined, custom msg", () => {
286
+ const accept = (0, form_components_1.acceptDateForTest)(lenstate, undefined, okDateInfo, { type: 'future', allowHolidays: false }, dateFormat, otherDateErrorMessage);
287
+ expect(accept(new Date("2022/11/7"))).toEqual([]); //today
288
+ expect(accept(new Date("2022/11/12"))).toEqual(["holidayMsg"]);
289
+ expect(accept(new Date("2022/11/15"))).toEqual(["holidayMsg"]);
290
+ expect(accept(new Date("2022/11/17"))).toEqual(["holidayMsg"]);
291
+ });
292
+ });
293
+ // @ts-ignore
294
+ const context = {
295
+ combine: form_components_1.MyCombined,
296
+ pageSelectionL: (0, pages_1.pageSelectionlens)(),
297
+ pages: {}
298
+ };
299
+ const emptyState = {
300
+ messages: [], pageSelection: [], tags: {}
301
+ };
302
+ describe("DatePicker", () => {
303
+ const datePicker = (state, props, dateRange, remember) => (0, form_components_1.DatePicker)(Object.assign(Object.assign({}, props), { id: 'someId', label: 'someLabel', state: (0, state_1.lensState)(state, remember, '', context).focusOn('theDate'), dateFormat: 'dd/MM/yyyy', dateRange: {}, allButtons: {} }));
304
+ it("should display the undefined date, required is false, readonly undefined", () => {
305
+ const picker = (0, enzyme_1.mount)(datePicker(Object.assign(Object.assign({}, emptyState), { date: undefined }), { required: false }, {}, () => { }));
306
+ expect(picker.html().replace(/"/g, "'")).toEqual("<div class='labelAndDate '><label class='input-label'>someLabel</label><div class=' '><div class='react-datepicker-wrapper'><div class='react-datepicker__input-container'><input type='text' id='someId' placeholder='Select a date' class='' value=''></div></div></div></div>");
307
+ const input = picker.find("input");
308
+ input.simulate('click');
309
+ expect(picker.html().replace(/"/g, "'")).toContain("<div class='react-datepicker__tab-loop__start' tabindex='0'>");
310
+ });
311
+ it("should display the undefined date, required is true, readonly undefined - looking for marker that says 'I am needed'", () => {
312
+ const picker = (0, enzyme_1.mount)(datePicker(Object.assign(Object.assign({}, emptyState), { date: undefined }), { required: false }, {}, () => { }));
313
+ expect(picker.html().replace(/"/g, "'")).toEqual("<div class='labelAndDate '><label class='input-label'>someLabel</label><div class=' '><div class='react-datepicker-wrapper'><div class='react-datepicker__input-container'><input type='text' id='someId' placeholder='Select a date' class='' value=''></div></div></div></div>");
314
+ });
315
+ });
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const jsx_runtime_1 = require("react/jsx-runtime");
4
+ const enzymeAdapterSetup_1 = require("./enzymeAdapterSetup");
5
+ const form_components_1 = require("@focuson/form_components");
6
+ const enzyme_1 = require("enzyme");
7
+ const state_1 = require("@focuson/state");
8
+ const context_fixture_1 = require("./context.fixture");
9
+ (0, enzymeAdapterSetup_1.enzymeSetup)();
10
+ const empty = {
11
+ messages: [], pageSelection: [], restCommands: [], tags: {}
12
+ };
13
+ const lookup = {
14
+ a: 'A',
15
+ b: '<b>Some bold</b>',
16
+ };
17
+ function displayString(data, ifUndefined, className) {
18
+ const state = (0, state_1.lensState)(Object.assign(Object.assign({}, empty), { data }), () => { }, '', (0, context_fixture_1.context)());
19
+ // @ts-ignore
20
+ const focusedState = state.focusOn('data');
21
+ return (0, enzyme_1.mount)((0, jsx_runtime_1.jsx)(form_components_1.DisplayStringWithLookup, { lookup: lookup, state: focusedState, className: className, ifUndefined: ifUndefined, id: 'someId' })).html();
22
+ }
23
+ describe("DisplayStringWithLookup", () => {
24
+ it('should render with undefined', () => {
25
+ expect(displayString(undefined)).toEqual('<div id="someId"></div>');
26
+ expect(displayString(undefined, 'xxx')).toEqual('<div id="someId">xxx</div>');
27
+ expect(displayString(undefined, 'xxx', 'clazz')).toEqual('<div id="someId" class="clazz">xxx</div>');
28
+ });
29
+ it('should render when value not in lookup', () => {
30
+ expect(displayString('x')).toEqual('<div id="someId"></div>');
31
+ expect(displayString('x', 'xxx')).toEqual('<div id="someId">xxx</div>');
32
+ expect(displayString('x', 'xxx', 'clazz')).toEqual('<div id="someId" class="clazz">xxx</div>');
33
+ });
34
+ it('should render when valid value', () => {
35
+ expect(displayString('a')).toEqual('<div id="someId">A</div>');
36
+ expect(displayString('a', 'xxx')).toEqual('<div id="someId">A</div>');
37
+ expect(displayString('a', 'xxx', 'clazz')).toEqual('<div id="someId" class="clazz">A</div>');
38
+ });
39
+ it('should render Html', () => {
40
+ expect(displayString('b')).toEqual('<div id="someId"><b>Some bold</b></div>');
41
+ });
42
+ });
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,79 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const jsx_runtime_1 = require("react/jsx-runtime");
4
+ const enzyme_1 = require("enzyme");
5
+ const form_components_1 = require("@focuson/form_components");
6
+ const lens_1 = require("@focuson/lens");
7
+ const state_1 = require("@focuson/state");
8
+ const focuson_1 = require("@focuson/focuson");
9
+ const enzymeAdapterSetup_1 = require("./enzymeAdapterSetup");
10
+ const utils_1 = require("@focuson/utils");
11
+ (0, enzymeAdapterSetup_1.enzymeSetup)();
12
+ let pageSelection = { pageName: 'a', pageMode: 'view', time: 'now' };
13
+ const x = { g: 1, h: ['h0', 'h1'], i: { j: 2 } };
14
+ const textForLabelState = {
15
+ messages: [],
16
+ pageSelection: [pageSelection],
17
+ restCommands: [],
18
+ tags: {},
19
+ a: {
20
+ 'false': false,
21
+ 'true': true,
22
+ b: { c: 'cValue', x },
23
+ d: ['zero', 'one', 'two', 'three', 'four', 'five'],
24
+ selecteda: 3,
25
+ e: 5,
26
+ f: 6,
27
+ holdse: 'e',
28
+ holdsf: 'e',
29
+ },
30
+ selected: 2,
31
+ holdseinroot: 'e'
32
+ };
33
+ const identity = lens_1.Lenses.identity();
34
+ const aL = identity.focusQuery('a');
35
+ const abL = identity.focusOn('a').focusQuery('b');
36
+ const abxL = identity.focusOn('a').focusQuery('b').focusQuery('x');
37
+ const pageDetails = {
38
+ a: { config: {}, pageType: 'MainPage', pageFunction: () => (0, jsx_runtime_1.jsx)("span", {}), lens: aL, pageMode: 'edit' }
39
+ };
40
+ const state = (0, state_1.lensState)(textForLabelState, s => { }, '', (0, focuson_1.defaultPageSelectionAndRestCommandsContext)(pageDetails, {}, {}, {}, utils_1.testDateFn, true));
41
+ // const fromPath: ( path: string[], description?: string ) => Optional<TextForLabelState, any> = fromPathFor ( state )
42
+ // let stateabx = state.copyWithLens ( abxL );
43
+ // const fromL = ( path: string ) => fromPathGivenState ( stateabx ) ( path )
44
+ // const from = ( path: string ) => fromL ( path ).getOption ( state.main )
45
+ // const set = ( path: string, value: any ) => fromL ( path ).set ( state.main, value )
46
+ describe("Label", () => {
47
+ it("should display plain text", () => {
48
+ const nav = (0, enzyme_1.shallow)((0, jsx_runtime_1.jsx)(form_components_1.Label, { state: state, label: 'Hello World' }));
49
+ expect(nav.html()).toEqual('<label class="input-label">Hello World</label>');
50
+ });
51
+ it("should display the text at the end of a path", () => {
52
+ const nav = (0, enzyme_1.shallow)((0, jsx_runtime_1.jsx)(form_components_1.Label, { state: state, label: 'Hello {~/e} World' }));
53
+ expect(nav.html()).toEqual('<label class="input-label">Hello 5 World</label>');
54
+ });
55
+ it("should display the text at the end of a path with [$last]", () => {
56
+ const nav = (0, enzyme_1.shallow)((0, jsx_runtime_1.jsx)(form_components_1.Label, { state: state, label: 'Hello {~/d[$last]} World' }));
57
+ expect(nav.html()).toEqual('<label class="input-label">Hello five World</label>');
58
+ });
59
+ it("should display the text at the end of a path with [~/e]", () => {
60
+ const nav = (0, enzyme_1.shallow)((0, jsx_runtime_1.jsx)(form_components_1.Label, { state: state, label: 'Hello {~/d[~/e]} World' }));
61
+ expect(nav.html()).toEqual('<label class="input-label">Hello five World</label>');
62
+ });
63
+ it("should display the text using lookup from boolean {boolean|if false|if true} - false", () => {
64
+ const nav = (0, enzyme_1.shallow)((0, jsx_runtime_1.jsx)(form_components_1.Label, { state: state, label: 'Hello {~/false|falseHappened|trueHappened} World' }));
65
+ expect(nav.html()).toEqual('<label class="input-label">Hello falseHappened World</label>');
66
+ });
67
+ it("should display the text using lookup from boolean {boolean|if false|if true} - true", () => {
68
+ const nav = (0, enzyme_1.shallow)((0, jsx_runtime_1.jsx)(form_components_1.Label, { state: state, label: 'Hello {~/true|falseHappened|trueHappened} World' }));
69
+ expect(nav.html()).toEqual('<label class="input-label">Hello trueHappened World</label>');
70
+ });
71
+ it("should display the text using lookup from number {number|if 0| if 1| if 2} - false", () => {
72
+ const nav = (0, enzyme_1.shallow)((0, jsx_runtime_1.jsx)(form_components_1.Label, { state: state, label: 'Hello {~/e|zero|one|two|three|four|five} World' }));
73
+ expect(nav.html()).toEqual('<label class="input-label">Hello five World</label>');
74
+ });
75
+ it("should display the text using html", () => {
76
+ const nav = (0, enzyme_1.shallow)((0, jsx_runtime_1.jsx)(form_components_1.Label, { state: state, label: 'Hello <b>world</b>' }));
77
+ expect(nav.html()).toEqual('<label class="input-label">Hello <b>world</b></label>');
78
+ });
79
+ });
@@ -0,0 +1 @@
1
+ export {};