testeranto 0.140.1 → 0.143.0
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/.aider.chat.history.md +9173 -0
- package/.aider.input.history +336 -0
- package/.aider.tags.cache.v3/{ad/3c/10f2ab1397f6d544e613d2a6acaf.val → 3d/81/8b6f0e9b98ec2952cdb8968ac386.val} +0 -0
- package/.aider.tags.cache.v3/63/f1/138061b0aadb868173d197c2a0e0.val +0 -0
- package/.aider.tags.cache.v3/be/72/19ee8e656d160afe9b31523245fe.val +0 -0
- package/.aider.tags.cache.v3/cache.db +0 -0
- package/.aider.tags.cache.v3/cache.db-shm +0 -0
- package/.aider.tags.cache.v3/cache.db-wal +0 -0
- package/.aider.tags.cache.v3/{a7/97/6d37fce350ad2d588f36729db0cd.val → d6/7d/1820c2d4b9330eab7017da4515e7.val} +0 -0
- package/README.md +1 -1
- package/docs/aiderTest.sh +1 -0
- package/docs/testing.ai.txt +98 -0
- package/docs/testing.prompt.txt +8 -0
- package/index.html +1 -1
- package/package.json +3 -3
- package/src/PM/PM_WithEslintAndTsc.ts +35 -21
- package/src/Pure.test.ts +299 -0
- package/src/lib/BaseSuite.test.ts +24 -5
- package/src/lib/abstractBase.test/MockGiven.ts +31 -0
- package/src/lib/abstractBase.test/MockThen.ts +20 -0
- package/src/lib/abstractBase.test/MockWhen.ts +17 -0
- package/src/lib/abstractBase.test/implementation.ts +51 -0
- package/src/lib/abstractBase.test/index.ts +19 -0
- package/src/lib/abstractBase.test/interface.ts +12 -0
- package/src/lib/abstractBase.test/specification.ts +49 -0
- package/src/lib/abstractBase.test/types.ts +19 -0
- package/src/lib/baseBuilder.test/TestBaseBuilder.ts +83 -0
- package/src/lib/baseBuilder.test/baseBuilder.test.implementation.ts +133 -0
- package/src/lib/baseBuilder.test/baseBuilder.test.interface.ts +18 -0
- package/src/lib/baseBuilder.test/baseBuilder.test.specification.ts +35 -0
- package/src/lib/baseBuilder.test/baseBuilder.test.ts +13 -0
- package/src/lib/baseBuilder.test/baseBuilder.test.types.ts +36 -0
- package/src/lib/classBuilder.test/TestClassBuilder.ts +88 -0
- package/src/lib/classBuilder.test/classBuilder.test.implementation.ts +200 -0
- package/src/lib/classBuilder.test/classBuilder.test.interface.ts +17 -0
- package/src/lib/classBuilder.test/classBuilder.test.specification.ts +112 -0
- package/src/lib/classBuilder.test/classBuilder.test.ts +14 -0
- package/src/lib/classBuilder.test/classBuilder.test.types.ts +72 -0
- package/src/lib/core.test/MockCore.ts +49 -0
- package/src/lib/core.test/core.test.implementation.ts +129 -0
- package/src/lib/core.test/core.test.interface.ts +18 -0
- package/src/lib/core.test/core.test.specification.ts +99 -0
- package/src/lib/core.test/core.test.ts +15 -0
- package/src/lib/core.test/core.test.types.ts +68 -0
- package/src/lib/core.ts +1 -1
- package/src/lib/pmProxy.test/implementation.ts +104 -0
- package/src/lib/pmProxy.test/index.ts +19 -0
- package/src/lib/pmProxy.test/interface.ts +47 -0
- package/src/lib/pmProxy.test/mockPM.ts +38 -0
- package/src/lib/pmProxy.test/mockPMBase.ts +136 -0
- package/src/lib/pmProxy.test/specification.ts +123 -0
- package/src/lib/pmProxy.test/types.ts +45 -0
- package/src/lib/pmProxy.ts +40 -193
- package/testeranto/bundles/node/allTests/chunk-2FXOXAKZ.mjs +800 -0
- package/testeranto/bundles/node/allTests/chunk-5MQGD4WC.mjs +251 -0
- package/testeranto/bundles/node/allTests/chunk-6CGAD2FD.mjs +800 -0
- package/testeranto/bundles/node/allTests/chunk-DWKHII32.mjs +800 -0
- package/testeranto/bundles/node/allTests/chunk-KYSOR62N.mjs +167 -0
- package/testeranto/bundles/node/allTests/chunk-PRPFVO6G.mjs +251 -0
- package/testeranto/bundles/node/allTests/chunk-RX4SUFXQ.mjs +251 -0
- package/testeranto/bundles/node/allTests/chunk-UED26IMH.mjs +802 -0
- package/testeranto/bundles/node/allTests/chunk-VAAIAWXC.mjs +117 -0
- package/testeranto/bundles/node/allTests/chunk-W44DUDBK.mjs +251 -0
- package/testeranto/bundles/node/allTests/chunk-YI3EGRMQ.mjs +167 -0
- package/testeranto/bundles/node/allTests/metafile.json +1072 -222
- package/testeranto/bundles/node/allTests/src/PM/__tests__/nodeSidecar.testeranto.mjs +2 -1
- package/testeranto/bundles/node/allTests/src/PM/__tests__/pureSidecar.testeranto.mjs +2 -1
- package/testeranto/bundles/node/allTests/src/PM/__tests__/webSidecar.testeranto.mjs +2 -1
- package/testeranto/bundles/node/allTests/src/Pure.test.mjs +261 -0
- package/testeranto/bundles/node/allTests/src/lib/BaseSuite.test.mjs +22 -4
- package/testeranto/bundles/node/allTests/src/lib/baseBuilder.test/baseBuilder.test.mjs +226 -0
- package/testeranto/bundles/node/allTests/src/lib/classBuilder.test/classBuilder.test.mjs +406 -0
- package/testeranto/bundles/node/allTests/src/lib/core.test/core.test.mjs +279 -0
- package/testeranto/bundles/node/allTests/src/lib/pmProxy.test/index.mjs +4479 -0
- package/testeranto/bundles/node/allTests/src/mothership/test.mjs +4 -2
- package/testeranto/reports/allTests/config.json +40 -1
- package/testeranto/reports/allTests/src/PM/__tests__/nodeSidecar.testeranto/node/console_log.txt +0 -0
- package/testeranto/reports/allTests/src/PM/__tests__/nodeSidecar.testeranto/node/log.txt +0 -0
- package/testeranto/reports/allTests/src/Pure.test/node/console_log.txt +17 -0
- package/testeranto/reports/allTests/src/Pure.test/node/dev.html +21 -0
- package/testeranto/reports/allTests/src/Pure.test/node/index.html +21 -0
- package/testeranto/reports/allTests/src/Pure.test/node/lint_errors.json +134 -0
- package/testeranto/reports/allTests/src/Pure.test/node/message +1 -0
- package/testeranto/reports/allTests/src/Pure.test/node/prompt.txt +7 -0
- package/testeranto/reports/allTests/src/Pure.test/node/type_errors.txt +26 -0
- package/testeranto/reports/allTests/src/lib/BaseGiven.test/node/dev.html +21 -0
- package/testeranto/reports/allTests/src/lib/BaseGiven.test/node/index.html +21 -0
- package/testeranto/reports/allTests/src/lib/BaseSuite.test/node/console_log.txt +27 -27
- package/testeranto/reports/allTests/src/lib/BaseSuite.test/node/lint_errors.json +104 -104
- package/testeranto/reports/allTests/src/lib/BaseSuite.test/node/type_errors.txt +47 -22
- package/testeranto/reports/allTests/src/lib/BaseThen.test/node/dev.html +21 -0
- package/testeranto/reports/allTests/src/lib/BaseThen.test/node/index.html +21 -0
- package/testeranto/reports/allTests/src/lib/BaseWhen.test/node/dev.html +21 -0
- package/testeranto/reports/allTests/src/lib/BaseWhen.test/node/index.html +21 -0
- package/testeranto/reports/allTests/src/lib/abstractBase/index/node/dev.html +21 -0
- package/testeranto/reports/allTests/src/lib/abstractBase/index/node/index.html +21 -0
- package/testeranto/reports/allTests/src/lib/baseBuilder/baseBuilder.test/node/dev.html +21 -0
- package/testeranto/reports/allTests/src/lib/baseBuilder/baseBuilder.test/node/index.html +21 -0
- package/testeranto/reports/allTests/src/lib/baseBuilder.test/baseBuilder.test/node/console_log.txt +12 -0
- package/testeranto/reports/allTests/src/lib/baseBuilder.test/baseBuilder.test/node/dev.html +21 -0
- package/testeranto/reports/allTests/src/lib/baseBuilder.test/baseBuilder.test/node/index.html +21 -0
- package/testeranto/reports/allTests/src/lib/baseBuilder.test/baseBuilder.test/node/lint_errors.json +966 -0
- package/testeranto/reports/allTests/src/lib/baseBuilder.test/baseBuilder.test/node/message +1 -0
- package/testeranto/reports/allTests/src/lib/baseBuilder.test/baseBuilder.test/node/prompt.txt +11 -0
- package/testeranto/reports/allTests/src/lib/baseBuilder.test/baseBuilder.test/node/type_errors.txt +52 -0
- package/testeranto/reports/allTests/src/lib/classBuilder.test/classBuilder.test/node/console_log.txt +17 -0
- package/testeranto/reports/allTests/src/lib/classBuilder.test/classBuilder.test/node/dev.html +21 -0
- package/testeranto/reports/allTests/src/lib/classBuilder.test/classBuilder.test/node/index.html +21 -0
- package/testeranto/reports/allTests/src/lib/classBuilder.test/classBuilder.test/node/lint_errors.json +771 -0
- package/testeranto/reports/allTests/src/lib/classBuilder.test/classBuilder.test/node/message +1 -0
- package/testeranto/reports/allTests/src/lib/classBuilder.test/classBuilder.test/node/prompt.txt +11 -0
- package/testeranto/reports/allTests/src/lib/classBuilder.test/classBuilder.test/node/type_errors.txt +67 -0
- package/testeranto/reports/allTests/src/lib/core.test/core.test/node/console_log.txt +17 -0
- package/testeranto/reports/allTests/src/lib/core.test/core.test/node/dev.html +21 -0
- package/testeranto/reports/allTests/src/lib/core.test/core.test/node/index.html +21 -0
- package/testeranto/reports/allTests/src/lib/core.test/core.test/node/lint_errors.json +416 -0
- package/testeranto/reports/allTests/src/lib/core.test/core.test/node/message +1 -0
- package/testeranto/reports/allTests/src/lib/core.test/core.test/node/prompt.txt +11 -0
- package/testeranto/reports/allTests/src/lib/core.test/core.test/node/type_errors.txt +54 -0
- package/testeranto/reports/allTests/src/lib/pmProxy.test/index/node/console_log.txt +43 -0
- package/testeranto/reports/allTests/src/lib/pmProxy.test/index/node/dev.html +21 -0
- package/testeranto/reports/allTests/src/lib/pmProxy.test/index/node/index.html +21 -0
- package/testeranto/reports/allTests/src/lib/pmProxy.test/index/node/lint_errors.json +319 -0
- package/testeranto/reports/allTests/src/lib/pmProxy.test/index/node/log.txt +0 -0
- package/testeranto/reports/allTests/src/lib/pmProxy.test/index/node/message +1 -0
- package/testeranto/reports/allTests/src/lib/pmProxy.test/index/node/prompt.txt +10 -0
- package/testeranto/reports/allTests/src/lib/pmProxy.test/index/node/type_errors.txt +64 -0
- package/testeranto/reports/allTests/src/mothership/test/node/console_log.txt +44 -0
- package/testeranto/reports/allTests/src/mothership/test/node/log.txt +0 -0
- package/testeranto/reports/allTests/summary.json +76 -6
- package/testeranto/reportsnode_build_errors +12 -0
- package/testeranto.config.ts +19 -2
package/src/Pure.test.ts
ADDED
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
import { Ibdd_in, Ibdd_out } from "./CoreTypes";
|
|
2
|
+
import PureTesteranto from "./Pure";
|
|
3
|
+
import { MockPMBase } from "./lib/pmProxy.test/mockPMBase";
|
|
4
|
+
import { IPM } from "./lib/types";
|
|
5
|
+
|
|
6
|
+
// Test types specific to PureTesteranto testing
|
|
7
|
+
type PureI = Ibdd_in<
|
|
8
|
+
null, // No initial input needed
|
|
9
|
+
IPM, // Test subject is IPM
|
|
10
|
+
{ pm: IPM }, // Store contains PM instance
|
|
11
|
+
{ pm: IPM }, // Selection is same as store
|
|
12
|
+
() => IPM, // Given returns IPM
|
|
13
|
+
(store: { pm: IPM }) => { pm: IPM }, // When modifies store
|
|
14
|
+
(store: { pm: IPM }) => { pm: IPM } // Then verifies store
|
|
15
|
+
>;
|
|
16
|
+
|
|
17
|
+
type PureO = Ibdd_out<
|
|
18
|
+
{ Default: [string] },
|
|
19
|
+
{ Default: [] },
|
|
20
|
+
{
|
|
21
|
+
applyProxy: [string]; // When to apply a proxy
|
|
22
|
+
verifyCall: [string, any]; // Then to verify calls
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
verifyProxy: [string]; // Then to verify proxy behavior
|
|
26
|
+
verifyNoProxy: []; // Then to verify no proxy
|
|
27
|
+
},
|
|
28
|
+
{ Default: [] }
|
|
29
|
+
>;
|
|
30
|
+
|
|
31
|
+
// Implementation for PureTesteranto tests
|
|
32
|
+
const implementation = {
|
|
33
|
+
suites: {
|
|
34
|
+
Default: "PureTesteranto Test Suite",
|
|
35
|
+
},
|
|
36
|
+
|
|
37
|
+
givens: {
|
|
38
|
+
Default: () => ({
|
|
39
|
+
pm: new MockPMBase() as unknown as IPM,
|
|
40
|
+
config: {},
|
|
41
|
+
proxies: {
|
|
42
|
+
butThenProxy: (pm: IPM, path: string) => ({
|
|
43
|
+
...pm,
|
|
44
|
+
writeFileSync: (p: string, c: string) =>
|
|
45
|
+
pm.writeFileSync(`${path}/butThen/${p}`, c)
|
|
46
|
+
}),
|
|
47
|
+
andWhenProxy: (pm: IPM, path: string) => ({
|
|
48
|
+
...pm,
|
|
49
|
+
writeFileSync: (p: string, c: string) =>
|
|
50
|
+
pm.writeFileSync(`${path}/andWhen/${p}`, c)
|
|
51
|
+
}),
|
|
52
|
+
beforeEachProxy: (pm: IPM, suite: string) => ({
|
|
53
|
+
...pm,
|
|
54
|
+
writeFileSync: (p: string, c: string) =>
|
|
55
|
+
pm.writeFileSync(`suite-${suite}/beforeEach/${p}`, c)
|
|
56
|
+
})
|
|
57
|
+
}
|
|
58
|
+
}),
|
|
59
|
+
},
|
|
60
|
+
|
|
61
|
+
whens: {
|
|
62
|
+
applyProxy: (proxyType: string) => (store) => {
|
|
63
|
+
switch (proxyType) {
|
|
64
|
+
case "invalidConfig":
|
|
65
|
+
throw new Error("Invalid configuration");
|
|
66
|
+
case "missingProxy":
|
|
67
|
+
return { ...store, pm: {} }; // Break proxy chain
|
|
68
|
+
case "largePayload":
|
|
69
|
+
return {
|
|
70
|
+
...store,
|
|
71
|
+
largePayload: true,
|
|
72
|
+
pm: {
|
|
73
|
+
...store.pm,
|
|
74
|
+
writeFileSync: (p: string, c: string) => {
|
|
75
|
+
if (c.length > 1e6) {
|
|
76
|
+
return true;
|
|
77
|
+
}
|
|
78
|
+
throw new Error("Payload too small");
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
default:
|
|
83
|
+
return store;
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
},
|
|
87
|
+
|
|
88
|
+
thens: {
|
|
89
|
+
verifyProxy: (expectedPath: string) => (store) => {
|
|
90
|
+
const testPath = "expected";
|
|
91
|
+
const result = store.pm.writeFileSync(testPath, "content");
|
|
92
|
+
const actualPath = store.pm.getLastCall("writeFileSync")?.path;
|
|
93
|
+
if (actualPath !== expectedPath) {
|
|
94
|
+
throw new Error(`Expected path ${expectedPath}, got ${actualPath}`);
|
|
95
|
+
}
|
|
96
|
+
return store;
|
|
97
|
+
},
|
|
98
|
+
verifyNoProxy: () => (store) => {
|
|
99
|
+
if (store.pm.getCallCount("writeFileSync") > 0) {
|
|
100
|
+
throw new Error("Proxy was unexpectedly applied");
|
|
101
|
+
}
|
|
102
|
+
return store;
|
|
103
|
+
},
|
|
104
|
+
verifyError: (expectedError: string) => (store) => {
|
|
105
|
+
try {
|
|
106
|
+
store.pm.writeFileSync("test", "content");
|
|
107
|
+
throw new Error("Expected error but none was thrown");
|
|
108
|
+
} catch (error) {
|
|
109
|
+
if (!error.message.includes(expectedError)) {
|
|
110
|
+
throw new Error(`Expected error "${expectedError}", got "${error.message}"`);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
return store;
|
|
114
|
+
},
|
|
115
|
+
verifyResourceConfig: () => (store) => {
|
|
116
|
+
if (!store.pm.testResourceConfiguration) {
|
|
117
|
+
throw new Error("Missing test resource configuration");
|
|
118
|
+
}
|
|
119
|
+
return store;
|
|
120
|
+
},
|
|
121
|
+
verifyLargePayload: () => (store) => {
|
|
122
|
+
const largeContent = "x".repeat(2e6); // 2MB payload
|
|
123
|
+
const result = store.pm.writeFileSync("large.txt", largeContent);
|
|
124
|
+
if (!result) {
|
|
125
|
+
throw new Error("Failed to handle large payload");
|
|
126
|
+
}
|
|
127
|
+
return store;
|
|
128
|
+
},
|
|
129
|
+
verifyTypeSafety: () => (store) => {
|
|
130
|
+
// TypeScript will catch these at compile time
|
|
131
|
+
return store;
|
|
132
|
+
},
|
|
133
|
+
},
|
|
134
|
+
|
|
135
|
+
checks: {
|
|
136
|
+
Default: () => ({} as IPM),
|
|
137
|
+
},
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
// Specification for PureTesteranto tests
|
|
141
|
+
const specification = (Suite, Given, When, Then, Check) => [
|
|
142
|
+
Suite.Default("Core Functionality", {
|
|
143
|
+
initializationTest: Given.Default(
|
|
144
|
+
["Should initialize with default configuration"],
|
|
145
|
+
[],
|
|
146
|
+
[Then.verifyNoProxy()]
|
|
147
|
+
),
|
|
148
|
+
resourceConfigTest: Given.Default(
|
|
149
|
+
["Should handle test resource configuration"],
|
|
150
|
+
[When.applyProxy("resourceConfig")],
|
|
151
|
+
[Then.verifyResourceConfig()]
|
|
152
|
+
),
|
|
153
|
+
}),
|
|
154
|
+
|
|
155
|
+
Suite.Default("Proxy Integration", {
|
|
156
|
+
butThenProxyTest: Given.Default(
|
|
157
|
+
["Should integrate with butThenProxy"],
|
|
158
|
+
[When.applyProxy("butThenProxy")],
|
|
159
|
+
[Then.verifyProxy("test/path/butThen/expected")]
|
|
160
|
+
),
|
|
161
|
+
andWhenProxyTest: Given.Default(
|
|
162
|
+
["Should integrate with andWhenProxy"],
|
|
163
|
+
[When.applyProxy("andWhenProxy")],
|
|
164
|
+
[Then.verifyProxy("test/path/andWhen/expected")]
|
|
165
|
+
),
|
|
166
|
+
beforeEachProxyTest: Given.Default(
|
|
167
|
+
["Should integrate with beforeEachProxy"],
|
|
168
|
+
[When.applyProxy("beforeEachProxy")],
|
|
169
|
+
[Then.verifyProxy("suite-1/beforeEach/expected")]
|
|
170
|
+
),
|
|
171
|
+
}),
|
|
172
|
+
|
|
173
|
+
Suite.Default("Error Handling", {
|
|
174
|
+
invalidConfigTest: Given.Default(
|
|
175
|
+
["Should handle invalid configuration"],
|
|
176
|
+
[When.applyProxy("invalidConfig")],
|
|
177
|
+
[Then.verifyError("Invalid configuration")]
|
|
178
|
+
),
|
|
179
|
+
missingProxyTest: Given.Default(
|
|
180
|
+
["Should handle missing proxy"],
|
|
181
|
+
[When.applyProxy("missingProxy")],
|
|
182
|
+
[Then.verifyError("Proxy not found")]
|
|
183
|
+
),
|
|
184
|
+
}),
|
|
185
|
+
|
|
186
|
+
Suite.Default("Performance", {
|
|
187
|
+
multipleProxiesTest: Given.Default(
|
|
188
|
+
["Should handle multiple proxies efficiently"],
|
|
189
|
+
[
|
|
190
|
+
When.applyProxy("butThenProxy"),
|
|
191
|
+
When.applyProxy("andWhenProxy"),
|
|
192
|
+
When.applyProxy("beforeEachProxy")
|
|
193
|
+
],
|
|
194
|
+
[
|
|
195
|
+
Then.verifyProxy("test/path/butThen/expected"),
|
|
196
|
+
Then.verifyProxy("test/path/andWhen/expected"),
|
|
197
|
+
Then.verifyProxy("suite-1/beforeEach/expected")
|
|
198
|
+
]
|
|
199
|
+
),
|
|
200
|
+
largePayloadTest: Given.Default(
|
|
201
|
+
["Should handle large payloads"],
|
|
202
|
+
[When.applyProxy("largePayload")],
|
|
203
|
+
[Then.verifyLargePayload()]
|
|
204
|
+
),
|
|
205
|
+
}),
|
|
206
|
+
|
|
207
|
+
Suite.Default("Cross-Component Verification", {
|
|
208
|
+
proxyChainTest: Given.Default(
|
|
209
|
+
["Proxies should chain correctly"],
|
|
210
|
+
[
|
|
211
|
+
When.applyProxy("butThenProxy"),
|
|
212
|
+
When.applyProxy("andWhenProxy")
|
|
213
|
+
],
|
|
214
|
+
[
|
|
215
|
+
Then.verifyProxy("test/path/andWhen/butThen/expected")
|
|
216
|
+
]
|
|
217
|
+
),
|
|
218
|
+
errorPropagationTest: Given.Default(
|
|
219
|
+
["Errors should propagate across components"],
|
|
220
|
+
[When.applyProxy("invalidConfig")],
|
|
221
|
+
[Then.verifyError("Invalid configuration")]
|
|
222
|
+
),
|
|
223
|
+
resourceSharingTest: Given.Default(
|
|
224
|
+
["Resources should be shared correctly"],
|
|
225
|
+
[When.applyProxy("resourceConfig")],
|
|
226
|
+
[Then.verifyResourceConfig()]
|
|
227
|
+
)
|
|
228
|
+
}),
|
|
229
|
+
|
|
230
|
+
Suite.Default("Type Safety", {
|
|
231
|
+
strictTypeTest: Given.Default(
|
|
232
|
+
["Should enforce type safety"],
|
|
233
|
+
[When.applyProxy("typeSafe")],
|
|
234
|
+
[Then.verifyTypeSafety()]
|
|
235
|
+
),
|
|
236
|
+
invalidTypeTest: Given.Default(
|
|
237
|
+
["Should reject invalid types"],
|
|
238
|
+
[When.applyProxy("invalidType")],
|
|
239
|
+
[Then.verifyError("Type mismatch")]
|
|
240
|
+
),
|
|
241
|
+
}),
|
|
242
|
+
|
|
243
|
+
Suite.Default("Integration Tests", {
|
|
244
|
+
// Verify builders work together
|
|
245
|
+
builderIntegration: Given.Default(
|
|
246
|
+
["BaseBuilder and ClassBuilder should integrate properly"],
|
|
247
|
+
[],
|
|
248
|
+
[
|
|
249
|
+
Then.initializedProperly(),
|
|
250
|
+
Then.specsGenerated(),
|
|
251
|
+
Then.jobsCreated(),
|
|
252
|
+
Then.artifactsTracked()
|
|
253
|
+
]
|
|
254
|
+
),
|
|
255
|
+
|
|
256
|
+
// Verify PM proxy integration
|
|
257
|
+
pmProxyIntegration: Given.Default(
|
|
258
|
+
["PM proxies should work with test runners"],
|
|
259
|
+
[When.applyProxy("butThenProxy")],
|
|
260
|
+
[Then.verifyProxy("test/path/butThen/expected")]
|
|
261
|
+
),
|
|
262
|
+
|
|
263
|
+
// Verify full test lifecycle
|
|
264
|
+
fullLifecycle: Given.Default(
|
|
265
|
+
["Should complete full test lifecycle"],
|
|
266
|
+
[
|
|
267
|
+
When.addArtifact(Promise.resolve("test")),
|
|
268
|
+
When.setTestJobs([]),
|
|
269
|
+
When.modifySpecs((specs) => [...specs])
|
|
270
|
+
],
|
|
271
|
+
[
|
|
272
|
+
Then.testRunSuccessful(),
|
|
273
|
+
Then.artifactsTracked(),
|
|
274
|
+
Then.specsModified(0)
|
|
275
|
+
]
|
|
276
|
+
)
|
|
277
|
+
})
|
|
278
|
+
];
|
|
279
|
+
|
|
280
|
+
// Test interface for PureTesteranto
|
|
281
|
+
const testInterface = {
|
|
282
|
+
beforeEach: async (subject, initializer) => {
|
|
283
|
+
return { pm: initializer() };
|
|
284
|
+
},
|
|
285
|
+
andWhen: async (store, whenCB) => whenCB(store),
|
|
286
|
+
butThen: async (store, thenCB) => thenCB(store),
|
|
287
|
+
afterEach: async (store) => store,
|
|
288
|
+
afterAll: async () => {},
|
|
289
|
+
beforeAll: async (input, testResource) => ({} as IPM),
|
|
290
|
+
assertThis: (x) => x,
|
|
291
|
+
};
|
|
292
|
+
|
|
293
|
+
// Export the test suite
|
|
294
|
+
export default PureTesteranto<PureI, PureO, {}>(
|
|
295
|
+
null, // No initial input
|
|
296
|
+
specification,
|
|
297
|
+
implementation,
|
|
298
|
+
testInterface
|
|
299
|
+
);
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import Testeranto from "../Node";
|
|
2
|
+
|
|
1
3
|
import { BaseSuite } from "./BaseSuite";
|
|
2
4
|
import { BaseGiven, BaseWhen, BaseThen, BaseCheck } from "./abstractBase";
|
|
3
5
|
import { ITTestResourceConfiguration, ITestArtifactory, ITLog } from ".";
|
|
4
|
-
import { IPM } from "./types";
|
|
6
|
+
import { IPM, ITestCheckCallback } from "./types";
|
|
5
7
|
import {
|
|
6
8
|
Ibdd_in,
|
|
7
9
|
Ibdd_out,
|
|
@@ -9,7 +11,7 @@ import {
|
|
|
9
11
|
ITestImplementation,
|
|
10
12
|
ITestInterface,
|
|
11
13
|
} from "../CoreTypes";
|
|
12
|
-
import
|
|
14
|
+
import { WhenSpecification } from "../Types";
|
|
13
15
|
|
|
14
16
|
// 1. Define our test types with full type safety
|
|
15
17
|
type TestStore = {
|
|
@@ -159,10 +161,10 @@ class TestableSuite extends BaseSuite<I, O> {
|
|
|
159
161
|
|
|
160
162
|
// 3. Enhanced Test Specification with more test cases
|
|
161
163
|
const specification: ITestSpecification<I, O> = (
|
|
162
|
-
Suite:
|
|
163
|
-
Given:
|
|
164
|
+
Suite: ITestSpecification<I, O>,
|
|
165
|
+
Given: WhenSpecification<I, O>,
|
|
164
166
|
When: WhenSpecification<I, O>,
|
|
165
|
-
Then:
|
|
167
|
+
Then: WhenSpecification<I, O>,
|
|
166
168
|
Check: ITestCheckCallback<I, O>
|
|
167
169
|
) => [
|
|
168
170
|
Suite.Default(
|
|
@@ -219,6 +221,23 @@ const specification: ITestSpecification<I, O> = (
|
|
|
219
221
|
// )
|
|
220
222
|
]
|
|
221
223
|
),
|
|
224
|
+
|
|
225
|
+
Suite.Default("Comprehensive Integration", {
|
|
226
|
+
fullStackTest: Given.Default(
|
|
227
|
+
["All components should work together"],
|
|
228
|
+
[
|
|
229
|
+
When.addArtifact(Promise.resolve("test")),
|
|
230
|
+
When.modifySpecs((specs) => [...specs, "extra"]),
|
|
231
|
+
When.modifyJobs((jobs) => [...jobs, {}])
|
|
232
|
+
],
|
|
233
|
+
[
|
|
234
|
+
Then.specsModified(1),
|
|
235
|
+
Then.jobsModified(1),
|
|
236
|
+
Then.artifactsTracked(),
|
|
237
|
+
Then.testRunSuccessful()
|
|
238
|
+
]
|
|
239
|
+
)
|
|
240
|
+
})
|
|
222
241
|
];
|
|
223
242
|
|
|
224
243
|
// 4. Enhanced Test Implementation with more operations
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { BaseGiven } from "../abstractBase";
|
|
2
|
+
import { Ibdd_in_any } from "../../CoreTypes";
|
|
3
|
+
|
|
4
|
+
export class MockGiven<I extends Ibdd_in_any> extends BaseGiven<I> {
|
|
5
|
+
constructor(
|
|
6
|
+
name: string,
|
|
7
|
+
features: string[],
|
|
8
|
+
whens: BaseWhen<I>[],
|
|
9
|
+
thens: BaseThen<I>[],
|
|
10
|
+
givenCB: I["given"],
|
|
11
|
+
initialValues: any
|
|
12
|
+
) {
|
|
13
|
+
super(name, features, whens, thens, givenCB, initialValues);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
async givenThat(
|
|
17
|
+
subject: I["isubject"],
|
|
18
|
+
testResourceConfiguration: any,
|
|
19
|
+
artifactory: any,
|
|
20
|
+
givenCB: I["given"],
|
|
21
|
+
initialValues: any,
|
|
22
|
+
pm: any
|
|
23
|
+
): Promise<I["istore"]> {
|
|
24
|
+
return givenCB();
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
uberCatcher(e: Error): void {
|
|
28
|
+
console.error("MockGiven error:", e);
|
|
29
|
+
this.error = e;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { BaseThen } from "../abstractBase";
|
|
2
|
+
import { Ibdd_in_any } from "../../CoreTypes";
|
|
3
|
+
|
|
4
|
+
export class MockThen<I extends Ibdd_in_any> extends BaseThen<I> {
|
|
5
|
+
constructor(
|
|
6
|
+
name: string,
|
|
7
|
+
thenCB: (val: I["iselection"]) => Promise<I["then"]>
|
|
8
|
+
) {
|
|
9
|
+
super(name, thenCB);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
async butThen(
|
|
13
|
+
store: I["istore"],
|
|
14
|
+
thenCB: (s: I["iselection"]) => Promise<I["isubject"]>,
|
|
15
|
+
testResourceConfiguration: any,
|
|
16
|
+
pm: any
|
|
17
|
+
): Promise<I["iselection"]> {
|
|
18
|
+
return thenCB(store);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { BaseWhen } from "../abstractBase";
|
|
2
|
+
import { Ibdd_in_any } from "../../CoreTypes";
|
|
3
|
+
|
|
4
|
+
export class MockWhen<I extends Ibdd_in_any> extends BaseWhen<I> {
|
|
5
|
+
constructor(name: string, whenCB: (x: I["iselection"]) => I["then"]) {
|
|
6
|
+
super(name, whenCB);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
async andWhen(
|
|
10
|
+
store: I["istore"],
|
|
11
|
+
whenCB: (x: I["iselection"]) => I["then"],
|
|
12
|
+
testResource: any,
|
|
13
|
+
pm: any
|
|
14
|
+
): Promise<I["istore"]> {
|
|
15
|
+
return whenCB(store);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { PassThrough } from "stream";
|
|
2
|
+
|
|
3
|
+
import { ITestImplementation } from "../../CoreTypes";
|
|
4
|
+
|
|
5
|
+
import { I, O } from "./types";
|
|
6
|
+
|
|
7
|
+
export const implementation: ITestImplementation<I, O> = {
|
|
8
|
+
suites: {
|
|
9
|
+
Default: "Abstract Base Test Suite",
|
|
10
|
+
},
|
|
11
|
+
|
|
12
|
+
givens: {
|
|
13
|
+
Default: () => ({
|
|
14
|
+
testStore: { value: "initial" },
|
|
15
|
+
testSelection: { selected: true },
|
|
16
|
+
}),
|
|
17
|
+
WithError: () => ({
|
|
18
|
+
testStore: { value: "error" },
|
|
19
|
+
testSelection: { selected: false },
|
|
20
|
+
}),
|
|
21
|
+
},
|
|
22
|
+
|
|
23
|
+
whens: {
|
|
24
|
+
modifyStore: (newValue: string) => (store) => ({
|
|
25
|
+
...store,
|
|
26
|
+
testStore: { value: newValue },
|
|
27
|
+
}),
|
|
28
|
+
throwError: () => () => {
|
|
29
|
+
throw new Error("Test error");
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
|
|
33
|
+
thens: {
|
|
34
|
+
verifyStore: (expected: string) => (store) => {
|
|
35
|
+
if (store.testStore.value !== expected) {
|
|
36
|
+
throw new Error(`Expected ${expected}, got ${store.testStore.value}`);
|
|
37
|
+
}
|
|
38
|
+
return store;
|
|
39
|
+
},
|
|
40
|
+
verifyError: (expected: string) => (store) => {
|
|
41
|
+
if (!store.error || !store.error.message.includes(expected)) {
|
|
42
|
+
throw new Error(`Expected error "${expected}" not found`);
|
|
43
|
+
}
|
|
44
|
+
return store;
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
|
|
48
|
+
checks: {
|
|
49
|
+
Default: () => new PassThrough(),
|
|
50
|
+
},
|
|
51
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import Testeranto from "../../Node";
|
|
2
|
+
import { specification } from "./specification";
|
|
3
|
+
import { implementation } from "./implementation";
|
|
4
|
+
import { testInterface } from "./interface";
|
|
5
|
+
import { I, O } from "./types";
|
|
6
|
+
import { MockGiven } from "./MockGiven";
|
|
7
|
+
import { MockThen } from "./MockThen";
|
|
8
|
+
import { MockWhen } from "./MockWhen";
|
|
9
|
+
|
|
10
|
+
export default Testeranto<I, O, {}>(
|
|
11
|
+
{
|
|
12
|
+
MockGiven,
|
|
13
|
+
MockWhen,
|
|
14
|
+
MockThen,
|
|
15
|
+
},
|
|
16
|
+
specification,
|
|
17
|
+
implementation,
|
|
18
|
+
testInterface
|
|
19
|
+
);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ITestInterface } from "../../CoreTypes";
|
|
2
|
+
import { I } from "./types";
|
|
3
|
+
|
|
4
|
+
export const testInterface: ITestInterface<I> = {
|
|
5
|
+
beforeEach: async (subject, initializer) => initializer(),
|
|
6
|
+
andWhen: async (store, whenCB) => whenCB(store),
|
|
7
|
+
butThen: async (store, thenCB) => thenCB(store),
|
|
8
|
+
afterEach: (store) => store,
|
|
9
|
+
afterAll: () => {},
|
|
10
|
+
assertThis: (result) => !!result,
|
|
11
|
+
beforeAll: async (input) => input as any
|
|
12
|
+
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { ITestSpecification } from "../../CoreTypes";
|
|
2
|
+
import { I, O } from "./types";
|
|
3
|
+
|
|
4
|
+
export const specification: ITestSpecification<I, O> = (
|
|
5
|
+
Suite,
|
|
6
|
+
Given,
|
|
7
|
+
When,
|
|
8
|
+
Then,
|
|
9
|
+
Check
|
|
10
|
+
) => [
|
|
11
|
+
Suite.Default("BaseGiven Tests", {
|
|
12
|
+
initialization: Given.Default(
|
|
13
|
+
["Should initialize with default values"],
|
|
14
|
+
[],
|
|
15
|
+
[Then.verifyStore("initial")]
|
|
16
|
+
),
|
|
17
|
+
errorHandling: Given.WithError(
|
|
18
|
+
["Should handle errors properly"],
|
|
19
|
+
[When.throwError()],
|
|
20
|
+
[Then.verifyError("Test error")]
|
|
21
|
+
)
|
|
22
|
+
}),
|
|
23
|
+
|
|
24
|
+
Suite.Default("BaseWhen Tests", {
|
|
25
|
+
stateModification: Given.Default(
|
|
26
|
+
["Should modify state correctly"],
|
|
27
|
+
[When.modifyStore("modified")],
|
|
28
|
+
[Then.verifyStore("modified")]
|
|
29
|
+
),
|
|
30
|
+
errorPropagation: Given.Default(
|
|
31
|
+
["Should propagate errors"],
|
|
32
|
+
[When.throwError()],
|
|
33
|
+
[Then.verifyError("Test error")]
|
|
34
|
+
)
|
|
35
|
+
}),
|
|
36
|
+
|
|
37
|
+
Suite.Default("BaseThen Tests", {
|
|
38
|
+
assertionPassing: Given.Default(
|
|
39
|
+
["Should pass valid assertions"],
|
|
40
|
+
[When.modifyStore("asserted")],
|
|
41
|
+
[Then.verifyStore("asserted")]
|
|
42
|
+
),
|
|
43
|
+
assertionFailing: Given.Default(
|
|
44
|
+
["Should fail invalid assertions"],
|
|
45
|
+
[When.modifyStore("wrong")],
|
|
46
|
+
[Then.verifyStore("right")] // This should fail
|
|
47
|
+
)
|
|
48
|
+
})
|
|
49
|
+
];
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Ibdd_in, Ibdd_out } from "../../CoreTypes";
|
|
2
|
+
|
|
3
|
+
export type I = Ibdd_in<
|
|
4
|
+
{}, // iinput
|
|
5
|
+
{}, // isubject
|
|
6
|
+
{ testStore: { value: string }; error?: Error }, // istore
|
|
7
|
+
{ testSelection: { selected: boolean } }, // iselection
|
|
8
|
+
() => { testStore: { value: string } }, // given
|
|
9
|
+
(store: any) => any, // when
|
|
10
|
+
(store: any) => any // then
|
|
11
|
+
>;
|
|
12
|
+
|
|
13
|
+
export type O = Ibdd_out<
|
|
14
|
+
{ Default: [string] }, // Suites
|
|
15
|
+
{ Default: []; WithError: [] }, // Givens
|
|
16
|
+
{ modifyStore: [string]; throwError: [] }, // Whens
|
|
17
|
+
{ verifyStore: [string]; verifyError: [string] }, // Thens
|
|
18
|
+
{ Default: [] } // Checks
|
|
19
|
+
>;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { BaseBuilder } from "../basebuilder";
|
|
2
|
+
import { Ibdd_in_any, Ibdd_out_any, ITestSpecification } from "../../CoreTypes";
|
|
3
|
+
import {
|
|
4
|
+
ISuiteKlasser,
|
|
5
|
+
IGivenKlasser,
|
|
6
|
+
IWhenKlasser,
|
|
7
|
+
IThenKlasser,
|
|
8
|
+
ICheckKlasser,
|
|
9
|
+
} from "../types";
|
|
10
|
+
import { ITTestResourceRequest } from "..";
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Concrete implementation of BaseBuilder for testing purposes only
|
|
14
|
+
*/
|
|
15
|
+
export class TestBaseBuilder<
|
|
16
|
+
I extends Ibdd_in_any,
|
|
17
|
+
O extends Ibdd_out_any,
|
|
18
|
+
SuiteExtensions = {},
|
|
19
|
+
GivenExtensions = {},
|
|
20
|
+
WhenExtensions = {},
|
|
21
|
+
ThenExtensions = {},
|
|
22
|
+
CheckExtensions = {}
|
|
23
|
+
> extends BaseBuilder<
|
|
24
|
+
I,
|
|
25
|
+
O,
|
|
26
|
+
SuiteExtensions,
|
|
27
|
+
GivenExtensions,
|
|
28
|
+
WhenExtensions,
|
|
29
|
+
ThenExtensions,
|
|
30
|
+
CheckExtensions
|
|
31
|
+
> {
|
|
32
|
+
public summary: Record<string, any> = {};
|
|
33
|
+
|
|
34
|
+
constructor(
|
|
35
|
+
input: I["iinput"],
|
|
36
|
+
suitesOverrides: Record<
|
|
37
|
+
keyof SuiteExtensions,
|
|
38
|
+
ISuiteKlasser<I, O>
|
|
39
|
+
> = {} as any,
|
|
40
|
+
givenOverrides: Record<keyof GivenExtensions, IGivenKlasser<I>> = {} as any,
|
|
41
|
+
whenOverrides: Record<keyof WhenExtensions, IWhenKlasser<I>> = {} as any,
|
|
42
|
+
thenOverrides: Record<keyof ThenExtensions, IThenKlasser<I>> = {} as any,
|
|
43
|
+
checkOverrides: Record<keyof CheckExtensions, ICheckKlasser<I>> = {} as any,
|
|
44
|
+
testResourceRequirement: ITTestResourceRequest = { ports: [] },
|
|
45
|
+
testSpecification: ITestSpecification<I, O> = () => []
|
|
46
|
+
) {
|
|
47
|
+
super(
|
|
48
|
+
input,
|
|
49
|
+
suitesOverrides,
|
|
50
|
+
givenOverrides,
|
|
51
|
+
whenOverrides,
|
|
52
|
+
thenOverrides,
|
|
53
|
+
checkOverrides,
|
|
54
|
+
testResourceRequirement,
|
|
55
|
+
testSpecification
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
this.summary = {};
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Simplified version for testing that doesn't actually run tests
|
|
63
|
+
*/
|
|
64
|
+
public testRun(puppetMaster: any): Promise<any> {
|
|
65
|
+
this.summary = {
|
|
66
|
+
[puppetMaster.testResourceConfiguration.name]: {
|
|
67
|
+
typeErrors: 0,
|
|
68
|
+
staticErrors: 0,
|
|
69
|
+
runTimeError: "",
|
|
70
|
+
prompt: "",
|
|
71
|
+
failingFeatures: {},
|
|
72
|
+
},
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
return Promise.resolve({
|
|
76
|
+
failed: false,
|
|
77
|
+
fails: 0,
|
|
78
|
+
artifacts: [],
|
|
79
|
+
logPromise: Promise.resolve(),
|
|
80
|
+
features: [],
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
}
|