@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.
- package/README.md +6 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +18 -0
- package/dist/src/DataDrivenFixedOptionDropDownAndDetails.spec.d.ts +1 -0
- package/dist/src/DataDrivenFixedOptionDropDownAndDetails.spec.js +70 -0
- package/dist/src/DatePicker.spec.d.ts +1 -0
- package/dist/src/DatePicker.spec.js +315 -0
- package/dist/src/DisplayStringWithLookup.spec.d.ts +1 -0
- package/dist/src/DisplayStringWithLookup.spec.js +42 -0
- package/dist/src/Label.spec.d.ts +1 -0
- package/dist/src/Label.spec.js +79 -0
- package/dist/src/Lens.spec.d.ts +1 -0
- package/dist/src/Lens.spec.js +164 -0
- package/dist/src/LensFixture.d.ts +28 -0
- package/dist/src/LensFixture.js +15 -0
- package/dist/src/LensState.spec.d.ts +1 -0
- package/dist/src/LensState.spec.js +100 -0
- package/dist/src/MonthYearDataPickerWithLength.spec.d.ts +1 -0
- package/dist/src/MonthYearDataPickerWithLength.spec.js +21 -0
- package/dist/src/WithTextLayout.spec.d.ts +1 -0
- package/dist/src/WithTextLayout.spec.js +29 -0
- package/dist/src/actions.spec.d.ts +1 -0
- package/dist/src/actions.spec.js +40 -0
- package/dist/src/composition.spec.d.ts +1 -0
- package/dist/src/composition.spec.js +28 -0
- package/dist/src/context.fixture.d.ts +6 -0
- package/dist/src/context.fixture.js +9 -0
- package/dist/src/dateutils.spec.d.ts +1 -0
- package/dist/src/dateutils.spec.js +166 -0
- package/dist/src/deleteState.spec.d.ts +1 -0
- package/dist/src/deleteState.spec.js +36 -0
- package/dist/src/dropdown.spec.d.ts +1 -0
- package/dist/src/dropdown.spec.js +46 -0
- package/dist/src/enzymeAdapterSetup.d.ts +1 -0
- package/dist/src/enzymeAdapterSetup.js +12 -0
- package/dist/src/fetcher.fixture.d.ts +38 -0
- package/dist/src/fetcher.fixture.js +20 -0
- package/dist/src/fetchers.spec.d.ts +1 -0
- package/dist/src/fetchers.spec.js +346 -0
- package/dist/src/focusedPage.spec.d.ts +1 -0
- package/dist/src/focusedPage.spec.js +70 -0
- package/dist/src/labelAnd.spec.d.ts +1 -0
- package/dist/src/labelAnd.spec.js +105 -0
- package/dist/src/labelAndDateInput.spec.d.ts +1 -0
- package/dist/src/labelAndDateInput.spec.js +26 -0
- package/dist/src/lenspath.spec.d.ts +1 -0
- package/dist/src/lenspath.spec.js +171 -0
- package/dist/src/memoisation.spec.d.ts +1 -0
- package/dist/src/memoisation.spec.js +11 -0
- package/dist/src/messages.spec.d.ts +1 -0
- package/dist/src/messages.spec.js +34 -0
- package/dist/src/modalButton.integration.spec.d.ts +23 -0
- package/dist/src/modalButton.integration.spec.js +299 -0
- package/dist/src/modalButton.spec.d.ts +1 -0
- package/dist/src/modalButton.spec.js +147 -0
- package/dist/src/newFetchers.spec.d.ts +1 -0
- package/dist/src/newFetchers.spec.js +214 -0
- package/dist/src/optics.spec.d.ts +2 -0
- package/dist/src/optics.spec.js +195 -0
- package/dist/src/page.fixture.d.ts +30 -0
- package/dist/src/page.fixture.js +55 -0
- package/dist/src/pageSelection.spec.d.ts +1 -0
- package/dist/src/pageSelection.spec.js +146 -0
- package/dist/src/post.spec.d.ts +1 -0
- package/dist/src/post.spec.js +84 -0
- package/dist/src/postButton.spec.d.ts +2 -0
- package/dist/src/postButton.spec.js +26 -0
- package/dist/src/preMutate.spec.d.ts +1 -0
- package/dist/src/preMutate.spec.js +63 -0
- package/dist/src/radioButton.spec.d.ts +1 -0
- package/dist/src/radioButton.spec.js +48 -0
- package/dist/src/restButton.spec.d.ts +13 -0
- package/dist/src/restButton.spec.js +95 -0
- package/dist/src/selectedItem.spec.d.ts +1 -0
- package/dist/src/selectedItem.spec.js +50 -0
- package/dist/src/stateAndFromApiTagFetcher.spec.d.ts +1 -0
- package/dist/src/stateAndFromApiTagFetcher.spec.js +59 -0
- package/dist/src/table.spec.d.ts +1 -0
- package/dist/src/table.spec.js +215 -0
- package/dist/src/tagFetcher.fixture.d.ts +7 -0
- package/dist/src/tagFetcher.fixture.js +16 -0
- package/dist/src/tagFetcher.spec.d.ts +1 -0
- package/dist/src/tagFetcher.spec.js +67 -0
- package/dist/src/template.spec.d.ts +1 -0
- package/dist/src/template.spec.js +58 -0
- package/dist/src/utils.spec.d.ts +1 -0
- package/dist/src/utils.spec.js +61 -0
- package/package.json +96 -0
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const lens_1 = require("@focuson/lens");
|
|
4
|
+
describe('tokenisepath', () => {
|
|
5
|
+
it("should extract the prefix as a token, replacing 'no prefix with ''", () => {
|
|
6
|
+
expect((0, lens_1.tokenisePath)('a')).toEqual(['a']);
|
|
7
|
+
expect((0, lens_1.tokenisePath)('a/b')).toEqual(['a', '/', 'b']);
|
|
8
|
+
expect((0, lens_1.tokenisePath)('one/two/three')).toEqual(['one', '/', 'two', '/', 'three']);
|
|
9
|
+
expect((0, lens_1.tokenisePath)('/one/two/three')).toEqual(['/', 'one', '/', 'two', '/', 'three']);
|
|
10
|
+
expect((0, lens_1.tokenisePath)('~one/two/three')).toEqual(['~', 'one', '/', 'two', '/', 'three']);
|
|
11
|
+
expect((0, lens_1.tokenisePath)('')).toEqual([]);
|
|
12
|
+
expect((0, lens_1.tokenisePath)('/')).toEqual(['/']);
|
|
13
|
+
expect((0, lens_1.tokenisePath)('~')).toEqual(['~']);
|
|
14
|
+
expect((0, lens_1.tokenisePath)('$variable')).toEqual(['$variable']); // no prefix
|
|
15
|
+
expect((0, lens_1.tokenisePath)("/one[$var]")).toEqual(["/", "one", "$var"]);
|
|
16
|
+
});
|
|
17
|
+
it("should tokenise [ ... ] with simple content", () => {
|
|
18
|
+
expect((0, lens_1.tokenisePath)('/one[a]/two[b]/three[c]')).toEqual([
|
|
19
|
+
"/", "one", "[", "a", "]", "/", "two", "[", "b", "]", "/", "three", "[", "c", "]"
|
|
20
|
+
]);
|
|
21
|
+
});
|
|
22
|
+
it("should tokenise [ ... ] with numbers", () => {
|
|
23
|
+
expect((0, lens_1.tokenisePath)('/one[1]/two[2]/three[3]')).toEqual([
|
|
24
|
+
"/", "one", "$1", "/", "two", "$2", "/", "three", "$3"
|
|
25
|
+
]);
|
|
26
|
+
});
|
|
27
|
+
it("should tokenise [ ... ] with $tokens", () => {
|
|
28
|
+
expect((0, lens_1.tokenisePath)('/a[$one]/bb[$two]/ccc[$three]')).toEqual([
|
|
29
|
+
"/", "a", "$one", "/", "bb", "$two", "/", "ccc", "$three"
|
|
30
|
+
]);
|
|
31
|
+
});
|
|
32
|
+
it("should tokenise [ ... ] with path in the []", () => {
|
|
33
|
+
expect((0, lens_1.tokenisePath)('/one[a/b]/two[/bbb/ccc]/three[~/ccc]')).toEqual([
|
|
34
|
+
"/", "one", "[", "a", "/", "b", "]", "/", "two", "[", "/", "bbb", "/", "ccc", "]", "/", "three", "[", "~", "/", "ccc", "]"
|
|
35
|
+
]);
|
|
36
|
+
});
|
|
37
|
+
it("should tokenise [ ... ] with path in the [] and a $ or two", () => {
|
|
38
|
+
expect((0, lens_1.tokenisePath)('/one[$next]/two[bbb/ccc]/three[~/ccc][$next]')).toEqual([
|
|
39
|
+
"/", "one", "$next", "/", "two", "[", "bbb", "/", "ccc", "]", "/", "three", "[", "~", "/", "ccc", "]", "$next"
|
|
40
|
+
]);
|
|
41
|
+
});
|
|
42
|
+
it("should tokenise the common usages of #", () => {
|
|
43
|
+
expect((0, lens_1.tokenisePath)('#variable')).toEqual(["#variable"]);
|
|
44
|
+
expect((0, lens_1.tokenisePath)('#var1[#var2]')).toEqual(["#var1", "[", "#var2", "]"]);
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
const stringBuilder = {
|
|
48
|
+
initialVariable(name) { return `initialV(${name})`; },
|
|
49
|
+
isVariable(name) { return !name.match(/^[0-9]+$/); },
|
|
50
|
+
foldVariable(acc, name) { return acc + `.variable(${name})`; },
|
|
51
|
+
zero(initial) { return `#${initial}#`; },
|
|
52
|
+
foldAppend(acc) { return acc + '.APPEND'; },
|
|
53
|
+
foldLast(acc) { return acc + '.LAST'; },
|
|
54
|
+
foldNth(acc, n) { return acc + `.[${n}]`; },
|
|
55
|
+
foldBracketsPath(acc, path) { return acc + '.OPEN[' + path + ']CLOSE'; },
|
|
56
|
+
foldKey(acc, key) { return acc + '.' + key; }
|
|
57
|
+
};
|
|
58
|
+
describe("parsePath", () => {
|
|
59
|
+
it("should fold the tokens", () => {
|
|
60
|
+
expect((0, lens_1.parsePath)('/one[$last]/two[bbb/ccc]/three[~/ccc][1][$append]/[#var]', stringBuilder)).toEqual('#/#.one.LAST.two.OPEN[##.bbb.ccc]CLOSE.three.OPEN[#~#.ccc]CLOSE.[1].APPEND.OPEN[initialV(var)]CLOSE');
|
|
61
|
+
});
|
|
62
|
+
it("should fold 'just a variable name'", () => {
|
|
63
|
+
expect((0, lens_1.parsePath)('#name', stringBuilder)).toEqual('initialV(name)');
|
|
64
|
+
});
|
|
65
|
+
it("should fold '#var1[#var2]", () => {
|
|
66
|
+
expect((0, lens_1.parsePath)('#var1[#var2]', stringBuilder)).toEqual('initialV(var1).OPEN[initialV(var2)]CLOSE');
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
const someData = {
|
|
70
|
+
a: {
|
|
71
|
+
b: {
|
|
72
|
+
c: 'cValue', d: 'dValue',
|
|
73
|
+
},
|
|
74
|
+
e: ['zero', 'one'],
|
|
75
|
+
v0: 0,
|
|
76
|
+
v1: 1,
|
|
77
|
+
vc: 'c',
|
|
78
|
+
vd: 'd',
|
|
79
|
+
vfalse: false,
|
|
80
|
+
vtrue: true
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
const id = lens_1.Lenses.identity();
|
|
84
|
+
function makeAbL(path) {
|
|
85
|
+
return id.focusQuery('a').focusQuery('b').chainCalc(path);
|
|
86
|
+
}
|
|
87
|
+
function makeAEL(path) {
|
|
88
|
+
return id.focusQuery('a').focusQuery('e').chainCalc(path);
|
|
89
|
+
}
|
|
90
|
+
describe("calculateNth", () => {
|
|
91
|
+
it("should use the data at the end of pathL as an index into first - string", () => {
|
|
92
|
+
expect(makeAbL(id.focusQuery('a').focusQuery('vc')).getOption(someData)).toEqual('cValue');
|
|
93
|
+
expect(makeAbL(id.focusQuery('a').focusQuery('vd')).getOption(someData)).toEqual('dValue');
|
|
94
|
+
});
|
|
95
|
+
it("should use the data at the end of pathL as an index into first - numbers", () => {
|
|
96
|
+
expect(makeAEL(id.focusQuery('a').focusQuery('v0')).getOption(someData)).toEqual('zero');
|
|
97
|
+
expect(makeAEL(id.focusQuery('a').focusQuery('v1')).getOption(someData)).toEqual('one');
|
|
98
|
+
});
|
|
99
|
+
it("should use the data at the end of pathL as an index into first - boolean", () => {
|
|
100
|
+
expect(makeAEL(id.focusQuery('a').focusQuery('vfalse')).getOption(someData)).toEqual('zero');
|
|
101
|
+
expect(makeAEL(id.focusQuery('a').focusQuery('vtrue')).getOption(someData)).toEqual('one');
|
|
102
|
+
});
|
|
103
|
+
});
|
|
104
|
+
describe("chainIntoArray", () => {
|
|
105
|
+
function makeLens(fn) { return fn(id.focusQuery('a')).chainIntoArray(['x', 'y', 'z']); }
|
|
106
|
+
const data = { a: { v0: 0, v1: 1, vt: true, vf: false }, b: 'stuff' };
|
|
107
|
+
it("should make an optional that uses the value focused on to select an element of an array", () => {
|
|
108
|
+
expect(makeLens(s => s.focusQuery('v0')).getOption(data)).toEqual('x');
|
|
109
|
+
expect(makeLens(s => s.focusQuery('v0')).setOption(data, 'y')).toEqual({ "a": { "v0": 1, "v1": 1, "vf": false, "vt": true }, "b": "stuff" });
|
|
110
|
+
expect(makeLens(s => s.focusQuery('v1')).getOption(data)).toEqual('y');
|
|
111
|
+
expect(makeLens(s => s.focusQuery('v1')).setOption(data, 'z')).toEqual({ "a": { "v0": 0, "v1": 2, "vf": false, "vt": true }, "b": "stuff" });
|
|
112
|
+
expect(makeLens(s => s.focusQuery('vt')).getOption(data)).toEqual('y');
|
|
113
|
+
expect(makeLens(s => s.focusQuery('vt')).setOption(data, 'x')).toEqual({ "a": { "v0": 0, "v1": 1, "vf": false, "vt": 0 }, "b": "stuff" });
|
|
114
|
+
expect(makeLens(s => s.focusQuery('vf')).getOption(data)).toEqual('x');
|
|
115
|
+
expect(makeLens(s => s.focusQuery('vf')).setOption(data, 'y')).toEqual({ "a": { "v0": 0, "v1": 1, "vf": 1, "vt": true }, "b": "stuff" });
|
|
116
|
+
expect(makeLens(s => s.focusQuery('vf')).description).toEqual("chainIntoArray(x,y,z)");
|
|
117
|
+
});
|
|
118
|
+
});
|
|
119
|
+
describe("parsePathMakingLens", () => {
|
|
120
|
+
const optionals = {
|
|
121
|
+
a: l => l.focusQuery('a'),
|
|
122
|
+
b: l => l.focusQuery('a').focusQuery('b'),
|
|
123
|
+
};
|
|
124
|
+
it("should make an optional", () => {
|
|
125
|
+
expect((0, lens_1.parsePath)('/', (0, lens_1.lensBuilder)((0, lens_1.prefixNameAndLens)(), optionals)).description).toEqual('I');
|
|
126
|
+
expect((0, lens_1.parsePath)('/a/v0', (0, lens_1.lensBuilder)((0, lens_1.prefixNameAndLens)(), optionals)).description).toEqual('I.focus?(a).focus?(v0)');
|
|
127
|
+
expect((0, lens_1.parsePath)('/a/$last', (0, lens_1.lensBuilder)((0, lens_1.prefixNameAndLens)(), optionals)).description).toEqual('I.focus?(a).chain([last])');
|
|
128
|
+
expect((0, lens_1.parsePath)('/a/$append', (0, lens_1.lensBuilder)((0, lens_1.prefixNameAndLens)(), optionals)).description).toEqual('I.focus?(a).chain([append])');
|
|
129
|
+
expect((0, lens_1.parsePath)('/a/[1]', (0, lens_1.lensBuilder)((0, lens_1.prefixNameAndLens)(), optionals)).description).toEqual('I.focus?(a).chain([1])');
|
|
130
|
+
expect((0, lens_1.parsePath)('/a/[/a/b]', (0, lens_1.lensBuilder)((0, lens_1.prefixNameAndLens)(), optionals)).description).toEqual('I.focus?(a).chainCalc(I.focus?(a).focus?(b))');
|
|
131
|
+
expect((0, lens_1.parsePath)('/a/[b]', (0, lens_1.lensBuilder)((0, lens_1.prefixNameAndLens)(['', id.focusQuery('a')]), optionals)).description).toEqual('I.focus?(a).chainCalc(I.focus?(a).focus?(b))');
|
|
132
|
+
// expect ( parsePath ( '', lensBuilder ( prefixNameAndLens () ) ) ).toEqual ( undefined )
|
|
133
|
+
});
|
|
134
|
+
it("should throw error if the initial isn't defined", () => {
|
|
135
|
+
expect(() => (0, lens_1.parsePath)('a/b', (0, lens_1.lensBuilder)((0, lens_1.prefixNameAndLens)(), optionals))).toThrow("Error parsing 'a/b'. Cannot find initial ''");
|
|
136
|
+
});
|
|
137
|
+
it("should use variables", () => {
|
|
138
|
+
expect((0, lens_1.parsePath)('/a/#b', (0, lens_1.lensBuilder)((0, lens_1.prefixNameAndLens)(), optionals)).description).toEqual('I.focus?(a).chain(I.focus?(a).focus?(b))');
|
|
139
|
+
expect((0, lens_1.parsePath)('/a/#a', (0, lens_1.lensBuilder)((0, lens_1.prefixNameAndLens)(), optionals)).description).toEqual('I.focus?(a).chain(I.focus?(a))');
|
|
140
|
+
expect((0, lens_1.parsePath)('#a', (0, lens_1.lensBuilder)((0, lens_1.prefixNameAndLens)(), optionals)).description).toEqual('I.focus?(a)');
|
|
141
|
+
expect((0, lens_1.parsePath)('#b', (0, lens_1.lensBuilder)((0, lens_1.prefixNameAndLens)(), optionals)).description).toEqual('I.focus?(a).focus?(b)');
|
|
142
|
+
});
|
|
143
|
+
it("should work in the style $currentOccupation[$selected]/occupation", () => {
|
|
144
|
+
const data = {
|
|
145
|
+
cur: [{ occupation: 'zero' }, { occupation: 'one' }],
|
|
146
|
+
selected: 1
|
|
147
|
+
};
|
|
148
|
+
const optionals = {
|
|
149
|
+
currentOccupation: l => l.focusQuery('cur'),
|
|
150
|
+
selected: l => l.focusQuery('selected')
|
|
151
|
+
};
|
|
152
|
+
let builder = (0, lens_1.lensBuilder)((0, lens_1.prefixNameAndLens)(), optionals);
|
|
153
|
+
expect((0, lens_1.tokenisePath)('#currentOccupation[#selected]/occupation')).toEqual([
|
|
154
|
+
"#currentOccupation", "[", "#selected", "]", "/", "occupation"
|
|
155
|
+
]);
|
|
156
|
+
let lens = (0, lens_1.parsePath)('#currentOccupation[#selected]/occupation', builder);
|
|
157
|
+
expect(lens.description).toEqual('I.focus?(cur).chainCalc(I.focus?(selected)).focus?(occupation)');
|
|
158
|
+
expect(lens.getOption(data)).toEqual('one');
|
|
159
|
+
});
|
|
160
|
+
});
|
|
161
|
+
describe("parseMakingCode", () => {
|
|
162
|
+
const initials = (0, lens_1.stateCodeInitials)('FState');
|
|
163
|
+
it("should make code", () => {
|
|
164
|
+
expect((0, lens_1.parsePath)('/a/v0', (0, lens_1.stateCodeBuilder)(initials, 'opts'))).toEqual("state.copyWithIdentity().focusQuery('a').focusQuery('v0')");
|
|
165
|
+
expect((0, lens_1.parsePath)('~/a/$last', (0, lens_1.stateCodeBuilder)(initials, 'opts'))).toEqual("fullState.focusQuery('a').chain(Lenses.last())");
|
|
166
|
+
expect((0, lens_1.parsePath)('a/$append', (0, lens_1.stateCodeBuilder)(initials, 'opts'))).toEqual("state.focusQuery('a').chain(Lenses.append())");
|
|
167
|
+
expect((0, lens_1.parsePath)('a/[1]', (0, lens_1.stateCodeBuilder)(initials, 'opts'))).toEqual("state.focusQuery('a').chain(Lenses.nth(1))");
|
|
168
|
+
expect((0, lens_1.parsePath)('/a/[/a/b]', (0, lens_1.stateCodeBuilder)(initials, 'opts'))).toEqual("state.copyWithIdentity().focusQuery('a').chainNthFromPath(state.copyWithIdentity().focusQuery('a').focusQuery('b'))");
|
|
169
|
+
expect((0, lens_1.parsePath)('/a/[b]', (0, lens_1.stateCodeBuilder)(initials, 'opts'))).toEqual("state.copyWithIdentity().focusQuery('a').chainNthFromPath(state.focusQuery('b'))");
|
|
170
|
+
});
|
|
171
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const utils_1 = require("@focuson/utils");
|
|
4
|
+
describe("memoisation", () => {
|
|
5
|
+
it("should return the value if already in and generate it if it isn't in", () => {
|
|
6
|
+
expect((0, utils_1.memoise)("type1", "key1")(() => 'one_one')).toEqual("one_one");
|
|
7
|
+
expect((0, utils_1.memoise)("type1", "key2")(() => 'one_two')).toEqual("one_two");
|
|
8
|
+
expect((0, utils_1.memoise)("type1", "key1")(() => { throw new Error(); })).toEqual("one_one");
|
|
9
|
+
expect((0, utils_1.memoise)("type1", "key2")(() => { throw new Error(); })).toEqual("one_two");
|
|
10
|
+
});
|
|
11
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const pages_1 = require("@focuson/pages");
|
|
4
|
+
const rest_1 = require("@focuson/rest");
|
|
5
|
+
const msg0 = { "level": "info", "msg": "the info message", "time": "2022-09-19T16:55:41.018Z" };
|
|
6
|
+
const msg1 = { "level": "error", "msg": "the error message {/CommonIds/accountId}", "time": "2022-09-19T16:54:41.018Z" };
|
|
7
|
+
const msg2 = { "level": "warning", "msg": "the warning message", "time": "2022-09-19T16:53:41.018Z" };
|
|
8
|
+
const msg3 = { "level": "info", "msg": "loading the authorised charges", "time": "2022-09-19T16:52:41.018Z" };
|
|
9
|
+
const dateFn = () => '2022-09-19T16:55:41.018Z';
|
|
10
|
+
function addToState(...messages) {
|
|
11
|
+
return ({ messages });
|
|
12
|
+
}
|
|
13
|
+
const someMessages = addToState(msg0, msg1, msg2, msg3);
|
|
14
|
+
describe("", () => {
|
|
15
|
+
it("Should not remove anything if the delayBeforeMessagesRemoved are undefined", () => {
|
|
16
|
+
expect((0, pages_1.removeOldMessages)(dateFn, (0, pages_1.simpleMessagesL)(), undefined)(someMessages)).toEqual(someMessages);
|
|
17
|
+
});
|
|
18
|
+
it("Should not remove messages older than the delayBeforeMessagesRemoved in milliseconds ", () => {
|
|
19
|
+
expect((0, pages_1.removeOldMessages)(dateFn, (0, pages_1.simpleMessagesL)(), 100)(someMessages)).toEqual(addToState(msg0));
|
|
20
|
+
expect((0, pages_1.removeOldMessages)(dateFn, (0, pages_1.simpleMessagesL)(), 60100)(someMessages)).toEqual(addToState(msg0, msg1));
|
|
21
|
+
expect((0, pages_1.removeOldMessages)(dateFn, (0, pages_1.simpleMessagesL)(), 120100)(someMessages)).toEqual(addToState(msg0, msg1, msg2));
|
|
22
|
+
expect((0, pages_1.removeOldMessages)(dateFn, (0, pages_1.simpleMessagesL)(), 180100)(someMessages)).toEqual(addToState(msg0, msg1, msg2, msg3));
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
describe("infoToSuccessMessagesPostProcessor", () => {
|
|
26
|
+
const processor = rest_1.infoToSuccessMessagesPostProcessor;
|
|
27
|
+
const msg1 = { msg: 'm1', level: 'info', time: 'someTime' };
|
|
28
|
+
const msg1AsSuccess = { msg: 'm1', level: 'success', time: 'someTime' };
|
|
29
|
+
const msg2 = { msg: 'm2', level: 'warning', time: 'someTime' };
|
|
30
|
+
const msg3 = { msg: 'm3', level: 'error', time: 'someTime' };
|
|
31
|
+
const msg4 = { msg: 'm4', level: 'success', time: 'someTime' };
|
|
32
|
+
expect(processor([])).toEqual([]);
|
|
33
|
+
expect(processor([msg1, msg2, msg3, msg4])).toEqual([msg1AsSuccess, msg2, msg3, msg4]);
|
|
34
|
+
});
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { HasPageSelection } from "@focuson/pages";
|
|
2
|
+
import { HasRestCommands } from "@focuson/rest";
|
|
3
|
+
import { SimpleMessage } from "@focuson/utils";
|
|
4
|
+
import { HasTagHolder } from "@focuson/template";
|
|
5
|
+
interface ModalChildData {
|
|
6
|
+
data: string;
|
|
7
|
+
}
|
|
8
|
+
interface PageData {
|
|
9
|
+
child?: ModalChildData;
|
|
10
|
+
list?: ModalChildData[];
|
|
11
|
+
temp?: ModalChildData;
|
|
12
|
+
tempAr?: ModalChildData[];
|
|
13
|
+
index?: number;
|
|
14
|
+
nested?: {
|
|
15
|
+
child?: ModalChildData;
|
|
16
|
+
list?: ModalChildData[];
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
export interface ModalButtonStateForTest extends HasPageSelection, HasRestCommands, HasTagHolder {
|
|
20
|
+
messages: SimpleMessage[];
|
|
21
|
+
mainPage: PageData;
|
|
22
|
+
}
|
|
23
|
+
export {};
|
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
4
|
+
const pages_1 = require("@focuson/pages");
|
|
5
|
+
const rest_1 = require("@focuson/rest");
|
|
6
|
+
const state_1 = require("@focuson/state");
|
|
7
|
+
const enzyme_1 = require("enzyme");
|
|
8
|
+
const enzymeAdapterSetup_1 = require("./enzymeAdapterSetup");
|
|
9
|
+
const utils_1 = require("@focuson/utils");
|
|
10
|
+
const lens_1 = require("@focuson/lens");
|
|
11
|
+
(0, enzymeAdapterSetup_1.enzymeSetup)();
|
|
12
|
+
const emptyS = {
|
|
13
|
+
messages: [],
|
|
14
|
+
tags: {},
|
|
15
|
+
pageSelection: [{ "pageName": "mainPage", "pageMode": "view", time: 'now' }],
|
|
16
|
+
restCommands: [],
|
|
17
|
+
mainPage: {}
|
|
18
|
+
};
|
|
19
|
+
const emptyNestedS = Object.assign(Object.assign({}, emptyS), { mainPage: { nested: {} } });
|
|
20
|
+
const dataS = Object.assign(Object.assign({}, emptyS), { mainPage: { child: { data: 'a' } } });
|
|
21
|
+
const nestedS = Object.assign(Object.assign({}, emptyS), { mainPage: { nested: { child: { data: 'a' } } } });
|
|
22
|
+
const listS = Object.assign(Object.assign({}, emptyS), { mainPage: {
|
|
23
|
+
index: 1,
|
|
24
|
+
list: [{ data: '0' }, { data: '1' }, { data: '2' }]
|
|
25
|
+
} });
|
|
26
|
+
const pageDetails = { mainPage: { lens: (0, lens_1.identityOptics)().focusQuery('mainPage'), pageType: 'MainPage', pageFunction: () => (0, jsx_runtime_1.jsx)("span", {}), config: {}, pageMode: 'edit' } };
|
|
27
|
+
const context = {
|
|
28
|
+
restL: (0, rest_1.restL)(),
|
|
29
|
+
combine: (state, pages) => (0, jsx_runtime_1.jsx)("div", { children: pages.map(p => p.element) }),
|
|
30
|
+
pageSelectionL: (0, pages_1.pageSelectionlens)(),
|
|
31
|
+
simpleMessagesL: (0, pages_1.simpleMessagesL)(),
|
|
32
|
+
pathToLens: (0, pages_1.fromPathFromRaw)((0, pages_1.pageSelectionlens)(), pageDetails),
|
|
33
|
+
pages: pageDetails,
|
|
34
|
+
commonIds: {},
|
|
35
|
+
newFetchers: {},
|
|
36
|
+
dateFn: utils_1.testDateFn,
|
|
37
|
+
restDetails: {},
|
|
38
|
+
closeOnePageTxs: pages_1.rawCloseOnePageTxs,
|
|
39
|
+
tagHolderL: lens_1.Lenses.identity().focusQuery('tags'),
|
|
40
|
+
currentState(state) { return state; },
|
|
41
|
+
messagePostProcessor: {},
|
|
42
|
+
mockJwt: true
|
|
43
|
+
};
|
|
44
|
+
function displayAndGetButton(s, setMain, fn) {
|
|
45
|
+
const comp = (0, enzyme_1.shallow)(fn((0, state_1.lensState)(s, setMain, 'ModalButton', context).focusOn('mainPage')));
|
|
46
|
+
return comp.find("button");
|
|
47
|
+
}
|
|
48
|
+
describe("modal buttons", () => {
|
|
49
|
+
describe("with single child", () => {
|
|
50
|
+
it("should copy", () => {
|
|
51
|
+
var remembered = {};
|
|
52
|
+
const button = displayAndGetButton(dataS, s => remembered = s, state => (0, jsx_runtime_1.jsx)(pages_1.ModalButton, { text: 'someTitle', id: 'someId', state: state, copy: [{ from: '~/child' }], focusOn: '~/temp', modal: 'someModal', pageMode: 'view', dateFn: utils_1.testDateFn }));
|
|
53
|
+
button.simulate('click');
|
|
54
|
+
expect(remembered).toEqual({
|
|
55
|
+
messages: [],
|
|
56
|
+
"tags": {},
|
|
57
|
+
mainPage: {
|
|
58
|
+
"child": { "data": "a" },
|
|
59
|
+
"temp": { "data": "a" }
|
|
60
|
+
},
|
|
61
|
+
"restCommands": [],
|
|
62
|
+
"pageSelection": [{ "pageName": "mainPage", "pageMode": "view", "time": "now", }, { "focusOn": "~/temp", "firstTime": true, "pageMode": "view", "pageName": "someModal", "time": "timeForTest", }],
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
it("should create empty", () => {
|
|
66
|
+
var remembered = {};
|
|
67
|
+
const button = displayAndGetButton(emptyS, s => remembered = s, state => (0, jsx_runtime_1.jsx)(pages_1.ModalButton, { text: 'someTitle', id: 'someId', state: state, createEmpty: { data: 'data' }, focusOn: '~/temp', modal: 'someModal', pageMode: 'view', dateFn: utils_1.testDateFn }));
|
|
68
|
+
button.simulate('click');
|
|
69
|
+
expect(remembered).toEqual({
|
|
70
|
+
messages: [],
|
|
71
|
+
"tags": {},
|
|
72
|
+
"pageSelection": [{ "pageName": "mainPage", "pageMode": "view", "time": "now", }, { "focusOn": "~/temp", "firstTime": true, "pageMode": "view", "pageName": "someModal", "time": "timeForTest", }],
|
|
73
|
+
"restCommands": [],
|
|
74
|
+
mainPage: { "temp": { "data": "data" } }
|
|
75
|
+
});
|
|
76
|
+
});
|
|
77
|
+
it("should copyJustString", () => {
|
|
78
|
+
var remembered = {};
|
|
79
|
+
const state = Object.assign(Object.assign({}, emptyS), { a: { x: 'somedata', y: 'other' } });
|
|
80
|
+
const button = displayAndGetButton(state, s => remembered = s, state => (0, jsx_runtime_1.jsx)(pages_1.ModalButton, { text: 'someTitle', id: 'someId', state: state, copyJustString: [{ from: '/a', to: '/b', joiner: '*' }], focusOn: '~/temp', modal: 'someModal', pageMode: 'view', dateFn: utils_1.testDateFn }));
|
|
81
|
+
button.simulate('click');
|
|
82
|
+
expect(remembered).toEqual(Object.assign(Object.assign({}, state), { "b": "somedata*other", "pageSelection": [{ "pageName": "mainPage", "pageMode": "view", "time": "now", }, { "focusOn": "~/temp", "firstTime": true, "pageMode": "view", "pageName": "someModal", "time": "timeForTest", }] }));
|
|
83
|
+
});
|
|
84
|
+
it("should handle copyJustString when target is not there", () => {
|
|
85
|
+
var remembered = {};
|
|
86
|
+
const button = displayAndGetButton(emptyS, s => remembered = s, state => (0, jsx_runtime_1.jsx)(pages_1.ModalButton, { text: 'someTitle', id: 'someId', state: state, copyJustString: [{ from: '/a', to: '/b', joiner: '*' }], focusOn: '~/temp', modal: 'someModal', pageMode: 'view', dateFn: utils_1.testDateFn }));
|
|
87
|
+
button.simulate('click');
|
|
88
|
+
expect(remembered).toEqual(Object.assign(Object.assign({}, emptyS), { "pageSelection": [{ "pageName": "mainPage", "pageMode": "view", "time": "now", }, { "focusOn": "~/temp", "firstTime": true, "pageMode": "view", "pageName": "someModal", "time": "timeForTest", }] }));
|
|
89
|
+
});
|
|
90
|
+
it("should create empty, then copy back", () => {
|
|
91
|
+
var remembered = {};
|
|
92
|
+
displayAndGetButton(emptyS, s => remembered = s, state => (0, jsx_runtime_1.jsx)(pages_1.ModalButton, { text: 'someTitle', id: 'someId', state: state, focusOn: '~/temp', createEmpty: { data: 'data' }, modal: 'someModal', copyOnClose: [{ to: '~/data' }], pageMode: 'view', dateFn: utils_1.testDateFn }))
|
|
93
|
+
.simulate('click');
|
|
94
|
+
expect(remembered).toEqual({
|
|
95
|
+
messages: [],
|
|
96
|
+
"tags": {},
|
|
97
|
+
"pageSelection": [
|
|
98
|
+
{ "pageName": "mainPage", "pageMode": "view", "time": "now", },
|
|
99
|
+
{
|
|
100
|
+
"focusOn": '~/temp', "firstTime": true, "pageMode": "view", "pageName": "someModal",
|
|
101
|
+
copyOnClose: [{ to: "~/data" }], "time": "timeForTest",
|
|
102
|
+
}
|
|
103
|
+
],
|
|
104
|
+
"restCommands": [],
|
|
105
|
+
mainPage: { "temp": { "data": "data" } }
|
|
106
|
+
});
|
|
107
|
+
var remembered1 = {};
|
|
108
|
+
displayAndGetButton(remembered, s => remembered1 = s, state => (0, jsx_runtime_1.jsx)(pages_1.ModalCommitButton, { id: 'id', state: state })).simulate('click');
|
|
109
|
+
console.log(JSON.stringify(remembered1, null, 2));
|
|
110
|
+
expect(remembered1).toEqual({
|
|
111
|
+
messages: [],
|
|
112
|
+
"tags": {},
|
|
113
|
+
"mainPage": { "temp": { "data": "data" }, "data": { "data": "data" } },
|
|
114
|
+
"pageSelection": [{ "pageMode": "view", "pageName": "mainPage", "time": "now", }],
|
|
115
|
+
"restCommands": []
|
|
116
|
+
});
|
|
117
|
+
});
|
|
118
|
+
it("should create empty, then copy back with a rest command", () => {
|
|
119
|
+
var remembered = {};
|
|
120
|
+
displayAndGetButton(emptyS, s => remembered = s, state => (0, jsx_runtime_1.jsx)(pages_1.ModalButton, { text: 'someTitle', id: 'someId', state: state, focusOn: '~/temp', createEmpty: { data: 'data' }, rest: { name: 'restName', restAction: 'update' }, modal: 'someModal', copyOnClose: [{ to: '~/data' }], pageMode: 'view', dateFn: utils_1.testDateFn }))
|
|
121
|
+
.simulate('click');
|
|
122
|
+
expect(remembered).toEqual({
|
|
123
|
+
"mainPage": { "temp": { "data": "data" } },
|
|
124
|
+
"messages": [],
|
|
125
|
+
"tags": {},
|
|
126
|
+
"pageSelection": [
|
|
127
|
+
{ "pageMode": "view", "pageName": "mainPage", "time": "now", },
|
|
128
|
+
{
|
|
129
|
+
"copyOnClose": [{ "to": "~/data" }],
|
|
130
|
+
"firstTime": true, "focusOn": "~/temp", "pageMode": "view", "pageName": "someModal",
|
|
131
|
+
"rest": { "name": "restName", "restAction": "update" }, "time": "timeForTest",
|
|
132
|
+
}
|
|
133
|
+
],
|
|
134
|
+
"restCommands": []
|
|
135
|
+
});
|
|
136
|
+
var remembered1 = {};
|
|
137
|
+
displayAndGetButton(remembered, s => remembered1 = s, state => (0, jsx_runtime_1.jsx)(pages_1.ModalCommitButton, { id: 'id', state: state })).simulate('click');
|
|
138
|
+
expect(remembered1).toEqual({
|
|
139
|
+
messages: [],
|
|
140
|
+
"tags": {},
|
|
141
|
+
"mainPage": { "temp": { "data": "data" }, "data": { "data": "data" } },
|
|
142
|
+
"pageSelection": [{ "pageMode": "view", "pageName": "mainPage", "time": "now", }],
|
|
143
|
+
"restCommands": [{ "name": "restName", "restAction": "update" }]
|
|
144
|
+
});
|
|
145
|
+
});
|
|
146
|
+
});
|
|
147
|
+
});
|
|
148
|
+
describe("with nested child", () => {
|
|
149
|
+
it("should copy", () => {
|
|
150
|
+
var remembered = {};
|
|
151
|
+
const button = displayAndGetButton(nestedS, s => remembered = s, state => (0, jsx_runtime_1.jsx)(pages_1.ModalButton, { text: 'someTitle', id: 'someId', state: state, copy: [{ from: '~/nested/child' }], focusOn: '~/temp', modal: 'someModal', pageMode: 'view', dateFn: utils_1.testDateFn }));
|
|
152
|
+
button.simulate('click');
|
|
153
|
+
expect(remembered).toEqual({
|
|
154
|
+
messages: [],
|
|
155
|
+
"tags": {},
|
|
156
|
+
mainPage: {
|
|
157
|
+
nested: { "child": { "data": "a" } },
|
|
158
|
+
"temp": { "data": "a" }
|
|
159
|
+
},
|
|
160
|
+
"restCommands": [],
|
|
161
|
+
"pageSelection": [{ "pageName": "mainPage", "pageMode": "view", "time": "now", }, { "focusOn": "~/temp", "firstTime": true, "pageMode": "view", "pageName": "someModal", "time": "timeForTest", }],
|
|
162
|
+
});
|
|
163
|
+
});
|
|
164
|
+
it("should create empty, then copy back", () => {
|
|
165
|
+
var remembered = {};
|
|
166
|
+
displayAndGetButton(emptyNestedS, s => remembered = s, state => (0, jsx_runtime_1.jsx)(pages_1.ModalButton, { text: 'someTitle', id: 'someId', state: state, focusOn: '~/temp', createEmpty: { data: 'data' }, modal: 'someModal', copyOnClose: [{ to: '~/nested/data' }], pageMode: 'view', dateFn: utils_1.testDateFn }))
|
|
167
|
+
.simulate('click');
|
|
168
|
+
expect(remembered).toEqual({
|
|
169
|
+
messages: [],
|
|
170
|
+
"tags": {},
|
|
171
|
+
"pageSelection": [{ "pageName": "mainPage", "pageMode": "view", "time": "now", }, {
|
|
172
|
+
"firstTime": true, "pageMode": "view", "pageName": "someModal",
|
|
173
|
+
"focusOn": "~/temp",
|
|
174
|
+
copyOnClose: [{ "to": "~/nested/data" }],
|
|
175
|
+
"time": "timeForTest",
|
|
176
|
+
}],
|
|
177
|
+
"restCommands": [],
|
|
178
|
+
mainPage: { "temp": { "data": "data" }, nested: {} }
|
|
179
|
+
});
|
|
180
|
+
var remembered1 = {};
|
|
181
|
+
displayAndGetButton(remembered, s => remembered1 = s, state => (0, jsx_runtime_1.jsx)(pages_1.ModalCommitButton, { id: 'id', state: state })).simulate('click');
|
|
182
|
+
expect(remembered1).toEqual({
|
|
183
|
+
messages: [],
|
|
184
|
+
"tags": {},
|
|
185
|
+
"mainPage": { "temp": { "data": "data" }, nested: { "data": { "data": "data" } } },
|
|
186
|
+
"pageSelection": [{ "pageMode": "view", "pageName": "mainPage", "time": "now" }],
|
|
187
|
+
"restCommands": []
|
|
188
|
+
});
|
|
189
|
+
});
|
|
190
|
+
it("should create empty, then copy back with a rest command", () => {
|
|
191
|
+
var remembered = {};
|
|
192
|
+
displayAndGetButton(emptyNestedS, s => remembered = s, state => (0, jsx_runtime_1.jsx)(pages_1.ModalButton, { text: 'someTitle', id: 'someId', state: state, focusOn: '~/temp', createEmpty: { data: 'data' }, rest: { name: 'restName', restAction: 'update' }, modal: 'someModal', copyOnClose: [{ to: '~/nested/data' }], pageMode: 'view', dateFn: utils_1.testDateFn }))
|
|
193
|
+
.simulate('click');
|
|
194
|
+
expect(remembered).toEqual({
|
|
195
|
+
messages: [],
|
|
196
|
+
"tags": {},
|
|
197
|
+
"pageSelection": [
|
|
198
|
+
{ "pageName": "mainPage", "pageMode": "view", time: 'now' },
|
|
199
|
+
{
|
|
200
|
+
"focusOn": "~/temp", rest: { name: 'restName', restAction: 'update' }, "firstTime": true, "pageMode": "view", "pageName": "someModal",
|
|
201
|
+
copyOnClose: [{ "to": "~/nested/data" }], time: 'timeForTest'
|
|
202
|
+
}
|
|
203
|
+
],
|
|
204
|
+
"restCommands": [],
|
|
205
|
+
mainPage: { "temp": { "data": "data" }, nested: {} }
|
|
206
|
+
});
|
|
207
|
+
var remembered1 = {};
|
|
208
|
+
displayAndGetButton(remembered, s => remembered1 = s, state => (0, jsx_runtime_1.jsx)(pages_1.ModalCommitButton, { id: 'id', state: state })).simulate('click');
|
|
209
|
+
expect(remembered1).toEqual({
|
|
210
|
+
messages: [],
|
|
211
|
+
"tags": {},
|
|
212
|
+
"mainPage": { "temp": { "data": "data" }, nested: { "data": { "data": "data" } } },
|
|
213
|
+
"pageSelection": [{ "pageMode": "view", "pageName": "mainPage", "time": "now", }],
|
|
214
|
+
"restCommands": [{ "name": "restName", "restAction": "update" }]
|
|
215
|
+
});
|
|
216
|
+
});
|
|
217
|
+
});
|
|
218
|
+
describe("with lists of data", () => {
|
|
219
|
+
it("should copy from [1]", () => {
|
|
220
|
+
var remembered = {};
|
|
221
|
+
const button = displayAndGetButton(listS, s => remembered = s, state => (0, jsx_runtime_1.jsx)(pages_1.ModalButton, { text: 'someTitle', id: 'someId', state: state, copy: [{ from: '~/list[1]' }], focusOn: '~/temp', modal: 'someModal', pageMode: 'view', dateFn: utils_1.testDateFn }));
|
|
222
|
+
button.simulate('click');
|
|
223
|
+
expect(remembered).toEqual({
|
|
224
|
+
messages: [],
|
|
225
|
+
"tags": {},
|
|
226
|
+
mainPage: {
|
|
227
|
+
"index": 1,
|
|
228
|
+
list: [{ data: '0' }, { data: '1' }, { data: '2' }],
|
|
229
|
+
temp: { "data": "1" }
|
|
230
|
+
},
|
|
231
|
+
"restCommands": [],
|
|
232
|
+
"pageSelection": [{ "pageName": "mainPage", "pageMode": "view", "time": "now", }, { "focusOn": "~/temp", "firstTime": true, "pageMode": "view", "pageName": "someModal", "time": "timeForTest", }],
|
|
233
|
+
});
|
|
234
|
+
});
|
|
235
|
+
it("should copy from [last]", () => {
|
|
236
|
+
var remembered = {};
|
|
237
|
+
const button = displayAndGetButton(listS, s => remembered = s, state => (0, jsx_runtime_1.jsx)(pages_1.ModalButton, { text: 'someTitle', id: 'someId', state: state, copy: [{ from: '~/list[$last]' }], focusOn: '~/temp', modal: 'someModal', pageMode: 'view', dateFn: utils_1.testDateFn }));
|
|
238
|
+
button.simulate('click');
|
|
239
|
+
expect(remembered.mainPage.temp).toEqual({ data: '2' });
|
|
240
|
+
});
|
|
241
|
+
it("should copy from [~/index]", () => {
|
|
242
|
+
var remembered = {};
|
|
243
|
+
const button = displayAndGetButton(listS, s => remembered = s, state => (0, jsx_runtime_1.jsx)(pages_1.ModalButton, { text: 'someTitle', id: 'someId', state: state, copy: [{ from: '~/list/[~/index]' }], focusOn: '~/temp', modal: 'someModal', pageMode: 'view', dateFn: utils_1.testDateFn }));
|
|
244
|
+
button.simulate('click');
|
|
245
|
+
expect(remembered.mainPage.temp).toEqual({ data: '1' });
|
|
246
|
+
});
|
|
247
|
+
});
|
|
248
|
+
it("should create empty, then copy back", () => {
|
|
249
|
+
var remembered = {};
|
|
250
|
+
displayAndGetButton(emptyNestedS, s => remembered = s, state => (0, jsx_runtime_1.jsx)(pages_1.ModalButton, { text: 'someTitle', id: 'someId', state: state, focusOn: '~/temp', createEmpty: { data: 'data' }, modal: 'someModal', copyOnClose: [{ to: '~/nested/data' }], pageMode: 'view', dateFn: utils_1.testDateFn }))
|
|
251
|
+
.simulate('click');
|
|
252
|
+
expect(remembered).toEqual({
|
|
253
|
+
messages: [],
|
|
254
|
+
"tags": {},
|
|
255
|
+
"pageSelection": [{ "pageName": "mainPage", "pageMode": "view", "time": "now" },
|
|
256
|
+
{
|
|
257
|
+
"focusOn": "~/temp", "firstTime": true, "pageMode": "view", "pageName": "someModal",
|
|
258
|
+
copyOnClose: [{ "to": "~/nested/data" }], "time": "timeForTest",
|
|
259
|
+
}],
|
|
260
|
+
"restCommands": [],
|
|
261
|
+
mainPage: { "temp": { "data": "data" }, nested: {} }
|
|
262
|
+
});
|
|
263
|
+
var remembered1 = {};
|
|
264
|
+
displayAndGetButton(remembered, s => remembered1 = s, state => (0, jsx_runtime_1.jsx)(pages_1.ModalCommitButton, { id: 'id', state: state })).simulate('click');
|
|
265
|
+
expect(remembered1).toEqual({
|
|
266
|
+
messages: [],
|
|
267
|
+
"tags": {},
|
|
268
|
+
"mainPage": { "temp": { "data": "data" }, nested: { "data": { "data": "data" } } },
|
|
269
|
+
"pageSelection": [{ "pageMode": "view", "pageName": "mainPage", "time": "now" }],
|
|
270
|
+
"restCommands": []
|
|
271
|
+
});
|
|
272
|
+
});
|
|
273
|
+
it("should create empty, then copy back with a rest command", () => {
|
|
274
|
+
var remembered = {};
|
|
275
|
+
displayAndGetButton(emptyNestedS, s => remembered = s, state => (0, jsx_runtime_1.jsx)(pages_1.ModalButton, { text: 'someTitle', id: 'someId', state: state, focusOn: '~/temp', createEmpty: { data: 'data' }, rest: { name: 'restName', restAction: 'update' }, modal: 'someModal', copyOnClose: [{ to: '~/nested/data' }], pageMode: 'view', dateFn: utils_1.testDateFn }))
|
|
276
|
+
.simulate('click');
|
|
277
|
+
expect(remembered).toEqual({
|
|
278
|
+
messages: [],
|
|
279
|
+
"tags": {},
|
|
280
|
+
"pageSelection": [
|
|
281
|
+
{ "pageName": "mainPage", "pageMode": "view", "time": "now", },
|
|
282
|
+
{
|
|
283
|
+
"focusOn": "~/temp", rest: { name: 'restName', restAction: 'update' }, "firstTime": true, "pageMode": "view", "pageName": "someModal",
|
|
284
|
+
copyOnClose: [{ "to": "~/nested/data" }], "time": "timeForTest",
|
|
285
|
+
}
|
|
286
|
+
],
|
|
287
|
+
"restCommands": [],
|
|
288
|
+
mainPage: { "temp": { "data": "data" }, nested: {} }
|
|
289
|
+
});
|
|
290
|
+
var remembered1 = {};
|
|
291
|
+
displayAndGetButton(remembered, s => remembered1 = s, state => (0, jsx_runtime_1.jsx)(pages_1.ModalCommitButton, { id: 'id', state: state })).simulate('click');
|
|
292
|
+
expect(remembered1).toEqual({
|
|
293
|
+
messages: [],
|
|
294
|
+
"tags": {},
|
|
295
|
+
"mainPage": { "temp": { "data": "data" }, nested: { "data": { "data": "data" } } },
|
|
296
|
+
"pageSelection": [{ "pageMode": "view", "pageName": "mainPage", "time": "now" }],
|
|
297
|
+
"restCommands": [{ "name": "restName", "restAction": "update", }]
|
|
298
|
+
});
|
|
299
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|