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,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,13 +19,13 @@ const test_1 = require("../../test/test");
|
|
|
19
19
|
const abstractChannelAsserter_1 = require("./abstractChannelAsserter");
|
|
20
20
|
const chai_1 = require("chai");
|
|
21
21
|
class StandaloneChannelAsserter extends abstractChannelAsserter_1.AbstractChannelAsserter {
|
|
22
|
-
constructor(channel,
|
|
23
|
-
super(Array.isArray(channel) ? channel : [channel], new test_1.Test(
|
|
22
|
+
constructor(channel, description) {
|
|
23
|
+
super(Array.isArray(channel) ? channel : [channel], new test_1.Test(description));
|
|
24
24
|
}
|
|
25
25
|
// noinspection JSUnusedGlobalSymbols
|
|
26
26
|
/**
|
|
27
27
|
* @description
|
|
28
|
-
*
|
|
28
|
+
* Subscribes all channels (before the test).
|
|
29
29
|
*/
|
|
30
30
|
subscribe(member) {
|
|
31
31
|
this._test.beforeTest(() => __awaiter(this, void 0, void 0, function* () {
|
|
@@ -34,7 +34,7 @@ class StandaloneChannelAsserter extends abstractChannelAsserter_1.AbstractChanne
|
|
|
34
34
|
yield channel.subscribe(member);
|
|
35
35
|
}
|
|
36
36
|
catch (err) {
|
|
37
|
-
chai_1.assert.fail(`Cannot subscribe to the channel ${index}. Error -> ` + err
|
|
37
|
+
chai_1.assert.fail(`Cannot subscribe to the channel ${index}. Error -> ` + err);
|
|
38
38
|
}
|
|
39
39
|
})));
|
|
40
40
|
}));
|
|
@@ -1,109 +1,91 @@
|
|
|
1
1
|
import { Test } from "../../test/test";
|
|
2
|
-
import { DataboxOptions, Client } from 'zation-client';
|
|
3
|
-
import { DataEventAsserter } from "../event/dataEventAsserter";
|
|
2
|
+
import { DataboxOptions, Client, Databox, Channel } from 'zation-client';
|
|
4
3
|
import { DataboxAsserter } from "../databox/databoxAsserter";
|
|
5
4
|
import { ChannelAsserter } from "../channel/channelAsserter";
|
|
6
5
|
import { ValueAsserter } from "../value/valueAsserter";
|
|
7
|
-
|
|
8
|
-
export declare abstract class AbstractClientAsserter<T
|
|
6
|
+
import { ClientAPI, ClientTokenPayload, Default } from "../../utils/types";
|
|
7
|
+
export declare abstract class AbstractClientAsserter<T, C extends Client<any, any>> {
|
|
9
8
|
protected _test: Test;
|
|
10
|
-
protected clients:
|
|
9
|
+
protected clients: C[];
|
|
11
10
|
protected abstract self(): T;
|
|
12
|
-
protected constructor(clients:
|
|
13
|
-
protected _forEachClient(func: (client:
|
|
11
|
+
protected constructor(clients: C[], test: Test);
|
|
12
|
+
protected _forEachClient(func: (client: C, i: number) => Promise<void>): Promise<void>;
|
|
14
13
|
/**
|
|
15
14
|
* @description
|
|
16
|
-
*
|
|
15
|
+
* Asserts that the client is connected.
|
|
17
16
|
* @param timeout
|
|
18
|
-
*
|
|
17
|
+
* Sets a time limit in that the assertion must be successful.
|
|
19
18
|
*/
|
|
20
19
|
isConnected(timeout?: number): T;
|
|
21
20
|
/**
|
|
22
21
|
* @description
|
|
23
|
-
*
|
|
22
|
+
* Asserts that the client is disconnected.
|
|
24
23
|
* @param timeout
|
|
25
|
-
*
|
|
24
|
+
* Sets a time limit in that the assertion must be successful.
|
|
26
25
|
*/
|
|
27
26
|
isDisconnected(timeout?: number): T;
|
|
28
27
|
/**
|
|
29
28
|
* @description
|
|
30
|
-
*
|
|
29
|
+
* Asserts that the client is authenticated.
|
|
31
30
|
* @param timeout
|
|
32
|
-
*
|
|
31
|
+
* Sets a time limit in that the assertion must be successful.
|
|
33
32
|
*/
|
|
34
33
|
isAuthenticated(timeout?: number): T;
|
|
35
34
|
/**
|
|
36
35
|
* @description
|
|
37
|
-
*
|
|
36
|
+
* Asserts that the client is deauthenticated.
|
|
38
37
|
* @param timeout
|
|
39
|
-
*
|
|
38
|
+
* Sets a time limit in that the assertion must be successful.
|
|
40
39
|
*/
|
|
41
40
|
isDeauthenticated(timeout?: number): T;
|
|
42
41
|
/**
|
|
43
42
|
* @description
|
|
44
|
-
*
|
|
43
|
+
* Asserts that the client has a user id.
|
|
45
44
|
* @param userId
|
|
46
45
|
* If it is not given it will assert that the client has any user id.
|
|
47
46
|
*/
|
|
48
47
|
hasUserId(userId?: number | string): T;
|
|
49
48
|
/**
|
|
50
49
|
* @description
|
|
51
|
-
*
|
|
50
|
+
* Asserts that the client has a authUserGroup.
|
|
52
51
|
* @param authUserGroup
|
|
53
52
|
* If it is not given it will assert that the client has any authUserGroup.
|
|
54
53
|
*/
|
|
55
54
|
hasAuthUserGroup(authUserGroup?: string): T;
|
|
56
55
|
/**
|
|
57
56
|
* @description
|
|
58
|
-
*
|
|
57
|
+
* Asserts that the client has a specific token id.
|
|
59
58
|
*/
|
|
60
59
|
hasTokenId(tokenId: string): T;
|
|
61
60
|
/**
|
|
62
61
|
* @description
|
|
63
|
-
*
|
|
62
|
+
* Asserts that the client has panel access.
|
|
64
63
|
*/
|
|
65
64
|
hasPanelAccess(access?: boolean): T;
|
|
66
65
|
/**
|
|
67
66
|
* @description
|
|
68
|
-
*
|
|
67
|
+
* Asserts the token payload of the client.
|
|
69
68
|
*/
|
|
70
|
-
tokenPayload(): ValueAsserter<T>;
|
|
69
|
+
tokenPayload(): ValueAsserter<ClientTokenPayload<C>, T>;
|
|
71
70
|
/**
|
|
72
71
|
* @description
|
|
73
|
-
*
|
|
72
|
+
* Create assertions on a databox of the client.
|
|
74
73
|
* Will automatically connect (before the test) and disconnect (after the test) the databox.
|
|
75
74
|
*/
|
|
76
|
-
databox(identifier:
|
|
75
|
+
databox<DN extends keyof ClientAPI<C>['databoxes']>(identifier: DN, member?: Default<ClientAPI<C>['databoxes'][DN]['member'], string>, options?: DataboxOptions<ClientAPI<C>['databoxes'][DN]['options'], ClientAPI<C>['databoxes'][DN]['fetchInput']>): DataboxAsserter<T, Databox<ClientAPI<C>['databoxes'][DN]['content'], Default<ClientAPI<C>['databoxes'][DN]['member'], string>, ClientAPI<C>['databoxes'][DN]['options'], ClientAPI<C>['databoxes'][DN]['fetchInput']>>;
|
|
77
76
|
/**
|
|
78
77
|
* @description
|
|
79
|
-
*
|
|
78
|
+
* Create assertions on a channel of the client.
|
|
80
79
|
* Will automatically subscribe (before the test) and unsubscribe (after the test) the channel.
|
|
81
80
|
*/
|
|
82
|
-
channel(identifier:
|
|
81
|
+
channel<CN extends keyof ClientAPI<C>['channels']>(identifier: CN, member?: Default<ClientAPI<C>['channels'][CN]['member'], string>): ChannelAsserter<T, Channel<Default<ClientAPI<C>['channels'][CN]['member'], string>, Default<ClientAPI<C>['channels'][CN]['publishes'], Record<string, any>>>>;
|
|
83
82
|
/**
|
|
84
83
|
* @description
|
|
85
|
-
*
|
|
86
|
-
*
|
|
84
|
+
* Runs a extra test action and asserts that no error will be thrown.
|
|
85
|
+
* AssertionErrors will be rethrown, and all other errors will fail
|
|
86
|
+
* the test with the provided message or the concrete error.
|
|
87
87
|
* @param action
|
|
88
|
-
* @param
|
|
88
|
+
* @param failMsg If not provided, the concrete error is used.
|
|
89
89
|
*/
|
|
90
|
-
action(action: (client:
|
|
91
|
-
/**
|
|
92
|
-
* @description
|
|
93
|
-
* This function lets you do extra actions on each client and
|
|
94
|
-
* asserts that an error or an error instance of a specific class is thrown.
|
|
95
|
-
* When no error is thrown, or the error does not match with the given classes
|
|
96
|
-
* (only if at least one class is given), it lets the test fail with the provided message.
|
|
97
|
-
* @param action
|
|
98
|
-
* @param message
|
|
99
|
-
* @param validErrorClasses
|
|
100
|
-
*/
|
|
101
|
-
actionShouldThrow(action: (client: Client, index: number) => void | Promise<void>, message: string, ...validErrorClasses: any[]): T;
|
|
102
|
-
/**
|
|
103
|
-
* @description
|
|
104
|
-
* Assert that the client should receive an emit-event from the server.
|
|
105
|
-
* It uses the custom zation event namespace
|
|
106
|
-
* (so you cannot have name conflicts with internal event names).
|
|
107
|
-
*/
|
|
108
|
-
receiveEvent(event: string, responder?: Responder): DataEventAsserter<T>;
|
|
90
|
+
action(action: (client: C, index: number) => void | Promise<void>, failMsg?: string): T;
|
|
109
91
|
}
|
|
@@ -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); }); }
|
|
@@ -16,10 +16,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
exports.AbstractClientAsserter = void 0;
|
|
18
18
|
const assert = require('assert');
|
|
19
|
-
const zation_client_1 = require("zation-client");
|
|
20
19
|
const timeoutAssert_1 = require("../../timeout/timeoutAssert");
|
|
21
20
|
const actionUtils_1 = require("../../utils/actionUtils");
|
|
22
|
-
const dataEventAsserter_1 = require("../event/dataEventAsserter");
|
|
23
21
|
const databoxAsserter_1 = require("../databox/databoxAsserter");
|
|
24
22
|
const channelAsserter_1 = require("../channel/channelAsserter");
|
|
25
23
|
const valueAsserter_1 = require("../value/valueAsserter");
|
|
@@ -30,218 +28,160 @@ class AbstractClientAsserter {
|
|
|
30
28
|
}
|
|
31
29
|
_forEachClient(func) {
|
|
32
30
|
return __awaiter(this, void 0, void 0, function* () {
|
|
33
|
-
|
|
34
|
-
this.clients.forEach((c, i) => {
|
|
35
|
-
promises.push(func(c, i));
|
|
36
|
-
});
|
|
37
|
-
yield Promise.all(promises);
|
|
31
|
+
yield Promise.all(this.clients.map((client, index) => func(client, index)));
|
|
38
32
|
});
|
|
39
33
|
}
|
|
40
34
|
// noinspection JSUnusedGlobalSymbols
|
|
41
35
|
/**
|
|
42
36
|
* @description
|
|
43
|
-
*
|
|
37
|
+
* Asserts that the client is connected.
|
|
44
38
|
* @param timeout
|
|
45
|
-
*
|
|
39
|
+
* Sets a time limit in that the assertion must be successful.
|
|
46
40
|
*/
|
|
47
41
|
isConnected(timeout = 0) {
|
|
48
|
-
this._test.test(() => __awaiter(this, void 0, void 0, function* () {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
yield toa.set();
|
|
58
|
-
}));
|
|
59
|
-
}));
|
|
42
|
+
this._test.test(() => this._forEachClient((c, i) => __awaiter(this, void 0, void 0, function* () {
|
|
43
|
+
if (c.connected)
|
|
44
|
+
return;
|
|
45
|
+
const toa = new timeoutAssert_1.TimeoutAssert(`Client: ${i} should be connected.`, timeout);
|
|
46
|
+
c.onceConnect(() => {
|
|
47
|
+
toa.resolve();
|
|
48
|
+
});
|
|
49
|
+
yield toa.set();
|
|
50
|
+
})));
|
|
60
51
|
return this.self();
|
|
61
52
|
}
|
|
62
53
|
// noinspection JSUnusedGlobalSymbols
|
|
63
54
|
/**
|
|
64
55
|
* @description
|
|
65
|
-
*
|
|
56
|
+
* Asserts that the client is disconnected.
|
|
66
57
|
* @param timeout
|
|
67
|
-
*
|
|
58
|
+
* Sets a time limit in that the assertion must be successful.
|
|
68
59
|
*/
|
|
69
60
|
isDisconnected(timeout = 0) {
|
|
70
|
-
this._test.test(() => __awaiter(this, void 0, void 0, function* () {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
yield toa.set();
|
|
80
|
-
}));
|
|
81
|
-
}));
|
|
61
|
+
this._test.test(() => this._forEachClient((c, i) => __awaiter(this, void 0, void 0, function* () {
|
|
62
|
+
if (!c.connected)
|
|
63
|
+
return;
|
|
64
|
+
const toa = new timeoutAssert_1.TimeoutAssert(`Client: ${i} should be disconnected.`, timeout);
|
|
65
|
+
c.onceDisconnect(() => {
|
|
66
|
+
toa.resolve();
|
|
67
|
+
});
|
|
68
|
+
yield toa.set();
|
|
69
|
+
})));
|
|
82
70
|
return this.self();
|
|
83
71
|
}
|
|
84
72
|
// noinspection JSUnusedGlobalSymbols
|
|
85
73
|
/**
|
|
86
74
|
* @description
|
|
87
|
-
*
|
|
75
|
+
* Asserts that the client is authenticated.
|
|
88
76
|
* @param timeout
|
|
89
|
-
*
|
|
77
|
+
* Sets a time limit in that the assertion must be successful.
|
|
90
78
|
*/
|
|
91
79
|
isAuthenticated(timeout = 0) {
|
|
92
|
-
this._test.test(() => __awaiter(this, void 0, void 0, function* () {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
yield toa.set();
|
|
102
|
-
}));
|
|
103
|
-
}));
|
|
80
|
+
this._test.test(() => this._forEachClient((c, i) => __awaiter(this, void 0, void 0, function* () {
|
|
81
|
+
if (c.authenticated)
|
|
82
|
+
return;
|
|
83
|
+
const toa = new timeoutAssert_1.TimeoutAssert(`Client: ${i} should be authenticated.`, timeout);
|
|
84
|
+
c.onceAuthenticate(() => {
|
|
85
|
+
toa.resolve();
|
|
86
|
+
});
|
|
87
|
+
yield toa.set();
|
|
88
|
+
})));
|
|
104
89
|
return this.self();
|
|
105
90
|
}
|
|
106
91
|
// noinspection JSUnusedGlobalSymbols
|
|
107
92
|
/**
|
|
108
93
|
* @description
|
|
109
|
-
*
|
|
94
|
+
* Asserts that the client is deauthenticated.
|
|
110
95
|
* @param timeout
|
|
111
|
-
*
|
|
96
|
+
* Sets a time limit in that the assertion must be successful.
|
|
112
97
|
*/
|
|
113
98
|
isDeauthenticated(timeout = 0) {
|
|
114
|
-
this._test.test(() => __awaiter(this, void 0, void 0, function* () {
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
yield toa.set();
|
|
124
|
-
}));
|
|
125
|
-
}));
|
|
99
|
+
this._test.test(() => this._forEachClient((c, i) => __awaiter(this, void 0, void 0, function* () {
|
|
100
|
+
if (!c.authenticated)
|
|
101
|
+
return;
|
|
102
|
+
const toa = new timeoutAssert_1.TimeoutAssert(`Client: ${i} should be deauthenticated.`, timeout);
|
|
103
|
+
c.onceDeauthenticate(() => {
|
|
104
|
+
toa.resolve();
|
|
105
|
+
});
|
|
106
|
+
yield toa.set();
|
|
107
|
+
})));
|
|
126
108
|
return this.self();
|
|
127
109
|
}
|
|
128
110
|
// noinspection JSUnusedGlobalSymbols
|
|
129
111
|
/**
|
|
130
112
|
* @description
|
|
131
|
-
*
|
|
113
|
+
* Asserts that the client has a user id.
|
|
132
114
|
* @param userId
|
|
133
115
|
* If it is not given it will assert that the client has any user id.
|
|
134
116
|
*/
|
|
135
117
|
hasUserId(userId) {
|
|
136
|
-
this._test.test(() => __awaiter(this, void 0, void 0, function* () {
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
assert.fail(`Client: ${i} should have any user id.`);
|
|
144
|
-
}
|
|
145
|
-
}));
|
|
146
|
-
}));
|
|
118
|
+
this._test.test(() => this._forEachClient((c, i) => __awaiter(this, void 0, void 0, function* () {
|
|
119
|
+
const currentId = c.userId;
|
|
120
|
+
if (userId != null)
|
|
121
|
+
assert.equal(currentId, userId, `Client: ${i} should have the userId: ${userId}`);
|
|
122
|
+
else if (currentId == null)
|
|
123
|
+
assert.fail(`Client: ${i} should have any user id.`);
|
|
124
|
+
})));
|
|
147
125
|
return this.self();
|
|
148
126
|
}
|
|
149
127
|
// noinspection JSUnusedGlobalSymbols
|
|
150
128
|
/**
|
|
151
129
|
* @description
|
|
152
|
-
*
|
|
130
|
+
* Asserts that the client has a authUserGroup.
|
|
153
131
|
* @param authUserGroup
|
|
154
132
|
* If it is not given it will assert that the client has any authUserGroup.
|
|
155
133
|
*/
|
|
156
134
|
hasAuthUserGroup(authUserGroup) {
|
|
157
|
-
this._test.test(() => __awaiter(this, void 0, void 0, function* () {
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
}
|
|
166
|
-
}));
|
|
167
|
-
}));
|
|
135
|
+
this._test.test(() => this._forEachClient((c, i) => __awaiter(this, void 0, void 0, function* () {
|
|
136
|
+
const currentGroup = c.authUserGroup;
|
|
137
|
+
if (authUserGroup != null) {
|
|
138
|
+
assert.equal(currentGroup, authUserGroup, `Client: ${i} should have the authUserGroup: ${authUserGroup}`);
|
|
139
|
+
}
|
|
140
|
+
else if (currentGroup == null)
|
|
141
|
+
assert.fail(`Client: ${i} should have any authUserGroup.`);
|
|
142
|
+
})));
|
|
168
143
|
return this.self();
|
|
169
144
|
}
|
|
170
145
|
// noinspection JSUnusedGlobalSymbols
|
|
171
146
|
/**
|
|
172
147
|
* @description
|
|
173
|
-
*
|
|
148
|
+
* Asserts that the client has a specific token id.
|
|
174
149
|
*/
|
|
175
150
|
hasTokenId(tokenId) {
|
|
176
|
-
this._test.test(() => __awaiter(this, void 0, void 0, function* () {
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
assert.equal(currentTokenId, tokenId, `Client: ${i} should have the tokenId: ${tokenId}`);
|
|
181
|
-
}
|
|
182
|
-
catch (e) {
|
|
183
|
-
if (e instanceof zation_client_1.AuthenticationRequiredError) {
|
|
184
|
-
assert.fail(`Client: ${i} can not access the token for assert token id.`);
|
|
185
|
-
}
|
|
186
|
-
else {
|
|
187
|
-
throw e;
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
}));
|
|
191
|
-
}));
|
|
151
|
+
this._test.test(() => this._forEachClient((c, i) => __awaiter(this, void 0, void 0, function* () {
|
|
152
|
+
var _a;
|
|
153
|
+
assert.equal((_a = c.authToken) === null || _a === void 0 ? void 0 : _a.tid, tokenId, `Client: ${i} should have the tokenId: ${tokenId}`);
|
|
154
|
+
})));
|
|
192
155
|
return this.self();
|
|
193
156
|
}
|
|
194
157
|
// noinspection JSUnusedGlobalSymbols
|
|
195
158
|
/**
|
|
196
159
|
* @description
|
|
197
|
-
*
|
|
160
|
+
* Asserts that the client has panel access.
|
|
198
161
|
*/
|
|
199
162
|
hasPanelAccess(access = true) {
|
|
200
|
-
this._test.test(() => __awaiter(this, void 0, void 0, function* () {
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
assert.equal(currentAccess, access, `Client: ${i} should ${access ? '' : 'not'} have panel access`);
|
|
205
|
-
}
|
|
206
|
-
catch (e) {
|
|
207
|
-
if (e instanceof zation_client_1.AuthenticationRequiredError) {
|
|
208
|
-
assert.fail(`Client: ${i} can not access the token for assert panel access.`);
|
|
209
|
-
}
|
|
210
|
-
else {
|
|
211
|
-
throw e;
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
}));
|
|
215
|
-
}));
|
|
163
|
+
this._test.test(() => this._forEachClient((c, i) => __awaiter(this, void 0, void 0, function* () {
|
|
164
|
+
var _a;
|
|
165
|
+
assert.equal((_a = c.authToken) === null || _a === void 0 ? void 0 : _a.panelAccess, access, `Client: ${i} should ${access ? '' : 'not'} have panel access`);
|
|
166
|
+
})));
|
|
216
167
|
return this.self();
|
|
217
168
|
}
|
|
218
169
|
// noinspection JSUnusedGlobalSymbols
|
|
219
170
|
/**
|
|
220
171
|
* @description
|
|
221
|
-
*
|
|
172
|
+
* Asserts the token payload of the client.
|
|
222
173
|
*/
|
|
223
174
|
tokenPayload() {
|
|
224
|
-
return new valueAsserter_1.ValueAsserter(this.self(),
|
|
225
|
-
this._test.test(() => __awaiter(this, void 0, void 0, function* () {
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
test(c.getTokenPayload(), ` ${i} Token:`);
|
|
229
|
-
}
|
|
230
|
-
catch (e) {
|
|
231
|
-
if (e instanceof zation_client_1.AuthenticationRequiredError) {
|
|
232
|
-
assert.fail(`Client: ${i} token payload can not be asserted because the client is not authenticated.`);
|
|
233
|
-
}
|
|
234
|
-
else
|
|
235
|
-
throw e;
|
|
236
|
-
}
|
|
237
|
-
}));
|
|
238
|
-
}));
|
|
175
|
+
return new valueAsserter_1.ValueAsserter(this.self(), (test) => {
|
|
176
|
+
this._test.test(() => this._forEachClient((c, i) => __awaiter(this, void 0, void 0, function* () {
|
|
177
|
+
test(c.authTokenPayload, `Client: ${i} token payload:`);
|
|
178
|
+
})));
|
|
239
179
|
});
|
|
240
180
|
}
|
|
241
181
|
// noinspection JSUnusedGlobalSymbols
|
|
242
182
|
/**
|
|
243
183
|
* @description
|
|
244
|
-
*
|
|
184
|
+
* Create assertions on a databox of the client.
|
|
245
185
|
* Will automatically connect (before the test) and disconnect (after the test) the databox.
|
|
246
186
|
*/
|
|
247
187
|
databox(identifier, member, options = {}) {
|
|
@@ -252,12 +192,10 @@ class AbstractClientAsserter {
|
|
|
252
192
|
yield db.connect(member);
|
|
253
193
|
}
|
|
254
194
|
catch (err) {
|
|
255
|
-
assert.fail("Cannot connect the databox. Error -> " + err
|
|
195
|
+
assert.fail("Cannot connect the databox. Error -> " + err);
|
|
256
196
|
}
|
|
257
197
|
}));
|
|
258
|
-
this._test.afterTest(() =>
|
|
259
|
-
yield db.disconnect();
|
|
260
|
-
}));
|
|
198
|
+
this._test.afterTest(() => db.disconnect());
|
|
261
199
|
return db;
|
|
262
200
|
});
|
|
263
201
|
return new databoxAsserter_1.DataboxAsserter(databoxes, this._test, this.self());
|
|
@@ -265,7 +203,7 @@ class AbstractClientAsserter {
|
|
|
265
203
|
// noinspection JSUnusedGlobalSymbols
|
|
266
204
|
/**
|
|
267
205
|
* @description
|
|
268
|
-
*
|
|
206
|
+
* Create assertions on a channel of the client.
|
|
269
207
|
* Will automatically subscribe (before the test) and unsubscribe (after the test) the channel.
|
|
270
208
|
*/
|
|
271
209
|
channel(identifier, member) {
|
|
@@ -276,12 +214,10 @@ class AbstractClientAsserter {
|
|
|
276
214
|
yield channel.subscribe(member);
|
|
277
215
|
}
|
|
278
216
|
catch (err) {
|
|
279
|
-
assert.fail("Cannot subscribe to the channel. Error -> " + err
|
|
217
|
+
assert.fail("Cannot subscribe to the channel. Error -> " + err);
|
|
280
218
|
}
|
|
281
219
|
}));
|
|
282
|
-
this._test.afterTest(() =>
|
|
283
|
-
channel.unsubscribe();
|
|
284
|
-
});
|
|
220
|
+
this._test.afterTest(() => channel.unsubscribe());
|
|
285
221
|
return channel;
|
|
286
222
|
});
|
|
287
223
|
return new channelAsserter_1.ChannelAsserter(channels, this._test, this.self());
|
|
@@ -289,54 +225,16 @@ class AbstractClientAsserter {
|
|
|
289
225
|
// noinspection JSUnusedGlobalSymbols
|
|
290
226
|
/**
|
|
291
227
|
* @description
|
|
292
|
-
*
|
|
293
|
-
*
|
|
294
|
-
*
|
|
295
|
-
* @param message if not provided it throws the specific error.
|
|
296
|
-
*/
|
|
297
|
-
action(action, message) {
|
|
298
|
-
this.clients.forEach((client, index) => {
|
|
299
|
-
actionUtils_1.default.action(this._test, () => action(client, index), message);
|
|
300
|
-
});
|
|
301
|
-
this._test.pushSyncWait();
|
|
302
|
-
return this.self();
|
|
303
|
-
}
|
|
304
|
-
// noinspection JSUnusedGlobalSymbols
|
|
305
|
-
/**
|
|
306
|
-
* @description
|
|
307
|
-
* This function lets you do extra actions on each client and
|
|
308
|
-
* asserts that an error or an error instance of a specific class is thrown.
|
|
309
|
-
* When no error is thrown, or the error does not match with the given classes
|
|
310
|
-
* (only if at least one class is given), it lets the test fail with the provided message.
|
|
228
|
+
* Runs a extra test action and asserts that no error will be thrown.
|
|
229
|
+
* AssertionErrors will be rethrown, and all other errors will fail
|
|
230
|
+
* the test with the provided message or the concrete error.
|
|
311
231
|
* @param action
|
|
312
|
-
* @param
|
|
313
|
-
* @param validErrorClasses
|
|
232
|
+
* @param failMsg If not provided, the concrete error is used.
|
|
314
233
|
*/
|
|
315
|
-
|
|
316
|
-
this.
|
|
317
|
-
actionUtils_1.default.actionShouldThrow(this._test, () => action(client, index), message, ...validErrorClasses);
|
|
318
|
-
});
|
|
234
|
+
action(action, failMsg) {
|
|
235
|
+
this._test.test(() => this._forEachClient((client, index) => actionUtils_1.default.runAction(() => action(client, index), failMsg)));
|
|
319
236
|
this._test.pushSyncWait();
|
|
320
237
|
return this.self();
|
|
321
238
|
}
|
|
322
|
-
// noinspection JSUnusedGlobalSymbols
|
|
323
|
-
/**
|
|
324
|
-
* @description
|
|
325
|
-
* Assert that the client should receive an emit-event from the server.
|
|
326
|
-
* It uses the custom zation event namespace
|
|
327
|
-
* (so you cannot have name conflicts with internal event names).
|
|
328
|
-
*/
|
|
329
|
-
receiveEvent(event, responder = (resp) => {
|
|
330
|
-
resp(null);
|
|
331
|
-
}) {
|
|
332
|
-
return new dataEventAsserter_1.DataEventAsserter(this.clients.map(c => {
|
|
333
|
-
return (listener) => {
|
|
334
|
-
c.once(event, (data, response) => {
|
|
335
|
-
listener(data);
|
|
336
|
-
responder(response, data);
|
|
337
|
-
});
|
|
338
|
-
};
|
|
339
|
-
}), "Client", event, this._test, this.self());
|
|
340
|
-
}
|
|
341
239
|
}
|
|
342
240
|
exports.AbstractClientAsserter = AbstractClientAsserter;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { Client } from 'zation-client';
|
|
2
2
|
import { AbstractClientAsserter } from "./abstractClientAsserter";
|
|
3
3
|
import { Test } from "../../test/test";
|
|
4
|
-
export declare class ClientAsserter<T
|
|
4
|
+
export declare class ClientAsserter<T, C extends Client<any, any>> extends AbstractClientAsserter<ClientAsserter<T, C>, C> {
|
|
5
5
|
private readonly _source;
|
|
6
|
-
constructor(clients:
|
|
6
|
+
constructor(clients: C[], test: Test, source: T);
|
|
7
7
|
/**
|
|
8
8
|
* @description
|
|
9
9
|
* End the client asserter.
|
|
10
10
|
*/
|
|
11
11
|
end(): T;
|
|
12
|
-
protected self(): ClientAsserter<T>;
|
|
12
|
+
protected self(): ClientAsserter<T, C>;
|
|
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.ClientAsserter = void 0;
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { Client } from 'zation-client';
|
|
2
2
|
import { AbstractClientAsserter } from "./abstractClientAsserter";
|
|
3
|
-
export declare class StandaloneClientAsserter extends AbstractClientAsserter<StandaloneClientAsserter> {
|
|
4
|
-
constructor(client:
|
|
3
|
+
export declare class StandaloneClientAsserter<C extends Client<any, any>> extends AbstractClientAsserter<StandaloneClientAsserter<C>, C> {
|
|
4
|
+
constructor(client: C | C[], description?: string);
|
|
5
5
|
/**
|
|
6
6
|
* @description
|
|
7
|
-
*
|
|
7
|
+
* Connects all clients (before the test).
|
|
8
8
|
*/
|
|
9
|
-
connect(): StandaloneClientAsserter
|
|
9
|
+
connect(): StandaloneClientAsserter<C>;
|
|
10
10
|
/**
|
|
11
11
|
* @description
|
|
12
12
|
* Run the test.
|
|
13
13
|
*/
|
|
14
14
|
test(): Promise<void>;
|
|
15
|
-
protected self(): StandaloneClientAsserter
|
|
15
|
+
protected self(): StandaloneClientAsserter<C>;
|
|
16
16
|
}
|