zation-assured 0.6.0 → 3.0.0-dev.2
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 +21 -14
- package/dist/lib/api/assert.js +17 -13
- 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 +20 -29
- package/dist/lib/helper/asserter/channel/abstractChannelAsserter.js +44 -85
- 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 +20 -38
- package/dist/lib/helper/asserter/client/abstractClientAsserter.js +82 -184
- 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 +29 -36
- package/dist/lib/helper/asserter/databox/abstractDataboxAsserter.js +44 -80
- 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 +13 -15
- package/dist/lib/helper/asserter/value/abstractValueAsserter.js +49 -53
- 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 -74
- package/dist/lib/helper/asserter/controller/responseAsserter.js +0 -138
- 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 -32
- 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
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
Author: Ing. Luca Gian Scaringella
|
|
4
|
+
GitHub: LucaCode
|
|
5
|
+
Copyright(c) Ing. Luca Gian 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
|
+
exports.IntegratedResponseAsserter = void 0;
|
|
18
|
+
const valueAsserter_1 = require("../value/valueAsserter");
|
|
19
|
+
const backErrorsFilterBuilder_1 = require("../../backError/backErrorsFilterBuilder");
|
|
20
|
+
const abstractActionAsserter_1 = require("../abstractActionAsserter");
|
|
21
|
+
const assert = require('assert');
|
|
22
|
+
class IntegratedResponseAsserter extends abstractActionAsserter_1.AbstractActionAsserter {
|
|
23
|
+
constructor(sendRequest, test, client) {
|
|
24
|
+
super(test, client);
|
|
25
|
+
this.sendRequest = sendRequest;
|
|
26
|
+
this.responseAsserters = [];
|
|
27
|
+
}
|
|
28
|
+
_executeAction() {
|
|
29
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
30
|
+
const resp = yield this.sendRequest();
|
|
31
|
+
for (let i = 0; i < this.responseAsserters.length; i++)
|
|
32
|
+
yield this.responseAsserters[i](resp);
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
// noinspection JSMethodCanBeStatic
|
|
36
|
+
_respInfo(res) {
|
|
37
|
+
return '\n ' + res.toString();
|
|
38
|
+
}
|
|
39
|
+
// noinspection JSUnusedGlobalSymbols
|
|
40
|
+
/**
|
|
41
|
+
* @description
|
|
42
|
+
* Asserts that the response is successful.
|
|
43
|
+
*/
|
|
44
|
+
isSuccessful() {
|
|
45
|
+
this.responseAsserters.push(resp => {
|
|
46
|
+
assert(resp.successful, 'Response should be successful.' + this._respInfo(resp));
|
|
47
|
+
});
|
|
48
|
+
return this;
|
|
49
|
+
}
|
|
50
|
+
// noinspection JSUnusedGlobalSymbols
|
|
51
|
+
/**
|
|
52
|
+
* @description
|
|
53
|
+
* Asserts that the response is not successful.
|
|
54
|
+
*/
|
|
55
|
+
isNotSuccessful() {
|
|
56
|
+
this.responseAsserters.push(resp => {
|
|
57
|
+
assert(!resp.successful, 'Response should be not successful.' + this._respInfo(resp));
|
|
58
|
+
});
|
|
59
|
+
return this;
|
|
60
|
+
}
|
|
61
|
+
// noinspection JSUnusedGlobalSymbols
|
|
62
|
+
/**
|
|
63
|
+
* @description
|
|
64
|
+
* Asserts that the response has a result.
|
|
65
|
+
*/
|
|
66
|
+
hasResult() {
|
|
67
|
+
this.responseAsserters.push(resp => {
|
|
68
|
+
assert(resp.result != null, `Response should have a result.`
|
|
69
|
+
+ this._respInfo(resp));
|
|
70
|
+
});
|
|
71
|
+
return this;
|
|
72
|
+
}
|
|
73
|
+
// noinspection JSUnusedGlobalSymbols
|
|
74
|
+
/**
|
|
75
|
+
* @description
|
|
76
|
+
* Asserts the result of the response.
|
|
77
|
+
*/
|
|
78
|
+
result() {
|
|
79
|
+
return new valueAsserter_1.ValueAsserter(this, (test) => {
|
|
80
|
+
this.responseAsserters.push(resp => {
|
|
81
|
+
test(resp.result, 'response data');
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
hasError(filter) {
|
|
86
|
+
if (filter !== undefined) {
|
|
87
|
+
this.responseAsserters.push((resp) => {
|
|
88
|
+
assert(resp.filter(filter).length > 0, `Response should have at least one back error that matches the filter: ${JSON.stringify(filter)}.`
|
|
89
|
+
+ this._respInfo(resp));
|
|
90
|
+
});
|
|
91
|
+
return this;
|
|
92
|
+
}
|
|
93
|
+
else
|
|
94
|
+
return new backErrorsFilterBuilder_1.BackErrorsFilterBuilder(this, (filter) => {
|
|
95
|
+
this.hasError(filter);
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
// noinspection JSUnusedGlobalSymbols
|
|
99
|
+
/**
|
|
100
|
+
* @description
|
|
101
|
+
* Creates a custom assertion.
|
|
102
|
+
* @param assert
|
|
103
|
+
*/
|
|
104
|
+
assert(assert) {
|
|
105
|
+
this.responseAsserters.push(resp => assert(resp));
|
|
106
|
+
return this;
|
|
107
|
+
}
|
|
108
|
+
self() {
|
|
109
|
+
return this;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
exports.IntegratedResponseAsserter = IntegratedResponseAsserter;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { BackErrorFilter, Response } from "zation-client";
|
|
2
|
+
import { ValueAsserter } from "../value/valueAsserter";
|
|
3
|
+
import { BackErrorsFilterBuilder } from "../../backError/backErrorsFilterBuilder";
|
|
4
|
+
import { ResponseData } from "../../utils/types";
|
|
5
|
+
export default class StandaloneResponseAsserter<R extends Response<any>> {
|
|
6
|
+
private readonly test;
|
|
7
|
+
private readonly responses;
|
|
8
|
+
constructor(response: R | R[], description?: string);
|
|
9
|
+
protected _forEachResponse(func: (response: R, i: number) => Promise<void> | void): Promise<void>;
|
|
10
|
+
private _respInfo;
|
|
11
|
+
/**
|
|
12
|
+
* @description
|
|
13
|
+
* Asserts that the response is successful.
|
|
14
|
+
*/
|
|
15
|
+
isSuccessful(): StandaloneResponseAsserter<R>;
|
|
16
|
+
/**
|
|
17
|
+
* @description
|
|
18
|
+
* Asserts that the response is not successful.
|
|
19
|
+
*/
|
|
20
|
+
isNotSuccessful(): StandaloneResponseAsserter<R>;
|
|
21
|
+
/**
|
|
22
|
+
* @description
|
|
23
|
+
* Asserts that the response has a result.
|
|
24
|
+
*/
|
|
25
|
+
hasResult(): StandaloneResponseAsserter<R>;
|
|
26
|
+
/**
|
|
27
|
+
* @description
|
|
28
|
+
* Asserts the result of the response.
|
|
29
|
+
*/
|
|
30
|
+
result(): ValueAsserter<ResponseData<R>, StandaloneResponseAsserter<R>>;
|
|
31
|
+
/**
|
|
32
|
+
* @description
|
|
33
|
+
* Asserts that the response has specific errors with a BackErrorFilterBuilder.
|
|
34
|
+
*/
|
|
35
|
+
hasError(): BackErrorsFilterBuilder<StandaloneResponseAsserter<R>>;
|
|
36
|
+
/**
|
|
37
|
+
* @description
|
|
38
|
+
* Asserts that the response has specific errors with a raw filter.
|
|
39
|
+
* @param filter
|
|
40
|
+
* Queric filter to filter for specific errors.
|
|
41
|
+
*/
|
|
42
|
+
hasError(filter: BackErrorFilter): StandaloneResponseAsserter<R>;
|
|
43
|
+
/**
|
|
44
|
+
* @description
|
|
45
|
+
* Creates a custom assertion.
|
|
46
|
+
* @param assert
|
|
47
|
+
*/
|
|
48
|
+
assert(assert: (resp: R) => void | Promise<void>): StandaloneResponseAsserter<R>;
|
|
49
|
+
}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
Author: Ing. Luca Gian Scaringella
|
|
4
|
+
GitHub: LucaCode
|
|
5
|
+
Copyright(c) Ing. Luca Gian 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 test_1 = require("../../test/test");
|
|
18
|
+
const valueAsserter_1 = require("../value/valueAsserter");
|
|
19
|
+
const backErrorsFilterBuilder_1 = require("../../backError/backErrorsFilterBuilder");
|
|
20
|
+
const assert = require('assert');
|
|
21
|
+
class StandaloneResponseAsserter {
|
|
22
|
+
constructor(response, description) {
|
|
23
|
+
this.test = new test_1.Test(description);
|
|
24
|
+
this.responses = Array.isArray(response) ? response : [response];
|
|
25
|
+
}
|
|
26
|
+
_forEachResponse(func) {
|
|
27
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
28
|
+
yield Promise.all(this.responses
|
|
29
|
+
.map((resp, i) => func(resp, i)));
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
// noinspection JSMethodCanBeStatic
|
|
33
|
+
_respInfo(res) {
|
|
34
|
+
return '\n ' + res.toString();
|
|
35
|
+
}
|
|
36
|
+
// noinspection JSUnusedGlobalSymbols
|
|
37
|
+
/**
|
|
38
|
+
* @description
|
|
39
|
+
* Asserts that the response is successful.
|
|
40
|
+
*/
|
|
41
|
+
isSuccessful() {
|
|
42
|
+
this.test.test(() => this._forEachResponse((resp, i) => __awaiter(this, void 0, void 0, function* () {
|
|
43
|
+
assert(resp.successful, `Response: ${i} should be successful.` + this._respInfo(resp));
|
|
44
|
+
})));
|
|
45
|
+
return this;
|
|
46
|
+
}
|
|
47
|
+
// noinspection JSUnusedGlobalSymbols
|
|
48
|
+
/**
|
|
49
|
+
* @description
|
|
50
|
+
* Asserts that the response is not successful.
|
|
51
|
+
*/
|
|
52
|
+
isNotSuccessful() {
|
|
53
|
+
this.test.test(() => this._forEachResponse((resp, i) => __awaiter(this, void 0, void 0, function* () {
|
|
54
|
+
assert(!resp.successful, `Response: ${i} should be not successful.` + this._respInfo(resp));
|
|
55
|
+
})));
|
|
56
|
+
return this;
|
|
57
|
+
}
|
|
58
|
+
// noinspection JSUnusedGlobalSymbols
|
|
59
|
+
/**
|
|
60
|
+
* @description
|
|
61
|
+
* Asserts that the response has a result.
|
|
62
|
+
*/
|
|
63
|
+
hasResult() {
|
|
64
|
+
this.test.test(() => this._forEachResponse((resp, i) => __awaiter(this, void 0, void 0, function* () {
|
|
65
|
+
assert(resp.result != null, `Response: ${i} should have a result.`
|
|
66
|
+
+ this._respInfo(resp));
|
|
67
|
+
})));
|
|
68
|
+
return this;
|
|
69
|
+
}
|
|
70
|
+
// noinspection JSUnusedGlobalSymbols
|
|
71
|
+
/**
|
|
72
|
+
* @description
|
|
73
|
+
* Asserts the result of the response.
|
|
74
|
+
*/
|
|
75
|
+
result() {
|
|
76
|
+
return new valueAsserter_1.ValueAsserter(this, (test) => {
|
|
77
|
+
this.test.test(() => this._forEachResponse((resp, i) => __awaiter(this, void 0, void 0, function* () {
|
|
78
|
+
test(resp.result, `response: ${i} result`);
|
|
79
|
+
})));
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
hasError(filter) {
|
|
83
|
+
if (filter !== undefined) {
|
|
84
|
+
this.test.test(() => this._forEachResponse((resp, i) => __awaiter(this, void 0, void 0, function* () {
|
|
85
|
+
assert(resp.filter(filter).length > 0, `Response: ${i} should have at least one back error that matches the filter: ${JSON.stringify(filter)}.`
|
|
86
|
+
+ this._respInfo(resp));
|
|
87
|
+
})));
|
|
88
|
+
return this;
|
|
89
|
+
}
|
|
90
|
+
else
|
|
91
|
+
return new backErrorsFilterBuilder_1.BackErrorsFilterBuilder(this, (filter) => {
|
|
92
|
+
this.hasError(filter);
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
// noinspection JSUnusedGlobalSymbols
|
|
96
|
+
/**
|
|
97
|
+
* @description
|
|
98
|
+
* Creates a custom assertion.
|
|
99
|
+
* @param assert
|
|
100
|
+
*/
|
|
101
|
+
assert(assert) {
|
|
102
|
+
this.test.test(() => this._forEachResponse((resp) => __awaiter(this, void 0, void 0, function* () {
|
|
103
|
+
yield assert(resp);
|
|
104
|
+
})));
|
|
105
|
+
return this;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
exports.default = StandaloneResponseAsserter;
|
|
@@ -1,79 +1,72 @@
|
|
|
1
1
|
import { Test } from "../../test/test";
|
|
2
|
-
import { Databox, DataEventReason } from 'zation-client';
|
|
2
|
+
import { Databox, DataEventReason, DbStorage } from 'zation-client';
|
|
3
3
|
import { DataEventAsserter } from "../event/dataEventAsserter";
|
|
4
4
|
import { ValueAsserter } from "../value/valueAsserter";
|
|
5
|
-
import {
|
|
6
|
-
|
|
5
|
+
import { CodeMetadataEventAsserter } from "../event/codeMetadataEventAsserter";
|
|
6
|
+
import { Query } from "queric";
|
|
7
|
+
import { DataboxData, DataboxFetchData, DataboxMember } from "../../utils/types";
|
|
8
|
+
import { DeepReadonly } from "../../utils/types";
|
|
9
|
+
export declare abstract class AbstractDataboxAsserter<T, D extends Databox<any, any, any, any>> {
|
|
7
10
|
protected _test: Test;
|
|
8
|
-
protected databoxes:
|
|
11
|
+
protected databoxes: D[];
|
|
9
12
|
protected abstract self(): T;
|
|
10
|
-
protected constructor(databoxes:
|
|
11
|
-
protected _forEachDatabox(func: (databox:
|
|
13
|
+
protected constructor(databoxes: D[], test: Test);
|
|
14
|
+
protected _forEachDatabox(func: (databox: D, i: number) => Promise<void> | void): Promise<void>;
|
|
12
15
|
/**
|
|
13
16
|
* @description
|
|
14
17
|
* Asserts that the databox is connected.
|
|
15
18
|
* @param timeout
|
|
16
|
-
*
|
|
19
|
+
* Sets a time limit in that the assertion must be successful.
|
|
17
20
|
*/
|
|
18
21
|
isConnected(timeout?: number): T;
|
|
19
22
|
/**
|
|
20
23
|
* @description
|
|
21
24
|
* Asserts that the databox is disconnected.
|
|
22
25
|
* @param timeout
|
|
23
|
-
*
|
|
26
|
+
* Sets a time limit in that the assertion must be successful.
|
|
24
27
|
*/
|
|
25
28
|
isDisconnected(timeout?: number): T;
|
|
26
29
|
/**
|
|
27
30
|
* Asserts the current data of the databox.
|
|
28
31
|
*/
|
|
29
|
-
data(): ValueAsserter<T>;
|
|
32
|
+
data(): ValueAsserter<DeepReadonly<DataboxData<D>>, T>;
|
|
30
33
|
/**
|
|
31
34
|
* Asserts the current member of the databox.
|
|
32
35
|
*/
|
|
33
|
-
member(): ValueAsserter<T>;
|
|
36
|
+
member(): ValueAsserter<DataboxMember<D>, T>;
|
|
34
37
|
/**
|
|
35
38
|
* Fetches data multiple times on each databox.
|
|
36
39
|
*/
|
|
37
|
-
fetch(times?: number, fetchData?:
|
|
40
|
+
fetch(times?: number, fetchData?: DataboxFetchData<D>): T;
|
|
38
41
|
/**
|
|
39
42
|
* @description
|
|
40
|
-
*
|
|
41
|
-
*
|
|
43
|
+
* Runs a extra test action and asserts that no error will be thrown.
|
|
44
|
+
* AssertionErrors will be rethrown, and all other errors will fail
|
|
45
|
+
* the test with the provided message or the concrete error.
|
|
42
46
|
* @param action
|
|
43
|
-
* @param
|
|
47
|
+
* @param failMsg If not provided, the concrete error is used.
|
|
44
48
|
*/
|
|
45
|
-
action(action: (databox:
|
|
49
|
+
action(action: (databox: D, index: number) => void | Promise<void>, failMsg?: string): T;
|
|
46
50
|
/**
|
|
47
51
|
* @description
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
* When no error is thrown, or the error does not match with the given classes
|
|
51
|
-
* (only if at least one class is given), it lets the test fail with the provided message.
|
|
52
|
-
* @param action
|
|
53
|
-
* @param message
|
|
54
|
-
* @param validErrorClasses
|
|
55
|
-
*/
|
|
56
|
-
actionShouldThrow(action: (databox: Databox, index: number) => void | Promise<void>, message: string, ...validErrorClasses: any[]): T;
|
|
57
|
-
/**
|
|
58
|
-
* @description
|
|
59
|
-
* Asserts that the databox should trigger an DataChange event.
|
|
60
|
-
* It is also possible to assert only in case of specific data event reasons.
|
|
52
|
+
* Asserts that the databox should trigger an data change event.
|
|
53
|
+
* It is also possible to filter for specific data event reasons with a queric query.
|
|
61
54
|
*/
|
|
62
|
-
dataChangeTriggers(
|
|
55
|
+
dataChangeTriggers(reasonFilter?: Query<DataEventReason>): DataEventAsserter<T, [DeepReadonly<DataboxData<D>>, DataEventReason, DbStorage<DataboxData<D>>], 0>;
|
|
63
56
|
/**
|
|
64
57
|
* @description
|
|
65
|
-
* Asserts that the databox should trigger an
|
|
66
|
-
* It is also possible to
|
|
58
|
+
* Asserts that the databox should trigger an data touch event.
|
|
59
|
+
* It is also possible to filter for specific data event reasons with a queric query.
|
|
67
60
|
*/
|
|
68
|
-
dataTouchTriggers(
|
|
61
|
+
dataTouchTriggers(reasonFilter?: Query<DataEventReason>): DataEventAsserter<T, [DeepReadonly<DataboxData<D>>, DataEventReason, DbStorage<DataboxData<D>>], 0>;
|
|
69
62
|
/**
|
|
70
63
|
* @description
|
|
71
|
-
* Asserts that the databox should trigger an
|
|
64
|
+
* Asserts that the databox should trigger an close event.
|
|
72
65
|
*/
|
|
73
|
-
closeTriggers():
|
|
66
|
+
closeTriggers(): CodeMetadataEventAsserter<T, [number | string | undefined, any], 0, 1>;
|
|
74
67
|
/**
|
|
75
68
|
* @description
|
|
76
|
-
* Asserts that the databox should trigger an
|
|
69
|
+
* Asserts that the databox should trigger an kick out event.
|
|
77
70
|
*/
|
|
78
|
-
kickOutTriggers():
|
|
71
|
+
kickOutTriggers(): CodeMetadataEventAsserter<T, [number | string | undefined, any], 0, 1>;
|
|
79
72
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/*
|
|
3
|
-
Author: Luca Scaringella
|
|
3
|
+
Author: Ing. Luca Gian Scaringella
|
|
4
4
|
GitHub: LucaCode
|
|
5
|
-
|
|
5
|
+
Copyright(c) Ing. Luca Gian Scaringella
|
|
6
6
|
*/
|
|
7
7
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
8
8
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
@@ -19,8 +19,9 @@ const timeoutAssert_1 = require("../../timeout/timeoutAssert");
|
|
|
19
19
|
const actionUtils_1 = require("../../utils/actionUtils");
|
|
20
20
|
const dataEventAsserter_1 = require("../event/dataEventAsserter");
|
|
21
21
|
const valueAsserter_1 = require("../value/valueAsserter");
|
|
22
|
-
const
|
|
22
|
+
const codeMetadataEventAsserter_1 = require("../event/codeMetadataEventAsserter");
|
|
23
23
|
const chai_1 = require("chai");
|
|
24
|
+
const queric_1 = require("queric");
|
|
24
25
|
class AbstractDataboxAsserter {
|
|
25
26
|
constructor(databoxes, test) {
|
|
26
27
|
this._test = test;
|
|
@@ -28,11 +29,7 @@ class AbstractDataboxAsserter {
|
|
|
28
29
|
}
|
|
29
30
|
_forEachDatabox(func) {
|
|
30
31
|
return __awaiter(this, void 0, void 0, function* () {
|
|
31
|
-
|
|
32
|
-
this.databoxes.forEach((c, i) => {
|
|
33
|
-
promises.push(func(c, i));
|
|
34
|
-
});
|
|
35
|
-
yield Promise.all(promises);
|
|
32
|
+
yield Promise.all(this.databoxes.map((db, i) => func(db, i)));
|
|
36
33
|
});
|
|
37
34
|
}
|
|
38
35
|
// noinspection JSUnusedGlobalSymbols
|
|
@@ -40,11 +37,11 @@ class AbstractDataboxAsserter {
|
|
|
40
37
|
* @description
|
|
41
38
|
* Asserts that the databox is connected.
|
|
42
39
|
* @param timeout
|
|
43
|
-
*
|
|
40
|
+
* Sets a time limit in that the assertion must be successful.
|
|
44
41
|
*/
|
|
45
42
|
isConnected(timeout = 0) {
|
|
46
43
|
this._test.test(() => __awaiter(this, void 0, void 0, function* () {
|
|
47
|
-
|
|
44
|
+
return this._forEachDatabox((d, i) => __awaiter(this, void 0, void 0, function* () {
|
|
48
45
|
if (d.isConnected())
|
|
49
46
|
return;
|
|
50
47
|
const toa = new timeoutAssert_1.TimeoutAssert(`Databox: ${i} should be connected.`, timeout);
|
|
@@ -61,11 +58,11 @@ class AbstractDataboxAsserter {
|
|
|
61
58
|
* @description
|
|
62
59
|
* Asserts that the databox is disconnected.
|
|
63
60
|
* @param timeout
|
|
64
|
-
*
|
|
61
|
+
* Sets a time limit in that the assertion must be successful.
|
|
65
62
|
*/
|
|
66
63
|
isDisconnected(timeout = 0) {
|
|
67
64
|
this._test.test(() => __awaiter(this, void 0, void 0, function* () {
|
|
68
|
-
|
|
65
|
+
return this._forEachDatabox((d, i) => __awaiter(this, void 0, void 0, function* () {
|
|
69
66
|
if (!d.isConnected())
|
|
70
67
|
return;
|
|
71
68
|
const toa = new timeoutAssert_1.TimeoutAssert(`Databox: ${i} should be disconnected.`, timeout);
|
|
@@ -82,12 +79,8 @@ class AbstractDataboxAsserter {
|
|
|
82
79
|
* Asserts the current data of the databox.
|
|
83
80
|
*/
|
|
84
81
|
data() {
|
|
85
|
-
return new valueAsserter_1.ValueAsserter(this.self(),
|
|
86
|
-
this._test.test(() =>
|
|
87
|
-
yield this._forEachDatabox((d, i) => __awaiter(this, void 0, void 0, function* () {
|
|
88
|
-
test(d.data, ` ${i} data:`);
|
|
89
|
-
}));
|
|
90
|
-
}));
|
|
82
|
+
return new valueAsserter_1.ValueAsserter(this.self(), (test) => {
|
|
83
|
+
this._test.test(() => this._forEachDatabox((d, i) => test(d.data, `Databox: ${i} data:`)));
|
|
91
84
|
});
|
|
92
85
|
}
|
|
93
86
|
// noinspection JSUnusedGlobalSymbols
|
|
@@ -95,12 +88,8 @@ class AbstractDataboxAsserter {
|
|
|
95
88
|
* Asserts the current member of the databox.
|
|
96
89
|
*/
|
|
97
90
|
member() {
|
|
98
|
-
return new valueAsserter_1.ValueAsserter(this.self(),
|
|
99
|
-
this._test.test(() =>
|
|
100
|
-
yield this._forEachDatabox((d, i) => __awaiter(this, void 0, void 0, function* () {
|
|
101
|
-
test(d.member, ` ${i} member:`);
|
|
102
|
-
}));
|
|
103
|
-
}));
|
|
91
|
+
return new valueAsserter_1.ValueAsserter(this.self(), (test) => {
|
|
92
|
+
this._test.test(() => this._forEachDatabox((d, i) => test(d.member, `Databox: ${i} member:`)));
|
|
104
93
|
});
|
|
105
94
|
}
|
|
106
95
|
// noinspection JSUnusedGlobalSymbols
|
|
@@ -117,7 +106,7 @@ class AbstractDataboxAsserter {
|
|
|
117
106
|
yield databox.fetch(fetchData);
|
|
118
107
|
}
|
|
119
108
|
catch (err) {
|
|
120
|
-
chai_1.assert.fail(`Databox ${number} fetch ${i} failed. Error -> ` + err
|
|
109
|
+
chai_1.assert.fail(`Databox: ${number} fetch ${i} failed. Error -> ` + err);
|
|
121
110
|
}
|
|
122
111
|
}))());
|
|
123
112
|
}
|
|
@@ -130,101 +119,76 @@ class AbstractDataboxAsserter {
|
|
|
130
119
|
// noinspection JSUnusedGlobalSymbols
|
|
131
120
|
/**
|
|
132
121
|
* @description
|
|
133
|
-
*
|
|
134
|
-
*
|
|
135
|
-
*
|
|
136
|
-
* @param message if not provided it throws the specific error.
|
|
137
|
-
*/
|
|
138
|
-
action(action, message) {
|
|
139
|
-
this.databoxes.forEach((databox, index) => {
|
|
140
|
-
actionUtils_1.default.action(this._test, () => action(databox, index), message);
|
|
141
|
-
});
|
|
142
|
-
this._test.pushSyncWait();
|
|
143
|
-
return this.self();
|
|
144
|
-
}
|
|
145
|
-
// noinspection JSUnusedGlobalSymbols
|
|
146
|
-
/**
|
|
147
|
-
* @description
|
|
148
|
-
* This function lets you do extra actions on each databox and
|
|
149
|
-
* asserts that an error or an error instance of a specific class is thrown.
|
|
150
|
-
* When no error is thrown, or the error does not match with the given classes
|
|
151
|
-
* (only if at least one class is given), it lets the test fail with the provided message.
|
|
122
|
+
* Runs a extra test action and asserts that no error will be thrown.
|
|
123
|
+
* AssertionErrors will be rethrown, and all other errors will fail
|
|
124
|
+
* the test with the provided message or the concrete error.
|
|
152
125
|
* @param action
|
|
153
|
-
* @param
|
|
154
|
-
* @param validErrorClasses
|
|
126
|
+
* @param failMsg If not provided, the concrete error is used.
|
|
155
127
|
*/
|
|
156
|
-
|
|
157
|
-
this.
|
|
158
|
-
actionUtils_1.default.actionShouldThrow(this._test, () => action(databox, index), message, ...validErrorClasses);
|
|
159
|
-
});
|
|
128
|
+
action(action, failMsg) {
|
|
129
|
+
this._test.test(() => this._forEachDatabox((databox, index) => actionUtils_1.default.runAction(() => action(databox, index), failMsg)));
|
|
160
130
|
this._test.pushSyncWait();
|
|
161
131
|
return this.self();
|
|
162
132
|
}
|
|
163
133
|
// noinspection JSUnusedGlobalSymbols
|
|
164
134
|
/**
|
|
165
135
|
* @description
|
|
166
|
-
* Asserts that the databox should trigger an
|
|
167
|
-
* It is also possible to
|
|
136
|
+
* Asserts that the databox should trigger an data change event.
|
|
137
|
+
* It is also possible to filter for specific data event reasons with a queric query.
|
|
168
138
|
*/
|
|
169
|
-
dataChangeTriggers(
|
|
139
|
+
dataChangeTriggers(reasonFilter) {
|
|
140
|
+
const filter = reasonFilter ? (0, queric_1.default)(reasonFilter) : () => true;
|
|
170
141
|
return new dataEventAsserter_1.DataEventAsserter(this.databoxes.map(d => {
|
|
171
142
|
return (listener) => {
|
|
172
143
|
let handler;
|
|
173
|
-
d.onDataChange(handler = (data,
|
|
174
|
-
if (
|
|
144
|
+
d.onDataChange(handler = (data, reason, storage) => {
|
|
145
|
+
if (filter(reason)) {
|
|
175
146
|
d.offDataChange(handler);
|
|
176
|
-
listener(data);
|
|
147
|
+
listener(data, reason, storage);
|
|
177
148
|
}
|
|
178
149
|
});
|
|
179
150
|
};
|
|
180
|
-
}), "Databox", "
|
|
151
|
+
}), "Databox", "data change", this._test, this.self(), 0, ((reasonFilter) ? ` with reasons that match the filter: ${reasonFilter}` : ''));
|
|
181
152
|
}
|
|
182
153
|
// noinspection JSUnusedGlobalSymbols
|
|
183
154
|
/**
|
|
184
155
|
* @description
|
|
185
|
-
* Asserts that the databox should trigger an
|
|
186
|
-
* It is also possible to
|
|
156
|
+
* Asserts that the databox should trigger an data touch event.
|
|
157
|
+
* It is also possible to filter for specific data event reasons with a queric query.
|
|
187
158
|
*/
|
|
188
|
-
dataTouchTriggers(
|
|
159
|
+
dataTouchTriggers(reasonFilter) {
|
|
160
|
+
const filter = reasonFilter ? (0, queric_1.default)(reasonFilter) : () => true;
|
|
189
161
|
return new dataEventAsserter_1.DataEventAsserter(this.databoxes.map(d => {
|
|
190
162
|
return (listener) => {
|
|
191
163
|
let handler;
|
|
192
|
-
d.onDataTouch(handler = (data,
|
|
193
|
-
if (
|
|
164
|
+
d.onDataTouch(handler = (data, reason, storage) => {
|
|
165
|
+
if (filter(reason)) {
|
|
194
166
|
d.offDataTouch(handler);
|
|
195
|
-
listener(data);
|
|
167
|
+
listener(data, reason, storage);
|
|
196
168
|
}
|
|
197
169
|
});
|
|
198
170
|
};
|
|
199
|
-
}), "Databox", "
|
|
171
|
+
}), "Databox", "data touch", this._test, this.self(), 0, ((reasonFilter) ? ` with reasons that match the filter: ${reasonFilter}` : ''));
|
|
200
172
|
}
|
|
201
173
|
// noinspection JSUnusedGlobalSymbols
|
|
202
174
|
/**
|
|
203
175
|
* @description
|
|
204
|
-
* Asserts that the databox should trigger an
|
|
176
|
+
* Asserts that the databox should trigger an close event.
|
|
205
177
|
*/
|
|
206
178
|
closeTriggers() {
|
|
207
|
-
return new
|
|
208
|
-
return (listener) =>
|
|
209
|
-
|
|
210
|
-
listener(data, code);
|
|
211
|
-
});
|
|
212
|
-
};
|
|
213
|
-
}), "Databox", "Close", this._test, this.self());
|
|
179
|
+
return new codeMetadataEventAsserter_1.CodeMetadataEventAsserter(this.databoxes.map(d => {
|
|
180
|
+
return (listener) => d.onceClose(listener);
|
|
181
|
+
}), "Databox", "close", this._test, this.self(), 0, 1);
|
|
214
182
|
}
|
|
215
183
|
// noinspection JSUnusedGlobalSymbols
|
|
216
184
|
/**
|
|
217
185
|
* @description
|
|
218
|
-
* Asserts that the databox should trigger an
|
|
186
|
+
* Asserts that the databox should trigger an kick out event.
|
|
219
187
|
*/
|
|
220
188
|
kickOutTriggers() {
|
|
221
|
-
return new
|
|
222
|
-
return (listener) =>
|
|
223
|
-
|
|
224
|
-
listener(data, code);
|
|
225
|
-
});
|
|
226
|
-
};
|
|
227
|
-
}), "Databox", "KickOut", this._test, this.self());
|
|
189
|
+
return new codeMetadataEventAsserter_1.CodeMetadataEventAsserter(this.databoxes.map(d => {
|
|
190
|
+
return (listener) => d.onceKickOut(listener);
|
|
191
|
+
}), "Databox", "kick out", this._test, this.self(), 0, 1);
|
|
228
192
|
}
|
|
229
193
|
}
|
|
230
194
|
exports.AbstractDataboxAsserter = AbstractDataboxAsserter;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { Databox } from 'zation-client';
|
|
2
2
|
import { Test } from "../../test/test";
|
|
3
3
|
import { AbstractDataboxAsserter } from "./abstractDataboxAsserter";
|
|
4
|
-
export declare class DataboxAsserter<T
|
|
4
|
+
export declare class DataboxAsserter<T, D extends Databox<any, any, any, any>> extends AbstractDataboxAsserter<DataboxAsserter<T, D>, D> {
|
|
5
5
|
private readonly _source;
|
|
6
|
-
constructor(databoxes:
|
|
6
|
+
constructor(databoxes: D[], test: Test, source: T);
|
|
7
7
|
/**
|
|
8
8
|
* @description
|
|
9
9
|
* End the databox asserter.
|
|
10
10
|
*/
|
|
11
11
|
end(): T;
|
|
12
|
-
protected self(): DataboxAsserter<T>;
|
|
12
|
+
protected self(): DataboxAsserter<T, D>;
|
|
13
13
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/*
|
|
3
|
-
Author: Luca Scaringella
|
|
3
|
+
Author: Ing. Luca Gian Scaringella
|
|
4
4
|
GitHub: LucaCode
|
|
5
|
-
|
|
5
|
+
Copyright(c) Ing. Luca Gian Scaringella
|
|
6
6
|
*/
|
|
7
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
8
|
exports.DataboxAsserter = void 0;
|