zation-assured 0.5.1 → 3.0.0-dev.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/LICENSE +1 -1
- package/README.md +55 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +3 -9
- package/dist/lib/api/assert.d.ts +16 -9
- package/dist/lib/api/assert.js +16 -12
- package/dist/lib/api/testHelper.d.ts +0 -8
- package/dist/lib/api/testHelper.js +6 -83
- package/dist/lib/api/when.d.ts +41 -45
- package/dist/lib/api/when.js +42 -55
- package/dist/lib/helper/asserter/abstractActionAsserter.d.ts +68 -0
- package/dist/lib/helper/asserter/{rootSendAsserter.js → abstractActionAsserter.js} +23 -67
- package/dist/lib/helper/asserter/assertStarter.d.ts +5 -0
- package/dist/lib/helper/asserter/assertStarter.js +16 -0
- package/dist/lib/helper/asserter/channel/abstractChannelAsserter.d.ts +24 -33
- package/dist/lib/helper/asserter/channel/abstractChannelAsserter.js +48 -89
- package/dist/lib/helper/asserter/channel/channelAsserter.d.ts +3 -3
- package/dist/lib/helper/asserter/channel/channelAsserter.js +2 -2
- package/dist/lib/helper/asserter/channel/standaloneChannelAsserter.d.ts +5 -5
- package/dist/lib/helper/asserter/channel/standaloneChannelAsserter.js +6 -6
- package/dist/lib/helper/asserter/client/abstractClientAsserter.d.ts +29 -47
- package/dist/lib/helper/asserter/client/abstractClientAsserter.js +91 -193
- package/dist/lib/helper/asserter/client/clientAsserter.d.ts +3 -3
- package/dist/lib/helper/asserter/client/clientAsserter.js +2 -2
- package/dist/lib/helper/asserter/client/standaloneClientAsserter.d.ts +5 -5
- package/dist/lib/helper/asserter/client/standaloneClientAsserter.js +6 -6
- package/dist/lib/helper/asserter/controller/integratedResponseAsserter.d.ts +52 -0
- package/dist/lib/helper/asserter/controller/integratedResponseAsserter.js +112 -0
- package/dist/lib/helper/asserter/controller/standaloneResponseAsserter.d.ts +49 -0
- package/dist/lib/helper/asserter/controller/standaloneResponseAsserter.js +108 -0
- package/dist/lib/helper/asserter/databox/abstractDataboxAsserter.d.ts +33 -40
- package/dist/lib/helper/asserter/databox/abstractDataboxAsserter.js +48 -84
- package/dist/lib/helper/asserter/databox/databoxAsserter.d.ts +3 -3
- package/dist/lib/helper/asserter/databox/databoxAsserter.js +2 -2
- package/dist/lib/helper/asserter/databox/standaloneDataboxAsserter.d.ts +6 -5
- package/dist/lib/helper/asserter/databox/standaloneDataboxAsserter.js +6 -6
- package/dist/lib/helper/asserter/event/abstractEventAsserter.d.ts +12 -4
- package/dist/lib/helper/asserter/event/abstractEventAsserter.js +25 -10
- package/dist/lib/helper/asserter/event/codeMetadataEventAsserter.d.ts +21 -0
- package/dist/lib/helper/asserter/event/codeMetadataEventAsserter.js +47 -0
- package/dist/lib/helper/asserter/event/dataEventAsserter.d.ts +13 -3
- package/dist/lib/helper/asserter/event/dataEventAsserter.js +22 -4
- package/dist/lib/helper/asserter/receiver/integratedTransmitAsserter.d.ts +9 -0
- package/dist/lib/helper/asserter/receiver/{transmitAsserter.js → integratedTransmitAsserter.js} +9 -9
- package/dist/lib/helper/asserter/value/abstractValueAsserter.d.ts +10 -12
- package/dist/lib/helper/asserter/value/abstractValueAsserter.js +46 -50
- package/dist/lib/helper/asserter/value/standaloneValueAsserter.d.ts +3 -3
- package/dist/lib/helper/asserter/value/standaloneValueAsserter.js +6 -6
- package/dist/lib/helper/asserter/value/valueAsserter.d.ts +4 -4
- package/dist/lib/helper/asserter/value/valueAsserter.js +4 -4
- package/dist/lib/helper/backError/backErrorsFilterBuilder.d.ts +12 -0
- package/dist/lib/helper/backError/backErrorsFilterBuilder.js +29 -0
- package/dist/lib/helper/console/logger.js +2 -2
- package/dist/lib/helper/definitions/optionTypes.d.ts +8 -0
- package/dist/lib/helper/definitions/optionTypes.js +7 -0
- package/dist/lib/helper/test/test.d.ts +2 -2
- package/dist/lib/helper/test/test.js +8 -6
- package/dist/lib/helper/timeout/timeoutAssert.js +2 -2
- package/dist/lib/helper/utils/actionUtils.d.ts +5 -18
- package/dist/lib/helper/utils/actionUtils.js +14 -43
- package/dist/lib/helper/utils/types.d.ts +20 -0
- package/dist/lib/helper/utils/types.js +7 -0
- package/package.json +8 -10
- package/dist/lib/api/before.d.ts +0 -3
- package/dist/lib/api/before.js +0 -20
- package/dist/lib/api/client.d.ts +0 -3
- package/dist/lib/api/client.js +0 -11
- package/dist/lib/api/describe.d.ts +0 -1
- package/dist/lib/api/describe.js +0 -6
- package/dist/lib/api/instanceManager.d.ts +0 -8
- package/dist/lib/api/instanceManager.js +0 -48
- package/dist/lib/api/testArea.d.ts +0 -3
- package/dist/lib/api/testArea.js +0 -41
- package/dist/lib/api/testServerManager.d.ts +0 -19
- package/dist/lib/api/testServerManager.js +0 -100
- package/dist/lib/helper/asserter/abstractClientAsserter.d.ts +0 -102
- package/dist/lib/helper/asserter/abstractClientAsserter.js +0 -293
- package/dist/lib/helper/asserter/anyAsserter.d.ts +0 -62
- package/dist/lib/helper/asserter/anyAsserter.js +0 -130
- package/dist/lib/helper/asserter/channelEventAsserter.d.ts +0 -34
- package/dist/lib/helper/asserter/channelEventAsserter.js +0 -84
- package/dist/lib/helper/asserter/channelPubAsserter.d.ts +0 -53
- package/dist/lib/helper/asserter/channelPubAsserter.js +0 -126
- package/dist/lib/helper/asserter/clientAsserter.d.ts +0 -13
- package/dist/lib/helper/asserter/clientAsserter.js +0 -26
- package/dist/lib/helper/asserter/controller/responseAsserter.d.ts +0 -76
- package/dist/lib/helper/asserter/controller/responseAsserter.js +0 -154
- package/dist/lib/helper/asserter/dataEventAsserter.d.ts +0 -40
- package/dist/lib/helper/asserter/dataEventAsserter.js +0 -113
- package/dist/lib/helper/asserter/event/abstractDataEventAsserter.d.ts +0 -13
- package/dist/lib/helper/asserter/event/abstractDataEventAsserter.js +0 -36
- package/dist/lib/helper/asserter/event/codeDataEventAsserter.d.ts +0 -14
- package/dist/lib/helper/asserter/event/codeDataEventAsserter.js +0 -40
- package/dist/lib/helper/asserter/eventAsserter.d.ts +0 -41
- package/dist/lib/helper/asserter/eventAsserter.js +0 -115
- package/dist/lib/helper/asserter/objectAsserter.d.ts +0 -55
- package/dist/lib/helper/asserter/objectAsserter.js +0 -113
- package/dist/lib/helper/asserter/receiver/transmitAsserter.d.ts +0 -9
- package/dist/lib/helper/asserter/responseAsserter.d.ts +0 -129
- package/dist/lib/helper/asserter/responseAsserter.js +0 -260
- package/dist/lib/helper/asserter/rootSendAsserter.d.ts +0 -89
- package/dist/lib/helper/asserter/standaloneClientAsserter.d.ts +0 -11
- package/dist/lib/helper/asserter/standaloneClientAsserter.js +0 -38
- package/dist/lib/helper/assured/clientAssured.d.ts +0 -2
- package/dist/lib/helper/assured/clientAssured.js +0 -11
- package/dist/lib/helper/assured/responseAssured.d.ts +0 -17
- package/dist/lib/helper/assured/responseAssured.js +0 -72
- package/dist/lib/helper/backError/backErrorFilterBuilder.d.ts +0 -13
- package/dist/lib/helper/backError/backErrorFilterBuilder.js +0 -35
- package/dist/lib/helper/builder/controller/abstractRequestBuilder.d.ts +0 -53
- package/dist/lib/helper/builder/controller/abstractRequestBuilder.js +0 -69
- package/dist/lib/helper/builder/controller/authRequestBuilder.d.ts +0 -15
- package/dist/lib/helper/builder/controller/authRequestBuilder.js +0 -30
- package/dist/lib/helper/builder/controller/standardRequestBuilder.d.ts +0 -15
- package/dist/lib/helper/builder/controller/standardRequestBuilder.js +0 -30
- package/dist/lib/helper/builder/controller/validationCheckRequestBuilder.d.ts +0 -21
- package/dist/lib/helper/builder/controller/validationCheckRequestBuilder.js +0 -40
- package/dist/lib/helper/builder/receiver/packageBuilder.d.ts +0 -45
- package/dist/lib/helper/builder/receiver/packageBuilder.js +0 -67
- package/dist/lib/helper/controller/request/abstractRequestBuilder.d.ts +0 -53
- package/dist/lib/helper/controller/request/abstractRequestBuilder.js +0 -68
- package/dist/lib/helper/controller/request/authRequestBuilder.d.ts +0 -15
- package/dist/lib/helper/controller/request/authRequestBuilder.js +0 -29
- package/dist/lib/helper/controller/request/standardRequestBuilder.d.ts +0 -15
- package/dist/lib/helper/controller/request/standardRequestBuilder.js +0 -29
- package/dist/lib/helper/controller/request/validationCheckRequestBuilder.d.ts +0 -21
- package/dist/lib/helper/controller/request/validationCheckRequestBuilder.js +0 -39
- package/dist/lib/helper/data/test.d.ts +0 -13
- package/dist/lib/helper/data/test.js +0 -89
- package/dist/lib/helper/do/actionUtils.d.ts +0 -24
- package/dist/lib/helper/do/actionUtils.js +0 -70
- package/dist/lib/helper/do/doUtils.d.ts +0 -24
- package/dist/lib/helper/do/doUtils.js +0 -80
- package/dist/lib/helper/error/backErrorFilterBuilder.d.ts +0 -13
- package/dist/lib/helper/error/backErrorFilterBuilder.js +0 -34
- package/dist/lib/helper/error/taskErrorFilterBuilder.d.ts +0 -13
- package/dist/lib/helper/error/taskErrorFilterBuilder.js +0 -34
- package/dist/lib/helper/request/abstractRequestBuilder.d.ts +0 -53
- package/dist/lib/helper/request/abstractRequestBuilder.js +0 -68
- package/dist/lib/helper/request/authRequestBuilder.d.ts +0 -15
- package/dist/lib/helper/request/authRequestBuilder.js +0 -29
- package/dist/lib/helper/request/requestBuilder.d.ts +0 -46
- package/dist/lib/helper/request/requestBuilder.js +0 -76
- package/dist/lib/helper/request/standardRequestBuilder.d.ts +0 -15
- package/dist/lib/helper/request/standardRequestBuilder.js +0 -29
- package/dist/lib/helper/request/validationCheckRequestBuilder.d.ts +0 -21
- package/dist/lib/helper/request/validationCheckRequestBuilder.js +0 -39
- package/dist/lib/helper/request/validationRequestBuilder.d.ts +0 -35
- package/dist/lib/helper/request/validationRequestBuilder.js +0 -61
- package/dist/lib/helper/utils/clientUtils.d.ts +0 -4
- package/dist/lib/helper/utils/clientUtils.js +0 -29
|
@@ -1,260 +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 zation_client_1 = require("zation-client");
|
|
18
|
-
const when_1 = require("../../api/when");
|
|
19
|
-
const logger_1 = require("../console/logger");
|
|
20
|
-
const anyAsserter_1 = require("./anyAsserter");
|
|
21
|
-
const backErrorFilterBuilder_1 = require("../backError/backErrorFilterBuilder");
|
|
22
|
-
const clientAsserter_1 = require("./clientAsserter");
|
|
23
|
-
const doUtils_1 = require("../do/doUtils");
|
|
24
|
-
const assert = require('assert');
|
|
25
|
-
class ResponseAsserter {
|
|
26
|
-
constructor(req, test, client) {
|
|
27
|
-
this.autoConnectedClient = false;
|
|
28
|
-
this._shouldThrowTimeoutError = false;
|
|
29
|
-
this._shouldThrowConnectionRequiredError = false;
|
|
30
|
-
this.req = req;
|
|
31
|
-
this._test = test;
|
|
32
|
-
this._client = client;
|
|
33
|
-
this._createTest();
|
|
34
|
-
}
|
|
35
|
-
_createTest() {
|
|
36
|
-
this._test.test(() => __awaiter(this, void 0, void 0, function* () {
|
|
37
|
-
if (!this._client.isConnected() && this.autoConnectedClient) {
|
|
38
|
-
yield this._client.connect();
|
|
39
|
-
}
|
|
40
|
-
try {
|
|
41
|
-
yield this.req.send(false);
|
|
42
|
-
if (this._shouldThrowTimeoutError) {
|
|
43
|
-
assert.fail('Send should throw a timeout error.');
|
|
44
|
-
}
|
|
45
|
-
if (this._shouldThrowConnectionRequiredError) {
|
|
46
|
-
assert.fail('Send should throw a connection required error.');
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
catch (e) {
|
|
50
|
-
if (e instanceof zation_client_1.TimeoutError) {
|
|
51
|
-
if (!this._shouldThrowTimeoutError) {
|
|
52
|
-
assert.fail('Send should not throw a timeout error.');
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
else if (e instanceof zation_client_1.ConnectionRequiredError) {
|
|
56
|
-
if (!this._shouldThrowConnectionRequiredError) {
|
|
57
|
-
assert.fail('Send should not throw a connection required error.');
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
else {
|
|
61
|
-
throw e;
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
}), true);
|
|
65
|
-
}
|
|
66
|
-
// noinspection JSMethodCanBeStatic
|
|
67
|
-
_respInfo(res) {
|
|
68
|
-
return '\n ' + res.toString();
|
|
69
|
-
}
|
|
70
|
-
// noinspection JSUnusedGlobalSymbols
|
|
71
|
-
/**
|
|
72
|
-
* @description
|
|
73
|
-
* Assert that send the request should throw a timeout error.
|
|
74
|
-
* @param value
|
|
75
|
-
*/
|
|
76
|
-
throwsTimeoutError(value = true) {
|
|
77
|
-
this._shouldThrowTimeoutError = value;
|
|
78
|
-
return this;
|
|
79
|
-
}
|
|
80
|
-
// noinspection JSUnusedGlobalSymbols
|
|
81
|
-
/**
|
|
82
|
-
* @description
|
|
83
|
-
* Assert that send the request should throw a connection required error.
|
|
84
|
-
* @param value
|
|
85
|
-
*/
|
|
86
|
-
throwsConnectionRequiredError(value = true) {
|
|
87
|
-
this._shouldThrowConnectionRequiredError = value;
|
|
88
|
-
return this;
|
|
89
|
-
}
|
|
90
|
-
// noinspection JSUnusedGlobalSymbols
|
|
91
|
-
/**
|
|
92
|
-
* @description
|
|
93
|
-
* Assert that the response is successful.
|
|
94
|
-
*/
|
|
95
|
-
isSuccessful() {
|
|
96
|
-
this.req.onResponse((res) => {
|
|
97
|
-
assert(res.isSuccessful(), 'Response should be successful.' + this._respInfo(res));
|
|
98
|
-
});
|
|
99
|
-
return this;
|
|
100
|
-
}
|
|
101
|
-
// noinspection JSUnusedGlobalSymbols
|
|
102
|
-
/**
|
|
103
|
-
* @description
|
|
104
|
-
* Assert that the response is not successful.
|
|
105
|
-
*/
|
|
106
|
-
isNotSuccessful() {
|
|
107
|
-
this.req.onResponse((res) => {
|
|
108
|
-
assert(!res.isSuccessful(), 'Response should be not successful.' + this._respInfo(res));
|
|
109
|
-
});
|
|
110
|
-
return this;
|
|
111
|
-
}
|
|
112
|
-
// noinspection JSUnusedGlobalSymbols
|
|
113
|
-
/**
|
|
114
|
-
* @description
|
|
115
|
-
* Assert that the response has a result.
|
|
116
|
-
*/
|
|
117
|
-
hasResult() {
|
|
118
|
-
this.req.onResponse((res) => {
|
|
119
|
-
assert(res.hasResult(), `Response should have a result.`
|
|
120
|
-
+ this._respInfo(res));
|
|
121
|
-
});
|
|
122
|
-
return this;
|
|
123
|
-
}
|
|
124
|
-
// noinspection JSUnusedGlobalSymbols
|
|
125
|
-
/**
|
|
126
|
-
* @description
|
|
127
|
-
* Assert the result of the response.
|
|
128
|
-
*/
|
|
129
|
-
assertResult() {
|
|
130
|
-
return new anyAsserter_1.AnyAsserter(this, 'Response Result', (test) => {
|
|
131
|
-
this.req.onResponse((res) => {
|
|
132
|
-
test(res.getResult());
|
|
133
|
-
});
|
|
134
|
-
});
|
|
135
|
-
}
|
|
136
|
-
// noinspection JSUnusedGlobalSymbols
|
|
137
|
-
/**
|
|
138
|
-
* @description
|
|
139
|
-
* Print the complete response to the console.
|
|
140
|
-
*/
|
|
141
|
-
print() {
|
|
142
|
-
this.req.onResponse((res) => {
|
|
143
|
-
logger_1.Logger.logInfo(res.toString());
|
|
144
|
-
});
|
|
145
|
-
return this;
|
|
146
|
-
}
|
|
147
|
-
// noinspection JSUnusedGlobalSymbols
|
|
148
|
-
/**
|
|
149
|
-
* @description
|
|
150
|
-
* Assert that the response has a specific count of errors.
|
|
151
|
-
* @param count
|
|
152
|
-
* count of errors
|
|
153
|
-
* @param filter
|
|
154
|
-
* Filter to filter for specific errors.
|
|
155
|
-
*/
|
|
156
|
-
hasErrorCount(count, ...filter) {
|
|
157
|
-
this.req.onResponse((res) => {
|
|
158
|
-
assert(ResponseAsserter._filterErrors(res, filter).length === count, `Response should have ${count} back errors.${filter.length === 0 ? '' : ` With filter: ${JSON.stringify(filter)}`}`
|
|
159
|
-
+ this._respInfo(res));
|
|
160
|
-
});
|
|
161
|
-
return this;
|
|
162
|
-
}
|
|
163
|
-
// noinspection JSUnusedGlobalSymbols
|
|
164
|
-
/**
|
|
165
|
-
* @description
|
|
166
|
-
* Assert that the response has count of specific errors
|
|
167
|
-
* with filter builder.
|
|
168
|
-
* @param count
|
|
169
|
-
* count of errors
|
|
170
|
-
*/
|
|
171
|
-
buildHasErrorCount(count) {
|
|
172
|
-
return new backErrorFilterBuilder_1.BackErrorFilterBuilder(this, count);
|
|
173
|
-
}
|
|
174
|
-
hasError(...filter) {
|
|
175
|
-
if (filter.length > 0) {
|
|
176
|
-
this.req.onResponse((res) => {
|
|
177
|
-
assert(ResponseAsserter._filterErrors(res, filter).length > 0, `Response should have an error.${filter.length === 0 ? '' : ` With filter: ${JSON.stringify(filter)}`}`
|
|
178
|
-
+ this._respInfo(res));
|
|
179
|
-
});
|
|
180
|
-
return this;
|
|
181
|
-
}
|
|
182
|
-
else
|
|
183
|
-
return new backErrorFilterBuilder_1.BackErrorFilterBuilder(this);
|
|
184
|
-
}
|
|
185
|
-
static _filterErrors(res, filter) {
|
|
186
|
-
return zation_client_1.ErrorFilterEngine.filterErrors(res.getErrors(false), filter);
|
|
187
|
-
}
|
|
188
|
-
// noinspection JSUnusedGlobalSymbols
|
|
189
|
-
/**
|
|
190
|
-
* @description
|
|
191
|
-
* With this function you can create custom assertions for a response.
|
|
192
|
-
* @param assert
|
|
193
|
-
* The assert function with params:
|
|
194
|
-
* -res The response
|
|
195
|
-
*/
|
|
196
|
-
assert(assert) {
|
|
197
|
-
this.req.onResponse((res) => __awaiter(this, void 0, void 0, function* () {
|
|
198
|
-
yield assert(res);
|
|
199
|
-
}));
|
|
200
|
-
return this;
|
|
201
|
-
}
|
|
202
|
-
// noinspection JSUnusedGlobalSymbols
|
|
203
|
-
/**
|
|
204
|
-
* @description
|
|
205
|
-
* With this function, you can do extra things in the test.
|
|
206
|
-
* Subscribe a channel, publish to a channel...
|
|
207
|
-
* @param func
|
|
208
|
-
* @param failMsg if not provided it throws the specific error.
|
|
209
|
-
*/
|
|
210
|
-
do(func, failMsg) {
|
|
211
|
-
doUtils_1.default.do(this._test, func, failMsg);
|
|
212
|
-
return this;
|
|
213
|
-
}
|
|
214
|
-
// noinspection JSUnusedGlobalSymbols
|
|
215
|
-
/**
|
|
216
|
-
* @description
|
|
217
|
-
* With this function, you can do extra things in the test
|
|
218
|
-
* and assert that it should throw an error or a specific error.
|
|
219
|
-
* Subscribe a channel, publish to a channel...
|
|
220
|
-
* @param func
|
|
221
|
-
* @param failMsg
|
|
222
|
-
* @param errors
|
|
223
|
-
*/
|
|
224
|
-
doShouldThrow(func, failMsg, ...errors) {
|
|
225
|
-
doUtils_1.default.doShouldThrow(this._test, func, failMsg, ...errors);
|
|
226
|
-
return this;
|
|
227
|
-
}
|
|
228
|
-
// noinspection JSUnusedGlobalSymbols
|
|
229
|
-
/**
|
|
230
|
-
* @description
|
|
231
|
-
* Start with a new request and link them to one test.
|
|
232
|
-
*/
|
|
233
|
-
and() {
|
|
234
|
-
this._test.newSubTest();
|
|
235
|
-
return new when_1.WhenBuilder(this._client, this._test);
|
|
236
|
-
}
|
|
237
|
-
// noinspection JSUnusedGlobalSymbols
|
|
238
|
-
/**
|
|
239
|
-
* @description
|
|
240
|
-
* Run the test.
|
|
241
|
-
* @param autoConnect
|
|
242
|
-
* Will auto connect the client
|
|
243
|
-
* if the client is not connected to the server.
|
|
244
|
-
*/
|
|
245
|
-
test(autoConnect = false) {
|
|
246
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
247
|
-
this.autoConnectedClient = autoConnect;
|
|
248
|
-
return this._test.execute();
|
|
249
|
-
});
|
|
250
|
-
}
|
|
251
|
-
// noinspection JSUnusedGlobalSymbols
|
|
252
|
-
/**
|
|
253
|
-
* @description
|
|
254
|
-
* Assert zation clients after request.
|
|
255
|
-
*/
|
|
256
|
-
client(...client) {
|
|
257
|
-
return new clientAsserter_1.ClientAsserter(client, this._test, this);
|
|
258
|
-
}
|
|
259
|
-
}
|
|
260
|
-
exports.ResponseAsserter = ResponseAsserter;
|
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
import { Channel, Databox, Client } from "zation-client";
|
|
2
|
-
import { Test } from "../test/test";
|
|
3
|
-
import { WhenBuilder } from "../../api/when";
|
|
4
|
-
import { ClientAsserter } from "./client/clientAsserter";
|
|
5
|
-
import { DataboxAsserter } from "./databox/databoxAsserter";
|
|
6
|
-
import { ChannelAsserter } from "./channel/channelAsserter";
|
|
7
|
-
export declare abstract class RootSendAsserter<T> {
|
|
8
|
-
protected readonly _test: Test;
|
|
9
|
-
protected readonly _client: Client;
|
|
10
|
-
private autoConnectedClient;
|
|
11
|
-
private _shouldThrowTimeoutError;
|
|
12
|
-
private _shouldThrowConnectionRequiredError;
|
|
13
|
-
protected constructor(test: Test, client: Client);
|
|
14
|
-
protected abstract _executeAction(): Promise<void>;
|
|
15
|
-
private _createTest;
|
|
16
|
-
/**
|
|
17
|
-
* @description
|
|
18
|
-
* Assert that send should throw a timeout error.
|
|
19
|
-
* @param value
|
|
20
|
-
*/
|
|
21
|
-
throwsTimeoutError(value?: boolean): T;
|
|
22
|
-
/**
|
|
23
|
-
* @description
|
|
24
|
-
* Assert that send should throw a connection required error.
|
|
25
|
-
* @param value
|
|
26
|
-
*/
|
|
27
|
-
throwsConnectionRequiredError(value?: boolean): T;
|
|
28
|
-
/**
|
|
29
|
-
* @description
|
|
30
|
-
* This function lets you do an extra action on the client and asserts that no error is thrown.
|
|
31
|
-
* When an error throws, it lets the test fail with the provided message or the concrete error.
|
|
32
|
-
* @param action
|
|
33
|
-
* @param message if not provided it throws the specific error.
|
|
34
|
-
*/
|
|
35
|
-
action(action: (client: Client) => void | Promise<void>, message?: string): T;
|
|
36
|
-
/**
|
|
37
|
-
* @description
|
|
38
|
-
* This function lets you do an extra action on the client and
|
|
39
|
-
* asserts that an error or an error instance of a specific class is thrown.
|
|
40
|
-
* When no error is thrown, or the error does not match with the given classes
|
|
41
|
-
* (only if at least one class is given), it lets the test fail with the provided message.
|
|
42
|
-
* @param action
|
|
43
|
-
* @param message
|
|
44
|
-
* @param validErrorClasses
|
|
45
|
-
*/
|
|
46
|
-
actionShouldThrow(action: (client: Client) => void | Promise<void>, message: string, ...validErrorClasses: any[]): T;
|
|
47
|
-
/**
|
|
48
|
-
* @description
|
|
49
|
-
* Start with a new when and link them to one test.
|
|
50
|
-
*/
|
|
51
|
-
and(): WhenBuilder;
|
|
52
|
-
/**
|
|
53
|
-
* @description
|
|
54
|
-
* Assert client.
|
|
55
|
-
*/
|
|
56
|
-
client(): ClientAsserter<T>;
|
|
57
|
-
/**
|
|
58
|
-
* @description
|
|
59
|
-
* Assert other clients.
|
|
60
|
-
* Notice that this method will not automatically connect the clients.
|
|
61
|
-
*/
|
|
62
|
-
otherClients(...clients: Client[]): ClientAsserter<T>;
|
|
63
|
-
/**
|
|
64
|
-
* @description
|
|
65
|
-
* Assert other databoxes.
|
|
66
|
-
* Notice that this method will not automatically connect the databoxes.
|
|
67
|
-
*/
|
|
68
|
-
otherDataboxes(...databoxes: Databox[]): DataboxAsserter<T>;
|
|
69
|
-
/**
|
|
70
|
-
* @description
|
|
71
|
-
* Assert other channels.
|
|
72
|
-
* Notice that this method will not automatically subscribe to the channels.
|
|
73
|
-
*/
|
|
74
|
-
otherChannels(...channels: Channel[]): ChannelAsserter<T>;
|
|
75
|
-
/**
|
|
76
|
-
* @description
|
|
77
|
-
* Runs the test.
|
|
78
|
-
* @param autoConnect
|
|
79
|
-
* Will auto connect the client
|
|
80
|
-
* if the client is not connected to the server.
|
|
81
|
-
*/
|
|
82
|
-
test(autoConnect?: boolean): Promise<void>;
|
|
83
|
-
/**
|
|
84
|
-
* @description
|
|
85
|
-
* Returns self.
|
|
86
|
-
* For fluent programing with inheritance.
|
|
87
|
-
*/
|
|
88
|
-
protected abstract self(): T;
|
|
89
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { ZationClient } from 'zation-client';
|
|
2
|
-
import { AbstractClientAsserter } from "./abstractClientAsserter";
|
|
3
|
-
export declare class StandaloneClientAsserter extends AbstractClientAsserter<StandaloneClientAsserter> {
|
|
4
|
-
constructor(client: ZationClient | ZationClient[], itTestDescription?: string);
|
|
5
|
-
/**
|
|
6
|
-
* @description
|
|
7
|
-
* Run the test.
|
|
8
|
-
*/
|
|
9
|
-
test(): Promise<void>;
|
|
10
|
-
protected self(): StandaloneClientAsserter;
|
|
11
|
-
}
|
|
@@ -1,38 +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 abstractClientAsserter_1 = require("./abstractClientAsserter");
|
|
18
|
-
const test_1 = require("../test/test");
|
|
19
|
-
class StandaloneClientAsserter extends abstractClientAsserter_1.AbstractClientAsserter {
|
|
20
|
-
constructor(client, itTestDescription) {
|
|
21
|
-
let clients = Array.isArray(client) ? client : [client];
|
|
22
|
-
super(clients, new test_1.Test(itTestDescription));
|
|
23
|
-
}
|
|
24
|
-
// noinspection JSUnusedGlobalSymbols
|
|
25
|
-
/**
|
|
26
|
-
* @description
|
|
27
|
-
* Run the test.
|
|
28
|
-
*/
|
|
29
|
-
test() {
|
|
30
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
31
|
-
return this._test.execute();
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
self() {
|
|
35
|
-
return this;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
exports.StandaloneClientAsserter = StandaloneClientAsserter;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*
|
|
3
|
-
Author: Luca Scaringella
|
|
4
|
-
GitHub: LucaCode
|
|
5
|
-
©Copyright by Luca Scaringella
|
|
6
|
-
*/
|
|
7
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
-
const assert = require('assert');
|
|
9
|
-
class ClientAssured {
|
|
10
|
-
}
|
|
11
|
-
exports.ClientAssured = ClientAssured;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { AbstractRequestHelper, Zation as ZationClient } from "zation-client";
|
|
2
|
-
import { Test } from "../data/test";
|
|
3
|
-
import { WhenBuilder } from "../../api/when";
|
|
4
|
-
export declare class ResponseAssured {
|
|
5
|
-
private req;
|
|
6
|
-
private readonly _test;
|
|
7
|
-
private readonly client;
|
|
8
|
-
constructor(req: AbstractRequestHelper<any>, test: Test, client: ZationClient);
|
|
9
|
-
private _respInfo;
|
|
10
|
-
isSuccessful(): ResponseAssured;
|
|
11
|
-
notSuccessful(): ResponseAssured;
|
|
12
|
-
hasError(): ResponseAssured;
|
|
13
|
-
print(): ResponseAssured;
|
|
14
|
-
hasErrorCount(count: number): ResponseAssured;
|
|
15
|
-
and(): WhenBuilder;
|
|
16
|
-
test(autoConnect?: boolean): void;
|
|
17
|
-
}
|
|
@@ -1,72 +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
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
9
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
10
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
11
|
-
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
|
12
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
13
|
-
});
|
|
14
|
-
};
|
|
15
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
-
const when_1 = require("../../api/when");
|
|
17
|
-
const logger_1 = require("../console/logger");
|
|
18
|
-
const assert = require('assert');
|
|
19
|
-
class ResponseAssured {
|
|
20
|
-
constructor(req, test, client) {
|
|
21
|
-
this.req = req;
|
|
22
|
-
this._test = test;
|
|
23
|
-
this.client = client;
|
|
24
|
-
}
|
|
25
|
-
// noinspection JSMethodCanBeStatic
|
|
26
|
-
_respInfo(res) {
|
|
27
|
-
return '\n ' + res.toString();
|
|
28
|
-
}
|
|
29
|
-
isSuccessful() {
|
|
30
|
-
this.req.onResponse((res) => {
|
|
31
|
-
assert(res.isSuccessful(), 'Response should be successful.' + this._respInfo(res));
|
|
32
|
-
});
|
|
33
|
-
return this;
|
|
34
|
-
}
|
|
35
|
-
notSuccessful() {
|
|
36
|
-
this.req.onResponse((res) => {
|
|
37
|
-
assert(!res.isSuccessful(), 'Response should be not successful.' + this._respInfo(res));
|
|
38
|
-
});
|
|
39
|
-
return this;
|
|
40
|
-
}
|
|
41
|
-
hasError() {
|
|
42
|
-
this.req.onResponse((res) => {
|
|
43
|
-
assert(res.hasErrors(false), 'Response should have at least one error.' + this._respInfo(res));
|
|
44
|
-
});
|
|
45
|
-
return this;
|
|
46
|
-
}
|
|
47
|
-
print() {
|
|
48
|
-
this.req.onResponse((res) => {
|
|
49
|
-
logger_1.Logger.logInfo(res.toString());
|
|
50
|
-
});
|
|
51
|
-
return this;
|
|
52
|
-
}
|
|
53
|
-
hasErrorCount(count) {
|
|
54
|
-
this.req.onResponse((res) => {
|
|
55
|
-
assert(res.getErrors(false).length === count, `Response should have ${count} errors.` + this._respInfo(res));
|
|
56
|
-
});
|
|
57
|
-
return this;
|
|
58
|
-
}
|
|
59
|
-
and() {
|
|
60
|
-
return new when_1.WhenBuilder(this.client, this._test);
|
|
61
|
-
}
|
|
62
|
-
test(autoConnect = true) {
|
|
63
|
-
this._test.test(() => __awaiter(this, void 0, void 0, function* () {
|
|
64
|
-
if (!this.client.isConnected() && autoConnect) {
|
|
65
|
-
yield this.client.connect();
|
|
66
|
-
}
|
|
67
|
-
yield this.req.send(false);
|
|
68
|
-
}));
|
|
69
|
-
this._test.execute();
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
exports.ResponseAssured = ResponseAssured;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { AbstractBackErrorFilterBuilder } from "zation-client";
|
|
2
|
-
import { ResponseAsserter } from "../asserter/controller/responseAsserter";
|
|
3
|
-
export declare class BackErrorFilterBuilder<T extends ResponseAsserter> extends AbstractBackErrorFilterBuilder<BackErrorFilterBuilder<T>> {
|
|
4
|
-
private readonly respAsserter;
|
|
5
|
-
private readonly count;
|
|
6
|
-
constructor(respAsserter: T, count?: number);
|
|
7
|
-
/**
|
|
8
|
-
* @description
|
|
9
|
-
* End the filter builder.
|
|
10
|
-
*/
|
|
11
|
-
end(): T;
|
|
12
|
-
protected self(): BackErrorFilterBuilder<T>;
|
|
13
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*
|
|
3
|
-
Author: Luca Scaringella
|
|
4
|
-
GitHub: LucaCode
|
|
5
|
-
©Copyright by Luca Scaringella
|
|
6
|
-
*/
|
|
7
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
-
exports.BackErrorFilterBuilder = void 0;
|
|
9
|
-
const zation_client_1 = require("zation-client");
|
|
10
|
-
class BackErrorFilterBuilder extends zation_client_1.AbstractBackErrorFilterBuilder {
|
|
11
|
-
constructor(respAsserter, count) {
|
|
12
|
-
super();
|
|
13
|
-
this.respAsserter = respAsserter;
|
|
14
|
-
this.count = count;
|
|
15
|
-
}
|
|
16
|
-
// noinspection JSUnusedGlobalSymbols
|
|
17
|
-
/**
|
|
18
|
-
* @description
|
|
19
|
-
* End the filter builder.
|
|
20
|
-
*/
|
|
21
|
-
end() {
|
|
22
|
-
this._pushTmpFilter();
|
|
23
|
-
if (this.count) {
|
|
24
|
-
this.respAsserter.hasErrorCount(this.count, ...this.filter);
|
|
25
|
-
}
|
|
26
|
-
else {
|
|
27
|
-
this.respAsserter.hasError(...this.filter);
|
|
28
|
-
}
|
|
29
|
-
return this.respAsserter;
|
|
30
|
-
}
|
|
31
|
-
self() {
|
|
32
|
-
return this;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
exports.BackErrorFilterBuilder = BackErrorFilterBuilder;
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { AbstractRequestBuilder as NativeAbstractRequestBuilder, Client } from "zation-client";
|
|
2
|
-
import { Test } from "../../test/test";
|
|
3
|
-
import { ResponseAsserter } from "../../asserter/controller/responseAsserter";
|
|
4
|
-
import { ConnectTimeoutOption } from "zation-client/dist/lib/main/utils/connectionUtils";
|
|
5
|
-
export declare abstract class AbstractRequestBuilder<T, RT> {
|
|
6
|
-
private readonly test;
|
|
7
|
-
private readonly client;
|
|
8
|
-
private readonly nativeBuilder;
|
|
9
|
-
protected constructor(test: Test, client: Client, nativeBuilder: NativeAbstractRequestBuilder<any>);
|
|
10
|
-
/**
|
|
11
|
-
* @description
|
|
12
|
-
* Set the apiLevel of the request.
|
|
13
|
-
* @param apiLevel.
|
|
14
|
-
* @default undefined.
|
|
15
|
-
*/
|
|
16
|
-
apiLevel(apiLevel: number | undefined): T;
|
|
17
|
-
/**
|
|
18
|
-
* @description
|
|
19
|
-
* Set the timeout for the response of the request.
|
|
20
|
-
* Value can be null which means the timeout is disabled or
|
|
21
|
-
* undefined then it will use the default timeout of the client config,
|
|
22
|
-
* or it can be a number that indicates the milliseconds.
|
|
23
|
-
* @param timeout
|
|
24
|
-
*/
|
|
25
|
-
responseTimeout(timeout: null | undefined | number): T;
|
|
26
|
-
/**
|
|
27
|
-
* With the ConnectTimeout option, you can activate that the socket is
|
|
28
|
-
* trying to connect when it is not connected. You have five possible choices:
|
|
29
|
-
* Undefined: It will use the value from the default options.
|
|
30
|
-
* False: The action will fail and throw a ConnectionRequiredError,
|
|
31
|
-
* when the socket is not connected.
|
|
32
|
-
* Null: The socket will try to connect (if it is not connected) and
|
|
33
|
-
* waits until the connection is made, then it continues the action.
|
|
34
|
-
* Number: Same as null, but now you can specify a timeout (in ms) of
|
|
35
|
-
* maximum waiting time for the connection. If the timeout is reached,
|
|
36
|
-
* it will throw a timeout error.
|
|
37
|
-
* AbortTrigger: Same as null, but now you have the possibility to abort the wait later.
|
|
38
|
-
* @param timeout
|
|
39
|
-
* @default undefined
|
|
40
|
-
*/
|
|
41
|
-
connectTimeout(timeout: ConnectTimeoutOption): T;
|
|
42
|
-
/**
|
|
43
|
-
* @description
|
|
44
|
-
* Start the assertions.
|
|
45
|
-
*/
|
|
46
|
-
assertThat(): ResponseAsserter;
|
|
47
|
-
/**
|
|
48
|
-
* @description
|
|
49
|
-
* Returns self.
|
|
50
|
-
* For fluent programing with inheritance.
|
|
51
|
-
*/
|
|
52
|
-
protected abstract self(): T;
|
|
53
|
-
}
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*
|
|
3
|
-
Author: Luca Scaringella
|
|
4
|
-
GitHub: LucaCode
|
|
5
|
-
©Copyright by Luca Scaringella
|
|
6
|
-
*/
|
|
7
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
-
exports.AbstractRequestBuilder = void 0;
|
|
9
|
-
const responseAsserter_1 = require("../../asserter/controller/responseAsserter");
|
|
10
|
-
class AbstractRequestBuilder {
|
|
11
|
-
constructor(test, client, nativeBuilder) {
|
|
12
|
-
this.test = test;
|
|
13
|
-
this.client = client;
|
|
14
|
-
this.nativeBuilder = nativeBuilder;
|
|
15
|
-
}
|
|
16
|
-
// noinspection JSUnusedGlobalSymbols
|
|
17
|
-
/**
|
|
18
|
-
* @description
|
|
19
|
-
* Set the apiLevel of the request.
|
|
20
|
-
* @param apiLevel.
|
|
21
|
-
* @default undefined.
|
|
22
|
-
*/
|
|
23
|
-
apiLevel(apiLevel) {
|
|
24
|
-
this.nativeBuilder.apiLevel(apiLevel);
|
|
25
|
-
return this.self();
|
|
26
|
-
}
|
|
27
|
-
// noinspection JSUnusedGlobalSymbols
|
|
28
|
-
/**
|
|
29
|
-
* @description
|
|
30
|
-
* Set the timeout for the response of the request.
|
|
31
|
-
* Value can be null which means the timeout is disabled or
|
|
32
|
-
* undefined then it will use the default timeout of the client config,
|
|
33
|
-
* or it can be a number that indicates the milliseconds.
|
|
34
|
-
* @param timeout
|
|
35
|
-
*/
|
|
36
|
-
responseTimeout(timeout) {
|
|
37
|
-
this.nativeBuilder.responseTimeout(timeout);
|
|
38
|
-
return this.self();
|
|
39
|
-
}
|
|
40
|
-
// noinspection JSUnusedGlobalSymbols
|
|
41
|
-
/**
|
|
42
|
-
* With the ConnectTimeout option, you can activate that the socket is
|
|
43
|
-
* trying to connect when it is not connected. You have five possible choices:
|
|
44
|
-
* Undefined: It will use the value from the default options.
|
|
45
|
-
* False: The action will fail and throw a ConnectionRequiredError,
|
|
46
|
-
* when the socket is not connected.
|
|
47
|
-
* Null: The socket will try to connect (if it is not connected) and
|
|
48
|
-
* waits until the connection is made, then it continues the action.
|
|
49
|
-
* Number: Same as null, but now you can specify a timeout (in ms) of
|
|
50
|
-
* maximum waiting time for the connection. If the timeout is reached,
|
|
51
|
-
* it will throw a timeout error.
|
|
52
|
-
* AbortTrigger: Same as null, but now you have the possibility to abort the wait later.
|
|
53
|
-
* @param timeout
|
|
54
|
-
* @default undefined
|
|
55
|
-
*/
|
|
56
|
-
connectTimeout(timeout) {
|
|
57
|
-
this.nativeBuilder.connectTimeout(timeout);
|
|
58
|
-
return this.self();
|
|
59
|
-
}
|
|
60
|
-
// noinspection JSUnusedGlobalSymbols
|
|
61
|
-
/**
|
|
62
|
-
* @description
|
|
63
|
-
* Start the assertions.
|
|
64
|
-
*/
|
|
65
|
-
assertThat() {
|
|
66
|
-
return new responseAsserter_1.ResponseAsserter(this.nativeBuilder, this.test, this.client);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
exports.AbstractRequestBuilder = AbstractRequestBuilder;
|