zation-assured 0.6.3 → 3.0.0-dev.4

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 (151) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +55 -2
  3. package/dist/index.d.ts +2 -2
  4. package/dist/index.js +3 -9
  5. package/dist/lib/api/assert.d.ts +21 -14
  6. package/dist/lib/api/assert.js +17 -13
  7. package/dist/lib/api/testHelper.d.ts +0 -8
  8. package/dist/lib/api/testHelper.js +6 -83
  9. package/dist/lib/api/when.d.ts +41 -45
  10. package/dist/lib/api/when.js +42 -55
  11. package/dist/lib/helper/asserter/abstractActionAsserter.d.ts +68 -0
  12. package/dist/lib/helper/asserter/{rootSendAsserter.js → abstractActionAsserter.js} +23 -67
  13. package/dist/lib/helper/asserter/assertStarter.d.ts +5 -0
  14. package/dist/lib/helper/asserter/assertStarter.js +16 -0
  15. package/dist/lib/helper/asserter/channel/abstractChannelAsserter.d.ts +20 -29
  16. package/dist/lib/helper/asserter/channel/abstractChannelAsserter.js +44 -85
  17. package/dist/lib/helper/asserter/channel/channelAsserter.d.ts +3 -3
  18. package/dist/lib/helper/asserter/channel/channelAsserter.js +2 -2
  19. package/dist/lib/helper/asserter/channel/standaloneChannelAsserter.d.ts +6 -6
  20. package/dist/lib/helper/asserter/channel/standaloneChannelAsserter.js +7 -7
  21. package/dist/lib/helper/asserter/client/abstractClientAsserter.d.ts +20 -38
  22. package/dist/lib/helper/asserter/client/abstractClientAsserter.js +82 -184
  23. package/dist/lib/helper/asserter/client/clientAsserter.d.ts +3 -3
  24. package/dist/lib/helper/asserter/client/clientAsserter.js +2 -2
  25. package/dist/lib/helper/asserter/client/standaloneClientAsserter.d.ts +6 -6
  26. package/dist/lib/helper/asserter/client/standaloneClientAsserter.js +7 -7
  27. package/dist/lib/helper/asserter/controller/integratedResponseAsserter.d.ts +52 -0
  28. package/dist/lib/helper/asserter/controller/integratedResponseAsserter.js +122 -0
  29. package/dist/lib/helper/asserter/controller/standaloneResponseAsserter.d.ts +54 -0
  30. package/dist/lib/helper/asserter/controller/standaloneResponseAsserter.js +118 -0
  31. package/dist/lib/helper/asserter/databox/abstractDataboxAsserter.d.ts +29 -36
  32. package/dist/lib/helper/asserter/databox/abstractDataboxAsserter.js +44 -80
  33. package/dist/lib/helper/asserter/databox/databoxAsserter.d.ts +3 -3
  34. package/dist/lib/helper/asserter/databox/databoxAsserter.js +2 -2
  35. package/dist/lib/helper/asserter/databox/standaloneDataboxAsserter.d.ts +7 -6
  36. package/dist/lib/helper/asserter/databox/standaloneDataboxAsserter.js +7 -7
  37. package/dist/lib/helper/asserter/event/abstractEventAsserter.d.ts +12 -4
  38. package/dist/lib/helper/asserter/event/abstractEventAsserter.js +25 -10
  39. package/dist/lib/helper/asserter/event/codeMetadataEventAsserter.d.ts +21 -0
  40. package/dist/lib/helper/asserter/event/codeMetadataEventAsserter.js +47 -0
  41. package/dist/lib/helper/asserter/event/dataEventAsserter.d.ts +13 -3
  42. package/dist/lib/helper/asserter/event/dataEventAsserter.js +22 -4
  43. package/dist/lib/helper/asserter/receiver/integratedTransmitAsserter.d.ts +9 -0
  44. package/dist/lib/helper/asserter/receiver/{transmitAsserter.js → integratedTransmitAsserter.js} +9 -9
  45. package/dist/lib/helper/asserter/value/abstractValueAsserter.d.ts +13 -15
  46. package/dist/lib/helper/asserter/value/abstractValueAsserter.js +49 -53
  47. package/dist/lib/helper/asserter/value/standaloneValueAsserter.d.ts +3 -3
  48. package/dist/lib/helper/asserter/value/standaloneValueAsserter.js +6 -6
  49. package/dist/lib/helper/asserter/value/valueAsserter.d.ts +4 -4
  50. package/dist/lib/helper/asserter/value/valueAsserter.js +4 -4
  51. package/dist/lib/helper/backError/backErrorsFilterBuilder.d.ts +12 -0
  52. package/dist/lib/helper/backError/backErrorsFilterBuilder.js +29 -0
  53. package/dist/lib/helper/console/logger.js +2 -2
  54. package/dist/lib/helper/definitions/optionTypes.d.ts +8 -0
  55. package/dist/lib/helper/definitions/optionTypes.js +7 -0
  56. package/dist/lib/helper/test/test.d.ts +2 -2
  57. package/dist/lib/helper/test/test.js +8 -6
  58. package/dist/lib/helper/timeout/timeoutAssert.js +2 -2
  59. package/dist/lib/helper/utils/actionUtils.d.ts +5 -18
  60. package/dist/lib/helper/utils/actionUtils.js +14 -43
  61. package/dist/lib/helper/utils/types.d.ts +20 -0
  62. package/dist/lib/helper/utils/types.js +7 -0
  63. package/package.json +9 -12
  64. package/dist/lib/api/before.d.ts +0 -3
  65. package/dist/lib/api/before.js +0 -20
  66. package/dist/lib/api/client.d.ts +0 -3
  67. package/dist/lib/api/client.js +0 -11
  68. package/dist/lib/api/describe.d.ts +0 -1
  69. package/dist/lib/api/describe.js +0 -6
  70. package/dist/lib/api/instanceManager.d.ts +0 -8
  71. package/dist/lib/api/instanceManager.js +0 -48
  72. package/dist/lib/api/testArea.d.ts +0 -3
  73. package/dist/lib/api/testArea.js +0 -41
  74. package/dist/lib/api/testServerManager.d.ts +0 -19
  75. package/dist/lib/api/testServerManager.js +0 -100
  76. package/dist/lib/helper/asserter/abstractClientAsserter.d.ts +0 -102
  77. package/dist/lib/helper/asserter/abstractClientAsserter.js +0 -293
  78. package/dist/lib/helper/asserter/anyAsserter.d.ts +0 -62
  79. package/dist/lib/helper/asserter/anyAsserter.js +0 -130
  80. package/dist/lib/helper/asserter/channelEventAsserter.d.ts +0 -34
  81. package/dist/lib/helper/asserter/channelEventAsserter.js +0 -84
  82. package/dist/lib/helper/asserter/channelPubAsserter.d.ts +0 -53
  83. package/dist/lib/helper/asserter/channelPubAsserter.js +0 -126
  84. package/dist/lib/helper/asserter/clientAsserter.d.ts +0 -13
  85. package/dist/lib/helper/asserter/clientAsserter.js +0 -26
  86. package/dist/lib/helper/asserter/controller/responseAsserter.d.ts +0 -74
  87. package/dist/lib/helper/asserter/controller/responseAsserter.js +0 -138
  88. package/dist/lib/helper/asserter/dataEventAsserter.d.ts +0 -40
  89. package/dist/lib/helper/asserter/dataEventAsserter.js +0 -113
  90. package/dist/lib/helper/asserter/event/abstractDataEventAsserter.d.ts +0 -13
  91. package/dist/lib/helper/asserter/event/abstractDataEventAsserter.js +0 -36
  92. package/dist/lib/helper/asserter/event/codeDataEventAsserter.d.ts +0 -14
  93. package/dist/lib/helper/asserter/event/codeDataEventAsserter.js +0 -40
  94. package/dist/lib/helper/asserter/eventAsserter.d.ts +0 -41
  95. package/dist/lib/helper/asserter/eventAsserter.js +0 -115
  96. package/dist/lib/helper/asserter/objectAsserter.d.ts +0 -55
  97. package/dist/lib/helper/asserter/objectAsserter.js +0 -113
  98. package/dist/lib/helper/asserter/receiver/transmitAsserter.d.ts +0 -9
  99. package/dist/lib/helper/asserter/responseAsserter.d.ts +0 -129
  100. package/dist/lib/helper/asserter/responseAsserter.js +0 -260
  101. package/dist/lib/helper/asserter/rootSendAsserter.d.ts +0 -89
  102. package/dist/lib/helper/asserter/standaloneClientAsserter.d.ts +0 -11
  103. package/dist/lib/helper/asserter/standaloneClientAsserter.js +0 -38
  104. package/dist/lib/helper/assured/clientAssured.d.ts +0 -2
  105. package/dist/lib/helper/assured/clientAssured.js +0 -11
  106. package/dist/lib/helper/assured/responseAssured.d.ts +0 -17
  107. package/dist/lib/helper/assured/responseAssured.js +0 -72
  108. package/dist/lib/helper/backError/backErrorFilterBuilder.d.ts +0 -13
  109. package/dist/lib/helper/backError/backErrorFilterBuilder.js +0 -32
  110. package/dist/lib/helper/builder/controller/abstractRequestBuilder.d.ts +0 -53
  111. package/dist/lib/helper/builder/controller/abstractRequestBuilder.js +0 -69
  112. package/dist/lib/helper/builder/controller/authRequestBuilder.d.ts +0 -15
  113. package/dist/lib/helper/builder/controller/authRequestBuilder.js +0 -30
  114. package/dist/lib/helper/builder/controller/standardRequestBuilder.d.ts +0 -15
  115. package/dist/lib/helper/builder/controller/standardRequestBuilder.js +0 -30
  116. package/dist/lib/helper/builder/controller/validationCheckRequestBuilder.d.ts +0 -21
  117. package/dist/lib/helper/builder/controller/validationCheckRequestBuilder.js +0 -40
  118. package/dist/lib/helper/builder/receiver/packageBuilder.d.ts +0 -45
  119. package/dist/lib/helper/builder/receiver/packageBuilder.js +0 -67
  120. package/dist/lib/helper/controller/request/abstractRequestBuilder.d.ts +0 -53
  121. package/dist/lib/helper/controller/request/abstractRequestBuilder.js +0 -68
  122. package/dist/lib/helper/controller/request/authRequestBuilder.d.ts +0 -15
  123. package/dist/lib/helper/controller/request/authRequestBuilder.js +0 -29
  124. package/dist/lib/helper/controller/request/standardRequestBuilder.d.ts +0 -15
  125. package/dist/lib/helper/controller/request/standardRequestBuilder.js +0 -29
  126. package/dist/lib/helper/controller/request/validationCheckRequestBuilder.d.ts +0 -21
  127. package/dist/lib/helper/controller/request/validationCheckRequestBuilder.js +0 -39
  128. package/dist/lib/helper/data/test.d.ts +0 -13
  129. package/dist/lib/helper/data/test.js +0 -89
  130. package/dist/lib/helper/do/actionUtils.d.ts +0 -24
  131. package/dist/lib/helper/do/actionUtils.js +0 -70
  132. package/dist/lib/helper/do/doUtils.d.ts +0 -24
  133. package/dist/lib/helper/do/doUtils.js +0 -80
  134. package/dist/lib/helper/error/backErrorFilterBuilder.d.ts +0 -13
  135. package/dist/lib/helper/error/backErrorFilterBuilder.js +0 -34
  136. package/dist/lib/helper/error/taskErrorFilterBuilder.d.ts +0 -13
  137. package/dist/lib/helper/error/taskErrorFilterBuilder.js +0 -34
  138. package/dist/lib/helper/request/abstractRequestBuilder.d.ts +0 -53
  139. package/dist/lib/helper/request/abstractRequestBuilder.js +0 -68
  140. package/dist/lib/helper/request/authRequestBuilder.d.ts +0 -15
  141. package/dist/lib/helper/request/authRequestBuilder.js +0 -29
  142. package/dist/lib/helper/request/requestBuilder.d.ts +0 -46
  143. package/dist/lib/helper/request/requestBuilder.js +0 -76
  144. package/dist/lib/helper/request/standardRequestBuilder.d.ts +0 -15
  145. package/dist/lib/helper/request/standardRequestBuilder.js +0 -29
  146. package/dist/lib/helper/request/validationCheckRequestBuilder.d.ts +0 -21
  147. package/dist/lib/helper/request/validationCheckRequestBuilder.js +0 -39
  148. package/dist/lib/helper/request/validationRequestBuilder.d.ts +0 -35
  149. package/dist/lib/helper/request/validationRequestBuilder.js +0 -61
  150. package/dist/lib/helper/utils/clientUtils.d.ts +0 -4
  151. package/dist/lib/helper/utils/clientUtils.js +0 -29
