zation-assured 3.0.0-dev.1 → 3.0.0-dev.5

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.
@@ -1,6 +1,6 @@
1
1
  import { StandaloneClientAsserter } from "../helper/asserter/client/standaloneClientAsserter";
2
2
  import { Channel, Databox, Client, Response } from "zation-client";
3
- import { ForintQuery } from "forint";
3
+ import { Query } from "queric";
4
4
  import { StandaloneDataboxAsserter } from "../helper/asserter/databox/standaloneDataboxAsserter";
5
5
  import { StandaloneChannelAsserter } from "../helper/asserter/channel/standaloneChannelAsserter";
6
6
  import { StandaloneValueAsserter } from "../helper/asserter/value/standaloneValueAsserter";
@@ -46,19 +46,19 @@ export declare const assert: {
46
46
  */
47
47
  channel: <C extends Channel<any, any>>(channel: C | C[], description?: string) => StandaloneChannelAsserter<C>;
48
48
  /**
49
- * Asserts that the promise rejects an error that matches with the forint query.
49
+ * Asserts that the promise rejects an error that matches with the queric query.
50
50
  * @param promise
51
51
  * @param query
52
52
  * @param message
53
53
  */
54
- rejects: (promise: Promise<any>, query: ForintQuery, message?: string | Error) => Promise<void>;
54
+ rejects: (promise: Promise<any>, query: Query, message?: string | Error) => Promise<void>;
55
55
  /**
56
- * Asserts that the promise resolves with a result that matches with the forint query.
56
+ * Asserts that the promise resolves with a result that matches with the queric query.
57
57
  * @param promise
58
58
  * @param query
59
59
  * @param message
60
60
  */
61
- resolves: (promise: Promise<any>, query: ForintQuery, message?: string | Error) => Promise<void>;
61
+ resolves: (promise: Promise<any>, query: Query, message?: string | Error) => Promise<void>;
62
62
  /**
63
63
  * Lets the test failing.
64
64
  * @param message
@@ -8,7 +8,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
8
8
  exports.assert = void 0;
9
9
  const assertFunc = require("assert");
10
10
  const standaloneClientAsserter_1 = require("../helper/asserter/client/standaloneClientAsserter");
11
- const forint_1 = require("forint");
11
+ const queric_1 = require("queric");
12
12
  const standaloneDataboxAsserter_1 = require("../helper/asserter/databox/standaloneDataboxAsserter");
13
13
  const standaloneChannelAsserter_1 = require("../helper/asserter/channel/standaloneChannelAsserter");
14
14
  const standaloneValueAsserter_1 = require("../helper/asserter/value/standaloneValueAsserter");
@@ -37,7 +37,7 @@ exports.assert.rejects = (promise, query, message) => {
37
37
  assertFunc.fail(message);
38
38
  r();
39
39
  }, (err) => {
40
- (0, exports.assert)((0, forint_1.default)(query)(err), message);
40
+ (0, exports.assert)((0, queric_1.default)(query)(err), message);
41
41
  r();
42
42
  });
43
43
  });
@@ -45,7 +45,7 @@ exports.assert.rejects = (promise, query, message) => {
45
45
  exports.assert.resolves = (promise, query, message) => {
46
46
  return new Promise(r => {
47
47
  promise.then((res) => {
48
- (0, exports.assert)((0, forint_1.default)(query)(res), message);
48
+ (0, exports.assert)((0, queric_1.default)(query)(res), message);
49
49
  r();
50
50
  }, () => {
51
51
  assertFunc.fail(message);
@@ -10,7 +10,7 @@ export declare class WhenBuilder<C extends Client<any, any>> {
10
10
  private readonly _client;
11
11
  private readonly _test;
12
12
  constructor(client: C, test: Test);
13
- static when<C extends Client<any, any>>(client: C, itShould?: string): WhenBuilder<C>;
13
+ static when<C extends Client<any, any>>(client: C, it?: string): WhenBuilder<C>;
14
14
  /**
15
15
  * @description
16
16
  * Creates a request test action.
@@ -15,8 +15,8 @@ class WhenBuilder {
15
15
  this._client = client;
16
16
  this._test = test;
17
17
  }
18
- static when(client, itShould) {
19
- return new WhenBuilder(client, new test_1.Test(itShould));
18
+ static when(client, it) {
19
+ return new WhenBuilder(client, new test_1.Test(it));
20
20
  }
21
21
  // noinspection JSUnusedGlobalSymbols
22
22
  /**
@@ -9,7 +9,7 @@ export declare class StandaloneChannelAsserter<C extends Channel<any, any>> exte
9
9
  subscribe(member?: any): StandaloneChannelAsserter<C>;
10
10
  /**
11
11
  * @description
12
- * Run the test.
12
+ * Runs the test.
13
13
  */
14
14
  test(): Promise<void>;
15
15
  protected self(): StandaloneChannelAsserter<C>;
@@ -43,7 +43,7 @@ class StandaloneChannelAsserter extends abstractChannelAsserter_1.AbstractChanne
43
43
  // noinspection JSUnusedGlobalSymbols
44
44
  /**
45
45
  * @description
46
- * Run the test.
46
+ * Runs the test.
47
47
  */
48
48
  test() {
49
49
  return __awaiter(this, void 0, void 0, function* () {
@@ -9,7 +9,7 @@ export declare class StandaloneClientAsserter<C extends Client<any, any>> extend
9
9
  connect(): StandaloneClientAsserter<C>;
10
10
  /**
11
11
  * @description
12
- * Run the test.
12
+ * Runs the test.
13
13
  */
14
14
  test(): Promise<void>;
15
15
  protected self(): StandaloneClientAsserter<C>;
@@ -43,7 +43,7 @@ class StandaloneClientAsserter extends abstractClientAsserter_1.AbstractClientAs
43
43
  // noinspection JSUnusedGlobalSymbols
44
44
  /**
45
45
  * @description
46
- * Run the test.
46
+ * Runs the test.
47
47
  */
48
48
  test() {
49
49
  return __awaiter(this, void 0, void 0, function* () {
@@ -39,7 +39,7 @@ export declare class IntegratedResponseAsserter<R extends Response<any>, C exten
39
39
  * @description
40
40
  * Asserts that the response has specific errors with a raw filter.
41
41
  * @param filter
42
- * Forint filter to filter for specific errors.
42
+ * Queric filter to filter for specific errors.
43
43
  */
44
44
  hasError(filter: BackErrorFilter): IntegratedResponseAsserter<R, C>;
45
45
  /**
@@ -15,6 +15,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  exports.IntegratedResponseAsserter = void 0;
18
+ const zation_client_1 = require("zation-client");
18
19
  const valueAsserter_1 = require("../value/valueAsserter");
19
20
  const backErrorsFilterBuilder_1 = require("../../backError/backErrorsFilterBuilder");
20
21
  const abstractActionAsserter_1 = require("../abstractActionAsserter");
@@ -27,7 +28,16 @@ class IntegratedResponseAsserter extends abstractActionAsserter_1.AbstractAction
27
28
  }
28
29
  _executeAction() {
29
30
  return __awaiter(this, void 0, void 0, function* () {
30
- const resp = yield this.sendRequest();
31
+ let resp;
32
+ try {
33
+ resp = yield this.sendRequest();
34
+ }
35
+ catch (err) {
36
+ if (err instanceof zation_client_1.Response)
37
+ resp = err;
38
+ else
39
+ throw err;
40
+ }
31
41
  for (let i = 0; i < this.responseAsserters.length; i++)
32
42
  yield this.responseAsserters[i](resp);
33
43
  });
@@ -3,7 +3,7 @@ import { ValueAsserter } from "../value/valueAsserter";
3
3
  import { BackErrorsFilterBuilder } from "../../backError/backErrorsFilterBuilder";
4
4
  import { ResponseData } from "../../utils/types";
5
5
  export default class StandaloneResponseAsserter<R extends Response<any>> {
6
- private readonly test;
6
+ private readonly _test;
7
7
  private readonly responses;
8
8
  constructor(response: R | R[], description?: string);
9
9
  protected _forEachResponse(func: (response: R, i: number) => Promise<void> | void): Promise<void>;
@@ -37,7 +37,7 @@ export default class StandaloneResponseAsserter<R extends Response<any>> {
37
37
  * @description
38
38
  * Asserts that the response has specific errors with a raw filter.
39
39
  * @param filter
40
- * Forint filter to filter for specific errors.
40
+ * Queric filter to filter for specific errors.
41
41
  */
42
42
  hasError(filter: BackErrorFilter): StandaloneResponseAsserter<R>;
43
43
  /**
@@ -46,4 +46,9 @@ export default class StandaloneResponseAsserter<R extends Response<any>> {
46
46
  * @param assert
47
47
  */
48
48
  assert(assert: (resp: R) => void | Promise<void>): StandaloneResponseAsserter<R>;
49
+ /**
50
+ * @description
51
+ * Runs the test.
52
+ */
53
+ test(): Promise<void>;
49
54
  }
@@ -20,7 +20,7 @@ const backErrorsFilterBuilder_1 = require("../../backError/backErrorsFilterBuild
20
20
  const assert = require('assert');
21
21
  class StandaloneResponseAsserter {
22
22
  constructor(response, description) {
23
- this.test = new test_1.Test(description);
23
+ this._test = new test_1.Test(description);
24
24
  this.responses = Array.isArray(response) ? response : [response];
25
25
  }
26
26
  _forEachResponse(func) {
@@ -39,7 +39,7 @@ class StandaloneResponseAsserter {
39
39
  * Asserts that the response is successful.
40
40
  */
41
41
  isSuccessful() {
42
- this.test.test(() => this._forEachResponse((resp, i) => __awaiter(this, void 0, void 0, function* () {
42
+ this._test.test(() => this._forEachResponse((resp, i) => __awaiter(this, void 0, void 0, function* () {
43
43
  assert(resp.successful, `Response: ${i} should be successful.` + this._respInfo(resp));
44
44
  })));
45
45
  return this;
@@ -50,7 +50,7 @@ class StandaloneResponseAsserter {
50
50
  * Asserts that the response is not successful.
51
51
  */
52
52
  isNotSuccessful() {
53
- this.test.test(() => this._forEachResponse((resp, i) => __awaiter(this, void 0, void 0, function* () {
53
+ this._test.test(() => this._forEachResponse((resp, i) => __awaiter(this, void 0, void 0, function* () {
54
54
  assert(!resp.successful, `Response: ${i} should be not successful.` + this._respInfo(resp));
55
55
  })));
56
56
  return this;
@@ -61,7 +61,7 @@ class StandaloneResponseAsserter {
61
61
  * Asserts that the response has a result.
62
62
  */
63
63
  hasResult() {
64
- this.test.test(() => this._forEachResponse((resp, i) => __awaiter(this, void 0, void 0, function* () {
64
+ this._test.test(() => this._forEachResponse((resp, i) => __awaiter(this, void 0, void 0, function* () {
65
65
  assert(resp.result != null, `Response: ${i} should have a result.`
66
66
  + this._respInfo(resp));
67
67
  })));
@@ -74,14 +74,14 @@ class StandaloneResponseAsserter {
74
74
  */
75
75
  result() {
76
76
  return new valueAsserter_1.ValueAsserter(this, (test) => {
77
- this.test.test(() => this._forEachResponse((resp, i) => __awaiter(this, void 0, void 0, function* () {
77
+ this._test.test(() => this._forEachResponse((resp, i) => __awaiter(this, void 0, void 0, function* () {
78
78
  test(resp.result, `response: ${i} result`);
79
79
  })));
80
80
  });
81
81
  }
82
82
  hasError(filter) {
83
83
  if (filter !== undefined) {
84
- this.test.test(() => this._forEachResponse((resp, i) => __awaiter(this, void 0, void 0, function* () {
84
+ this._test.test(() => this._forEachResponse((resp, i) => __awaiter(this, void 0, void 0, function* () {
85
85
  assert(resp.filter(filter).length > 0, `Response: ${i} should have at least one back error that matches the filter: ${JSON.stringify(filter)}.`
86
86
  + this._respInfo(resp));
87
87
  })));
@@ -99,10 +99,20 @@ class StandaloneResponseAsserter {
99
99
  * @param assert
100
100
  */
101
101
  assert(assert) {
102
- this.test.test(() => this._forEachResponse((resp) => __awaiter(this, void 0, void 0, function* () {
102
+ this._test.test(() => this._forEachResponse((resp) => __awaiter(this, void 0, void 0, function* () {
103
103
  yield assert(resp);
104
104
  })));
105
105
  return this;
106
106
  }
107
+ // noinspection JSUnusedGlobalSymbols
108
+ /**
109
+ * @description
110
+ * Runs the test.
111
+ */
112
+ test() {
113
+ return __awaiter(this, void 0, void 0, function* () {
114
+ return this._test.execute();
115
+ });
116
+ }
107
117
  }
108
118
  exports.default = StandaloneResponseAsserter;
@@ -3,7 +3,7 @@ import { Databox, DataEventReason, DbStorage } from 'zation-client';
3
3
  import { DataEventAsserter } from "../event/dataEventAsserter";
4
4
  import { ValueAsserter } from "../value/valueAsserter";
5
5
  import { CodeMetadataEventAsserter } from "../event/codeMetadataEventAsserter";
6
- import { ForintQuery } from "forint";
6
+ import { Query } from "queric";
7
7
  import { DataboxData, DataboxFetchData, DataboxMember } from "../../utils/types";
8
8
  import { DeepReadonly } from "../../utils/types";
9
9
  export declare abstract class AbstractDataboxAsserter<T, D extends Databox<any, any, any, any>> {
@@ -50,15 +50,15 @@ export declare abstract class AbstractDataboxAsserter<T, D extends Databox<any,
50
50
  /**
51
51
  * @description
52
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 forint query.
53
+ * It is also possible to filter for specific data event reasons with a queric query.
54
54
  */
55
- dataChangeTriggers(reasonFilter?: ForintQuery<DataEventReason>): DataEventAsserter<T, [DeepReadonly<DataboxData<D>>, DataEventReason, DbStorage<DataboxData<D>>], 0>;
55
+ dataChangeTriggers(reasonFilter?: Query<DataEventReason>): DataEventAsserter<T, [DeepReadonly<DataboxData<D>>, DataEventReason, DbStorage<DataboxData<D>>], 0>;
56
56
  /**
57
57
  * @description
58
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 forint query.
59
+ * It is also possible to filter for specific data event reasons with a queric query.
60
60
  */
61
- dataTouchTriggers(reasonFilter?: ForintQuery<DataEventReason>): DataEventAsserter<T, [DeepReadonly<DataboxData<D>>, DataEventReason, DbStorage<DataboxData<D>>], 0>;
61
+ dataTouchTriggers(reasonFilter?: Query<DataEventReason>): DataEventAsserter<T, [DeepReadonly<DataboxData<D>>, DataEventReason, DbStorage<DataboxData<D>>], 0>;
62
62
  /**
63
63
  * @description
64
64
  * Asserts that the databox should trigger an close event.
@@ -21,7 +21,7 @@ const dataEventAsserter_1 = require("../event/dataEventAsserter");
21
21
  const valueAsserter_1 = require("../value/valueAsserter");
22
22
  const codeMetadataEventAsserter_1 = require("../event/codeMetadataEventAsserter");
23
23
  const chai_1 = require("chai");
24
- const forint_1 = require("forint");
24
+ const queric_1 = require("queric");
25
25
  class AbstractDataboxAsserter {
26
26
  constructor(databoxes, test) {
27
27
  this._test = test;
@@ -134,10 +134,10 @@ class AbstractDataboxAsserter {
134
134
  /**
135
135
  * @description
136
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 forint query.
137
+ * It is also possible to filter for specific data event reasons with a queric query.
138
138
  */
139
139
  dataChangeTriggers(reasonFilter) {
140
- const filter = reasonFilter ? (0, forint_1.default)(reasonFilter) : () => true;
140
+ const filter = reasonFilter ? (0, queric_1.default)(reasonFilter) : () => true;
141
141
  return new dataEventAsserter_1.DataEventAsserter(this.databoxes.map(d => {
142
142
  return (listener) => {
143
143
  let handler;
@@ -154,10 +154,10 @@ class AbstractDataboxAsserter {
154
154
  /**
155
155
  * @description
156
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 forint query.
157
+ * It is also possible to filter for specific data event reasons with a queric query.
158
158
  */
159
159
  dataTouchTriggers(reasonFilter) {
160
- const filter = reasonFilter ? (0, forint_1.default)(reasonFilter) : () => true;
160
+ const filter = reasonFilter ? (0, queric_1.default)(reasonFilter) : () => true;
161
161
  return new dataEventAsserter_1.DataEventAsserter(this.databoxes.map(d => {
162
162
  return (listener) => {
163
163
  let handler;
@@ -10,7 +10,7 @@ export declare class StandaloneDataboxAsserter<D extends Databox<any, any, any,
10
10
  connect(member?: DataboxMember<D>): StandaloneDataboxAsserter<D>;
11
11
  /**
12
12
  * @description
13
- * Run the test.
13
+ * Runs the test.
14
14
  */
15
15
  test(): Promise<void>;
16
16
  protected self(): StandaloneDataboxAsserter<D>;
@@ -43,7 +43,7 @@ class StandaloneDataboxAsserter extends abstractDataboxAsserter_1.AbstractDatabo
43
43
  // noinspection JSUnusedGlobalSymbols
44
44
  /**
45
45
  * @description
46
- * Run the test.
46
+ * Runs the test.
47
47
  */
48
48
  test() {
49
49
  return __awaiter(this, void 0, void 0, function* () {
@@ -1,4 +1,4 @@
1
- import { ForintQuery } from "forint";
1
+ import { Query } from "queric";
2
2
  declare type AddTest = (test: (value: any, target: string) => void) => void;
3
3
  export declare abstract class AbstractValueAsserter<V, T> {
4
4
  protected abstract self(): T;
@@ -63,13 +63,13 @@ export declare abstract class AbstractValueAsserter<V, T> {
63
63
  */
64
64
  notDeepEqual(expectedValue: any): T;
65
65
  /**
66
- * Asserts that the value matches with a forint query.
66
+ * Asserts that the value matches with a queric query.
67
67
  */
68
- matches(query: ForintQuery<V> | ForintQuery<Record<any, any>>): T;
68
+ matches(query: Query<V> | Query<Record<any, any>>): T;
69
69
  /**
70
- * Asserts that the value not matches with a forint query.
70
+ * Asserts that the value not matches with a queric query.
71
71
  */
72
- notMatches(query: ForintQuery<V> | ForintQuery<Record<any, any>>): T;
72
+ notMatches(query: Query<V> | Query<Record<any, any>>): T;
73
73
  /**
74
74
  * @description
75
75
  * Asserts that the value has all specific keys.
@@ -15,7 +15,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  exports.AbstractValueAsserter = void 0;
18
- const forint_1 = require("forint");
18
+ const queric_1 = require("queric");
19
19
  const chai_1 = require("chai");
20
20
  class AbstractValueAsserter {
21
21
  constructor(addTest) {
@@ -141,21 +141,21 @@ class AbstractValueAsserter {
141
141
  }
142
142
  // noinspection JSUnusedGlobalSymbols
143
143
  /**
144
- * Asserts that the value matches with a forint query.
144
+ * Asserts that the value matches with a queric query.
145
145
  */
146
146
  matches(query) {
147
147
  this.addTest((inAny, target) => __awaiter(this, void 0, void 0, function* () {
148
- yield (0, chai_1.assert)((0, forint_1.default)(query)(inAny), `${target} should match with the forint query.`);
148
+ yield (0, chai_1.assert)((0, queric_1.default)(query)(inAny), `${target} should match with the queric query.`);
149
149
  }));
150
150
  return this.self();
151
151
  }
152
152
  // noinspection JSUnusedGlobalSymbols
153
153
  /**
154
- * Asserts that the value not matches with a forint query.
154
+ * Asserts that the value not matches with a queric query.
155
155
  */
156
156
  notMatches(query) {
157
157
  this.addTest((inAny, target) => __awaiter(this, void 0, void 0, function* () {
158
- yield (0, chai_1.assert)(!(0, forint_1.default)(query)(inAny), `${target} should not match with the forint query.`);
158
+ yield (0, chai_1.assert)(!(0, queric_1.default)(query)(inAny), `${target} should not match with the queric query.`);
159
159
  }));
160
160
  return this.self();
161
161
  }
@@ -2,8 +2,8 @@ declare type Action = () => Promise<void> | void;
2
2
  export declare class Test {
3
3
  private readonly _subTests;
4
4
  private currentSubTest;
5
- private readonly _description?;
6
- constructor(description?: string);
5
+ private readonly _it?;
6
+ constructor(it?: string);
7
7
  newSubTest(): void;
8
8
  beforeTest(action: Action): void;
9
9
  test(action: Action): void;
@@ -17,9 +17,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
17
17
  exports.Test = void 0;
18
18
  const waitSymbol = Symbol();
19
19
  class Test {
20
- constructor(description) {
20
+ constructor(it) {
21
21
  this._subTests = [];
22
- this._description = description;
22
+ this._it = it;
23
23
  this.newSubTest();
24
24
  }
25
25
  newSubTest() {
@@ -49,11 +49,11 @@ class Test {
49
49
  }
50
50
  execute() {
51
51
  return __awaiter(this, void 0, void 0, function* () {
52
- if (this._description != null) {
52
+ if (this._it != null) {
53
53
  if (global['it'] == null)
54
54
  throw new Error("Please install a test runner like mocha or jest.");
55
55
  return new Promise((resolve, reject) => {
56
- global['it'](this._description, () => __awaiter(this, void 0, void 0, function* () {
56
+ global['it'](this._it, () => __awaiter(this, void 0, void 0, function* () {
57
57
  try {
58
58
  yield this._run();
59
59
  resolve();
package/package.json CHANGED
@@ -1,14 +1,13 @@
1
1
  {
2
2
  "name": "zation-assured",
3
- "version": "3.0.0-dev.1",
3
+ "version": "3.0.0-dev.5",
4
4
  "license": "MIT",
5
5
  "description": "Library For Testing Zation Servers",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
8
8
  "scripts": {
9
9
  "prepublishOnly": "npm run build",
10
- "build": "gulp compile",
11
- "test": "nyc --reporter=html mocha -- ./test/**/*.test.js"
10
+ "build": "gulp compile"
12
11
  },
13
12
  "repository": {
14
13
  "type": "git",
@@ -42,8 +41,8 @@
42
41
  "@types/node": "^12.7.2",
43
42
  "chai": "^4.3.3",
44
43
  "path": "0.12.7",
45
- "zation-client": "^3.0.0-dev.3",
46
- "forint": "^0.2.1"
44
+ "zation-client": "^3.0.0-dev.9",
45
+ "queric": "^2.0.0"
47
46
  },
48
47
  "devDependencies": {
49
48
  "gulp": "4.0.0",