@@ -1,293 +0,0 @@
1
- "use strict";
2
- /*
3
- Author: Luca Scaringella
4
- GitHub: LucaCode
5
- ©Copyright by Luca Scaringella
6
- */
7
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
8
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
9
- return new (P || (P = Promise))(function (resolve, reject) {
10
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
11
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
12
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
13
- step((generator = generator.apply(thisArg, _arguments || [])).next());
14
- });
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- const assert = require('assert');
18
- const zation_client_1 = require("zation-client");
19
- const objectAsserter_1 = require("./objectAsserter");
20
- const timeoutAssert_1 = require("../timeout/timeoutAssert");
21
- const doUtils_1 = require("../do/doUtils");
22
- const eventAsserter_1 = require("./eventAsserter");
23
- class AbstractClientAsserter {
24
- constructor(clients, test) {
25
- this._test = test;
26
- this.clients = clients;
27
- }
28
- _forEachClient(func) {
29
- return __awaiter(this, void 0, void 0, function* () {
30
- let promises = [];
31
- this.clients.forEach((c, i) => {
32
- promises.push(func(c, i));
33
- });
34
- yield Promise.all(promises);
35
- });
36
- }
37
- // noinspection JSUnusedGlobalSymbols
38
- /**
39
- * @description
40
- * Assert that the client is connected.
41
- * @param timeout
42
- * With this parameter, you can set a time limit in that the assertion must be successful.
43
- */
44
- isConnected(timeout = 0) {
45
- this._test.test(() => __awaiter(this, void 0, void 0, function* () {
46
- yield this._forEachClient((c, i) => __awaiter(this, void 0, void 0, function* () {
47
- if (c.isConnected()) {
48
- return;
49
- }
50
- const toa = new timeoutAssert_1.TimeoutAssert(`Client: ${i} should be connected.`, timeout);
51
- c.eventReact().onceConnect(() => {
52
- toa.resolve();
53
- });
54
- yield toa.set();
55
- }));
56
- }));
57
- return this.self();
58
- }
59
- // noinspection JSUnusedGlobalSymbols
60
- /**
61
- * @description
62
- * Assert that the client is disconnected.
63
- * @param timeout
64
- * With this parameter, you can set a time limit in that the assertion must be successful.
65
- */
66
- isDisconnected(timeout = 0) {
67
- this._test.test(() => __awaiter(this, void 0, void 0, function* () {
68
- yield this._forEachClient((c, i) => __awaiter(this, void 0, void 0, function* () {
69
- if (!c.isConnected()) {
70
- return;
71
- }
72
- const toa = new timeoutAssert_1.TimeoutAssert(`Client: ${i} should be disconnected.`, timeout);
73
- c.eventReact().onceDisconnect(() => {
74
- toa.resolve();
75
- });
76
- yield toa.set();
77
- }));
78
- }));
79
- return this.self();
80
- }
81
- // noinspection JSUnusedGlobalSymbols
82
- /**
83
- * @description
84
- * Assert that the client is authenticated.
85
- * @param timeout
86
- * With this parameter, you can set a time limit in that the assertion must be successful.
87
- */
88
- isAuthenticated(timeout = 0) {
89
- this._test.test(() => __awaiter(this, void 0, void 0, function* () {
90
- yield this._forEachClient((c, i) => __awaiter(this, void 0, void 0, function* () {
91
- if (c.isAuthenticated()) {
92
- return;
93
- }
94
- const toa = new timeoutAssert_1.TimeoutAssert(`Client: ${i} should be authenticated.`, timeout);
95
- c.eventReact().onceAuthenticate(() => {
96
- toa.resolve();
97
- });
98
- yield toa.set();
99
- }));
100
- }));
101
- return this.self();
102
- }
103
- // noinspection JSUnusedGlobalSymbols
104
- /**
105
- * @description
106
- * Assert that the client is deauthenticated.
107
- * @param timeout
108
- * With this parameter, you can set a time limit in that the assertion must be successful.
109
- */
110
- isDeauthenticated(timeout = 0) {
111
- this._test.test(() => __awaiter(this, void 0, void 0, function* () {
112
- yield this._forEachClient((c, i) => __awaiter(this, void 0, void 0, function* () {
113
- if (!c.isAuthenticated()) {
114
- return;
115
- }
116
- const toa = new timeoutAssert_1.TimeoutAssert(`Client: ${i} should be deauthenticated.`, timeout);
117
- c.eventReact().onceDeauthenticate(() => {
118
- toa.resolve();
119
- });
120
- yield toa.set();
121
- }));
122
- }));
123
- return this.self();
124
- }
125
- // noinspection JSUnusedGlobalSymbols
126
- /**
127
- * @description
128
- * Assert that the client has a user id.
129
- * @param userId
130
- * If it is not given it will assert that the client has any user id.
131
- */
132
- hasUserId(userId) {
133
- this._test.test(() => __awaiter(this, void 0, void 0, function* () {
134
- yield this._forEachClient((c, i) => __awaiter(this, void 0, void 0, function* () {
135
- const currentId = c.userId;
136
- if (userId !== undefined) {
137
- assert.equal(currentId, userId, `Client: ${i} should have the userId: ${userId}`);
138
- }
139
- else if (currentId === undefined) {
140
- assert.fail(`Client: ${i} should have any user id.`);
141
- }
142
- }));
143
- }));
144
- return this.self();
145
- }
146
- // noinspection JSUnusedGlobalSymbols
147
- /**
148
- * @description
149
- * Assert that the client has a authUserGroup.
150
- * @param authUserGroup
151
- * If it is not given it will assert that the client has any authUserGroup.
152
- */
153
- hasAuthUserGroup(authUserGroup) {
154
- this._test.test(() => __awaiter(this, void 0, void 0, function* () {
155
- yield this._forEachClient((c, i) => __awaiter(this, void 0, void 0, function* () {
156
- const currentGroup = c.authUserGroup;
157
- if (authUserGroup !== undefined) {
158
- assert.equal(currentGroup, authUserGroup, `Client: ${i} should have the authUserGroup: ${authUserGroup}`);
159
- }
160
- else if (currentGroup === undefined) {
161
- assert.fail(`Client: ${i} should have any authUserGroup.`);
162
- }
163
- }));
164
- }));
165
- return this.self();
166
- }
167
- // noinspection JSUnusedGlobalSymbols
168
- /**
169
- * @description
170
- * Assert that the client has a specific token id.
171
- */
172
- hasTokenId(tokenId) {
173
- this._test.test(() => __awaiter(this, void 0, void 0, function* () {
174
- yield this._forEachClient((c, i) => __awaiter(this, void 0, void 0, function* () {
175
- try {
176
- const currentTokenId = c.tokenId;
177
- assert.equal(currentTokenId, tokenId, `Client: ${i} should have the tokenId: ${tokenId}`);
178
- }
179
- catch (e) {
180
- if (e instanceof zation_client_1.AuthenticationRequiredError) {
181
- assert.fail(`Client: ${i} can not access the token for assert token id.`);
182
- }
183
- else {
184
- throw e;
185
- }
186
- }
187
- }));
188
- }));
189
- return this.self();
190
- }
191
- // noinspection JSUnusedGlobalSymbols
192
- /**
193
- * @description
194
- * Assert that the client has panel access.
195
- */
196
- hasPanelAccess(access = true) {
197
- this._test.test(() => __awaiter(this, void 0, void 0, function* () {
198
- yield this._forEachClient((c, i) => __awaiter(this, void 0, void 0, function* () {
199
- try {
200
- const currentAccess = c.hasPanelAccess();
201
- assert.equal(currentAccess, access, `Client: ${i} should ${access ? '' : 'not'} have panel access`);
202
- }
203
- catch (e) {
204
- if (e instanceof zation_client_1.AuthenticationRequiredError) {
205
- assert.fail(`Client: ${i} can not access the token for assert panel access.`);
206
- }
207
- else {
208
- throw e;
209
- }
210
- }
211
- }));
212
- }));
213
- return this.self();
214
- }
215
- // noinspection JSUnusedGlobalSymbols
216
- /**
217
- * @description
218
- * Assert the token payload of the client.
219
- */
220
- assertTokenPayload() {
221
- return new objectAsserter_1.default(this.self(), 'Client:', (test) => {
222
- this._test.test(() => __awaiter(this, void 0, void 0, function* () {
223
- yield this._forEachClient((c, i) => __awaiter(this, void 0, void 0, function* () {
224
- try {
225
- test(c.getTokenPayload(), ` ${i} Token: `);
226
- }
227
- catch (e) {
228
- if (e instanceof zation_client_1.AuthenticationRequiredError) {
229
- assert.fail(`Client: ${i} can not access the token for assert token payload.`);
230
- }
231
- else {
232
- throw e;
233
- }
234
- }
235
- }));
236
- }));
237
- });
238
- }
239
- // noinspection JSUnusedGlobalSymbols
240
- /**
241
- * @description
242
- * With this function you can create custom assertions for a client.
243
- * @param assert
244
- * The assert function with params:
245
- * -client the client
246
- * -index the index of the client
247
- */
248
- assert(assert) {
249
- this._test.test(() => __awaiter(this, void 0, void 0, function* () {
250
- yield this._forEachClient((c, i) => __awaiter(this, void 0, void 0, function* () {
251
- yield assert(c, i);
252
- }));
253
- }));
254
- return this.self();
255
- }
256
- // noinspection JSUnusedGlobalSymbols
257
- /**
258
- * @description
259
- * With this function, you can do extra things in the test.
260
- * Subscribe a channel, publish to a channel...
261
- * @param func
262
- * @param failMsg if not provided it throws the specific error.
263
- */
264
- do(func, failMsg) {
265
- doUtils_1.default.do(this._test, func, failMsg);
266
- return this.self();
267
- }
268
- // noinspection JSUnusedGlobalSymbols
269
- /**
270
- * @description
271
- * With this function, you can do extra things in the test
272
- * and assert that it should throw an error or a specific error.
273
- * Subscribe a channel, publish to a channel...
274
- * @param func
275
- * @param failMsg
276
- * @param errors
277
- */
278
- doShouldThrow(func, failMsg, ...errors) {
279
- doUtils_1.default.doShouldThrow(this._test, func, failMsg, ...errors);
280
- return this.self();
281
- }
282
- // noinspection JSUnusedGlobalSymbols
283
- /**
284
- * @description
285
- * Assert that the client should receive an emit-event from the server.
286
- * It uses the custom zation event namespace
287
- * (so you cannot have name conflicts with internal event names).
288
- */
289
- receiveEvent(event, responder) {
290
- return new eventAsserter_1.EventAsserter(this.clients, event, this._test, this.self(), responder);
291
- }
292
- }
293
- exports.AbstractClientAsserter = AbstractClientAsserter;
@@ -1,62 +0,0 @@
1
- import ObjectAsserter from "./objectAsserter";
2
- import { ForintQuery } from "forint";
3
- declare type AddTest = (test: (any: any, eStr?: string) => void) => void;
4
- export declare class AnyAsserter<T> {
5
- protected readonly self: T;
6
- private readonly addTest;
7
- private readonly name;
8
- constructor(self: T, name: string, addTest: AddTest);
9
- /**
10
- * @description
11
- * Assert that any is undefined.
12
- */
13
- isUndefined(): AnyAsserter<T>;
14
- /**
15
- * @description
16
- * Assert that any is from a specific type.
17
- * @param type
18
- */
19
- typeOf(type: string): AnyAsserter<T>;
20
- /**
21
- * @description
22
- * Assert that any is equal with...
23
- * Is using the == operator to check.
24
- * @param any
25
- */
26
- equal(any: any): AnyAsserter<T>;
27
- /**
28
- * @description
29
- * Assert that any is strict equal with...
30
- * Is using the === operator to check.
31
- * @param any
32
- */
33
- strictEqual(any: any): AnyAsserter<T>;
34
- /**
35
- * @description
36
- * Object assert any.
37
- * This assertion will only invoked when any is from type object.
38
- * @param addTypeOfAssertion
39
- * Indicates if it should add a type of assertion for type object.
40
- * Default value is true.
41
- */
42
- objectAssert(addTypeOfAssertion?: boolean): ObjectAsserter<AnyAsserter<T>>;
43
- /**
44
- * Asserts that any matches with a forint query.
45
- */
46
- matches(query: ForintQuery): AnyAsserter<T>;
47
- /**
48
- * @description
49
- * With this function you can create custom assertions for any.
50
- * @param assert
51
- * function with params
52
- * -any the input
53
- * -name the name of this assertion.
54
- */
55
- assert(assert: (any: any, name: string) => void | Promise<void>): AnyAsserter<T>;
56
- /**
57
- * @description
58
- * End the any asserter.
59
- */
60
- end(): T;
61
- }
62
- export {};
@@ -1,130 +0,0 @@
1
- "use strict";
2
- /*
3
- Author: Luca Scaringella
4
- GitHub: LucaCode
5
- ©Copyright by Luca Scaringella
6
- */
7
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
8
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
9
- return new (P || (P = Promise))(function (resolve, reject) {
10
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
11
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
12
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
13
- step((generator = generator.apply(thisArg, _arguments || [])).next());
14
- });
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- const objectAsserter_1 = require("./objectAsserter");
18
- const forint_1 = require("forint");
19
- const cAssert = require('chai').assert;
20
- class AnyAsserter {
21
- constructor(self, name, addTest) {
22
- this.self = self;
23
- this.addTest = addTest;
24
- this.name = name;
25
- }
26
- // noinspection JSUnusedGlobalSymbols
27
- /**
28
- * @description
29
- * Assert that any is undefined.
30
- */
31
- isUndefined() {
32
- this.addTest((any, eStr = '') => {
33
- cAssert(any === undefined, `${this.name + eStr} should be undefined.`);
34
- });
35
- return this;
36
- }
37
- // noinspection JSUnusedGlobalSymbols
38
- /**
39
- * @description
40
- * Assert that any is from a specific type.
41
- * @param type
42
- */
43
- typeOf(type) {
44
- this.addTest((any, eStr = '') => {
45
- cAssert.typeOf(any, type, `${this.name + eStr} should from type ${type}`);
46
- });
47
- return this;
48
- }
49
- // noinspection JSUnusedGlobalSymbols
50
- /**
51
- * @description
52
- * Assert that any is equal with...
53
- * Is using the == operator to check.
54
- * @param any
55
- */
56
- equal(any) {
57
- this.addTest((inAny, eStr = '') => {
58
- cAssert.equal(inAny, any, `${this.name + eStr} should equal with ${any}`);
59
- });
60
- return this;
61
- }
62
- // noinspection JSUnusedGlobalSymbols
63
- /**
64
- * @description
65
- * Assert that any is strict equal with...
66
- * Is using the === operator to check.
67
- * @param any
68
- */
69
- strictEqual(any) {
70
- this.addTest((inAny, eStr = '') => {
71
- cAssert.strictEqual(inAny, any, `${this.name + eStr} should strict equal with ${any}`);
72
- });
73
- return this;
74
- }
75
- // noinspection JSUnusedGlobalSymbols
76
- /**
77
- * @description
78
- * Object assert any.
79
- * This assertion will only invoked when any is from type object.
80
- * @param addTypeOfAssertion
81
- * Indicates if it should add a type of assertion for type object.
82
- * Default value is true.
83
- */
84
- objectAssert(addTypeOfAssertion = true) {
85
- if (addTypeOfAssertion) {
86
- this.typeOf('object');
87
- }
88
- return new objectAsserter_1.default(this, this.name, (test) => {
89
- this.addTest((any, eStr = '') => {
90
- if (typeof any === 'object') {
91
- test(any, eStr);
92
- }
93
- });
94
- });
95
- }
96
- // noinspection JSUnusedGlobalSymbols
97
- /**
98
- * Asserts that any matches with a forint query.
99
- */
100
- matches(query) {
101
- this.addTest((inAny, eStr = '') => __awaiter(this, void 0, void 0, function* () {
102
- yield cAssert(forint_1.default(query)(inAny), `${this.name + eStr} should match with the forint query.`);
103
- }));
104
- return this;
105
- }
106
- // noinspection JSUnusedGlobalSymbols
107
- /**
108
- * @description
109
- * With this function you can create custom assertions for any.
110
- * @param assert
111
- * function with params
112
- * -any the input
113
- * -name the name of this assertion.
114
- */
115
- assert(assert) {
116
- this.addTest((inAny, eStr = '') => __awaiter(this, void 0, void 0, function* () {
117
- yield assert(inAny, this.name + eStr);
118
- }));
119
- return this;
120
- }
121
- // noinspection JSUnusedGlobalSymbols
122
- /**
123
- * @description
124
- * End the any asserter.
125
- */
126
- end() {
127
- return this.self;
128
- }
129
- }
130
- exports.AnyAsserter = AnyAsserter;
@@ -1,34 +0,0 @@
1
- import { Test } from "../data/test";
2
- import { Zation as ZationClient } from 'zation-client';
3
- declare type AddReaction = (client: ZationClient, reaction: () => Promise<void>) => void;
4
- export declare class ChannelEventAsserter<T> {
5
- protected readonly _test: Test;
6
- protected readonly _addOnceReaction: AddReaction;
7
- protected readonly _clients: ZationClient[];
8
- protected readonly _source: T;
9
- protected readonly _chName: string;
10
- protected readonly _eventName: string;
11
- private _timeout;
12
- private _not;
13
- constructor(addReaction: AddReaction, clients: ZationClient[], chName: string, eventName: string, test: Test, source: T);
14
- /**
15
- * @description
16
- * With this function, you can set a time limit in that the channel event action must happen.
17
- * @default
18
- * The default value is 0.
19
- */
20
- timeout(timeout: number): ChannelEventAsserter<T>;
21
- /**
22
- * @description
23
- * With this function, you can assert that the event should not be triggered.
24
- * @default
25
- * The default value is false.
26
- */
27
- not(): ChannelEventAsserter<T>;
28
- /**
29
- * @description
30
- * End the channel event asserter.
31
- */
32
- end(): T;
33
- }
34
- export {};
@@ -1,84 +0,0 @@
1
- "use strict";
2
- /*
3
- Author: Luca Scaringella
4
- GitHub: LucaCode
5
- ©Copyright by Luca Scaringella
6
- */
7
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
8
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
9
- return new (P || (P = Promise))(function (resolve, reject) {
10
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
11
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
12
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
13
- step((generator = generator.apply(thisArg, _arguments || [])).next());
14
- });
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- const timeoutAssert_1 = require("../timeout/timeoutAssert");
18
- const assert = require('assert');
19
- class ChannelEventAsserter {
20
- constructor(addReaction, clients, chName, eventName, test, source) {
21
- this._timeout = 0;
22
- this._not = false;
23
- this._addOnceReaction = addReaction;
24
- this._clients = clients;
25
- this._chName = chName;
26
- this._eventName = eventName;
27
- this._test = test;
28
- this._source = source;
29
- }
30
- // noinspection JSUnusedGlobalSymbols
31
- /**
32
- * @description
33
- * With this function, you can set a time limit in that the channel event action must happen.
34
- * @default
35
- * The default value is 0.
36
- */
37
- timeout(timeout) {
38
- this._timeout = timeout;
39
- return this;
40
- }
41
- // noinspection JSUnusedGlobalSymbols
42
- /**
43
- * @description
44
- * With this function, you can assert that the event should not be triggered.
45
- * @default
46
- * The default value is false.
47
- */
48
- not() {
49
- this._not = true;
50
- return this;
51
- }
52
- // noinspection JSUnusedGlobalSymbols
53
- /**
54
- * @description
55
- * End the channel event asserter.
56
- */
57
- end() {
58
- this._clients.forEach((c, i) => {
59
- let eventFired = false;
60
- let resolve;
61
- this._test.beforeTest(() => {
62
- this._addOnceReaction(c, () => __awaiter(this, void 0, void 0, function* () {
63
- eventFired = true;
64
- if (typeof resolve === 'function') {
65
- resolve();
66
- }
67
- }));
68
- });
69
- const failMsg = `Client: ${i} should ${this._not ? 'not' : ''} trigger the ${this._eventName} event in the channel: ${this._chName}.`;
70
- this._test.test(() => __awaiter(this, void 0, void 0, function* () {
71
- if (!eventFired) {
72
- const toa = new timeoutAssert_1.TimeoutAssert(failMsg, this._timeout, this._not);
73
- resolve = () => { toa.resolve(); };
74
- yield toa.set();
75
- }
76
- else if (this._not) {
77
- assert.fail(failMsg);
78
- }
79
- }));
80
- });
81
- return this._source;
82
- }
83
- }
84
- exports.ChannelEventAsserter = ChannelEventAsserter;
@@ -1,53 +0,0 @@
1
- import { Test } from "../data/test";
2
- import { Zation as ZationClient } from 'zation-client';
3
- import { AnyAsserter } from "./anyAsserter";
4
- declare type AddReaction = (client: ZationClient, event: string | string[] | null, reaction: (data: any) => Promise<void>) => void;
5
- export declare class ChannelPubAsserter<T> {
6
- protected readonly _test: Test;
7
- protected readonly _addOnceReaction: AddReaction;
8
- protected readonly _clients: ZationClient[];
9
- protected readonly _source: T;
10
- protected readonly _chName: string;
11
- private readonly _pubDataChecker;
12
- private _timeout;
13
- private _event;
14
- private _not;
15
- constructor(addReaction: AddReaction, clients: ZationClient[], chName: string, test: Test, source: T);
16
- /**
17
- * @description
18
- * With this function, you can set a time limit in that the publish action must happen.
19
- * @default
20
- * The default value is 0.
21
- */
22
- timeout(timeout: number): ChannelPubAsserter<T>;
23
- /**
24
- * @description
25
- * With this function, you set that the client should not get a publish.
26
- * @default
27
- * The default value is false.
28
- */
29
- not(): ChannelPubAsserter<T>;
30
- /**
31
- * @description
32
- * With this function, you can filter for a specific event.
33
- * @param event
34
- * You can also filter multiple events by giving an event array.
35
- * Or to all events if you pass as parameter null.
36
- * @default
37
- * The default value is null.
38
- */
39
- event(event: string | string[] | null): ChannelPubAsserter<T>;
40
- /**
41
- * @description
42
- * Assert the published data.
43
- * Notice that the pub data will not checked in (get not) mode.
44
- */
45
- assertPubData(): AnyAsserter<ChannelPubAsserter<T>>;
46
- private _checkPubData;
47
- /**
48
- * @description
49
- * End the channel publish asserter.
50
- */
51
- end(): T;
52
- }
53
- export {};