@iobroker/testing 5.0.2 → 5.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/tests/integration/lib/adapterSetup.js +1 -3
- package/build/tests/integration/lib/dbConnection.d.ts +3 -2
- package/build/tests/integration/lib/dbConnection.js +10 -2
- package/build/tests/unit/mocks/mockAdapter.js +2 -3
- package/build/tests/unit/mocks/mockDatabase.js +2 -3
- package/package.json +7 -7
|
@@ -38,8 +38,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
39
|
exports.AdapterSetup = void 0;
|
|
40
40
|
// Add debug logging for tests
|
|
41
|
-
// @ts-expect-error no types
|
|
42
|
-
const objects_1 = require("alcalzone-shared/objects");
|
|
43
41
|
const debug_1 = __importDefault(require("debug"));
|
|
44
42
|
const fs_extra_1 = require("fs-extra");
|
|
45
43
|
const path = __importStar(require("path"));
|
|
@@ -100,7 +98,7 @@ class AdapterSetup {
|
|
|
100
98
|
const packageJsonPath = path.join(this.testDir, 'package.json');
|
|
101
99
|
const packageJson = await (0, fs_extra_1.readJSON)(packageJsonPath);
|
|
102
100
|
packageJson.dependencies[this.adapterFullName] = `file:./${tarballName}`;
|
|
103
|
-
for (const [dep, version] of
|
|
101
|
+
for (const [dep, version] of Object.entries((0, adapterTools_1.getAdapterDependencies)(this.adapterDir))) {
|
|
104
102
|
// Don't overwrite the js-controller GitHub dependency with a probably lower one
|
|
105
103
|
if (dep === 'js-controller') {
|
|
106
104
|
continue;
|
|
@@ -13,10 +13,11 @@ export declare class DBConnection extends EventEmitter {
|
|
|
13
13
|
/**
|
|
14
14
|
* @param appName The branded name of "iobroker"
|
|
15
15
|
* @param testDir The directory the integration tests are executed in
|
|
16
|
+
* @param logger Logger object
|
|
16
17
|
*/
|
|
17
18
|
constructor(appName: string, testDir: string, logger: ioBroker.Logger);
|
|
18
|
-
private testDataDir;
|
|
19
|
-
private testControllerDir;
|
|
19
|
+
private readonly testDataDir;
|
|
20
|
+
private readonly testControllerDir;
|
|
20
21
|
private _objectsServer;
|
|
21
22
|
private _statesServer;
|
|
22
23
|
private _objectsClient;
|
|
@@ -48,6 +48,7 @@ class DBConnection extends events_1.default {
|
|
|
48
48
|
/**
|
|
49
49
|
* @param appName The branded name of "iobroker"
|
|
50
50
|
* @param testDir The directory the integration tests are executed in
|
|
51
|
+
* @param logger Logger object
|
|
51
52
|
*/
|
|
52
53
|
constructor(appName, testDir, logger) {
|
|
53
54
|
super();
|
|
@@ -85,11 +86,18 @@ class DBConnection extends events_1.default {
|
|
|
85
86
|
}
|
|
86
87
|
return this._statesClient.setStateAsync(...args);
|
|
87
88
|
});
|
|
88
|
-
this.delState = (...args) => {
|
|
89
|
+
this.delState = async (...args) => {
|
|
89
90
|
if (!this._statesClient) {
|
|
90
91
|
throw new Error('States DB is not running');
|
|
91
92
|
}
|
|
92
|
-
|
|
93
|
+
await new Promise((resolve, reject) => this._statesClient.delState(args[0], (err) => {
|
|
94
|
+
if (err) {
|
|
95
|
+
reject(err);
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
resolve();
|
|
99
|
+
}
|
|
100
|
+
}));
|
|
93
101
|
};
|
|
94
102
|
this.getObjectViewAsync = (...args) => {
|
|
95
103
|
if (!this._objectsClient) {
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createAdapterMock = createAdapterMock;
|
|
4
|
-
// @ts-expect-error no types
|
|
5
4
|
const objects_1 = require("alcalzone-shared/objects");
|
|
6
5
|
const sinon_1 = require("sinon");
|
|
7
6
|
const mockLogger_1 = require("./mockLogger");
|
|
@@ -159,7 +158,7 @@ function createAdapterMock(db, options = {}) {
|
|
|
159
158
|
}
|
|
160
159
|
const callback = getCallback(...args);
|
|
161
160
|
if (typeof callback === 'function') {
|
|
162
|
-
let objects =
|
|
161
|
+
let objects = Object.values(db.getObjects('*'));
|
|
163
162
|
objects = objects.filter(obj => obj.type === search);
|
|
164
163
|
if (startkey) {
|
|
165
164
|
objects = objects.filter(obj => obj._id >= startkey);
|
|
@@ -178,7 +177,7 @@ function createAdapterMock(db, options = {}) {
|
|
|
178
177
|
getObjectList: (({ startkey, endkey, include_docs, }, ...args) => {
|
|
179
178
|
const callback = getCallback(...args);
|
|
180
179
|
if (typeof callback === 'function') {
|
|
181
|
-
let objects =
|
|
180
|
+
let objects = Object.values(db.getObjects('*'));
|
|
182
181
|
if (startkey) {
|
|
183
182
|
objects = objects.filter(obj => obj._id >= startkey);
|
|
184
183
|
}
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.MockDatabase = void 0;
|
|
4
4
|
exports.createAsserts = createAsserts;
|
|
5
|
-
// @ts-expect-error no types
|
|
6
5
|
const objects_1 = require("alcalzone-shared/objects");
|
|
7
6
|
const str2regex_1 = require("../../../lib/str2regex");
|
|
8
7
|
const objectTemplate = Object.freeze({
|
|
@@ -113,14 +112,14 @@ class MockDatabase {
|
|
|
113
112
|
pattern = namespaceOrPattern;
|
|
114
113
|
}
|
|
115
114
|
const idRegExp = (0, str2regex_1.str2regex)(pattern);
|
|
116
|
-
return
|
|
115
|
+
return Object.fromEntries([...this.objects.entries()]
|
|
117
116
|
.filter(([id]) => idRegExp.test(id))
|
|
118
117
|
.filter(([, obj]) => type == null || obj.type === type));
|
|
119
118
|
}
|
|
120
119
|
getStates(pattern) {
|
|
121
120
|
// combines getStates and getForeignStates into one
|
|
122
121
|
const idRegExp = (0, str2regex_1.str2regex)(pattern);
|
|
123
|
-
return
|
|
122
|
+
return Object.fromEntries([...this.states.entries()].filter(([id]) => idRegExp.test(id)));
|
|
124
123
|
}
|
|
125
124
|
}
|
|
126
125
|
exports.MockDatabase = MockDatabase;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@iobroker/testing",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.4",
|
|
4
4
|
"description": "Shared utilities for adapter and module testing in ioBroker",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"types": "build/index.d.ts",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"@alcalzone/release-script": "^3.8.0",
|
|
43
43
|
"@alcalzone/release-script-plugin-license": "^3.7.0",
|
|
44
44
|
"@iobroker/adapter-core": "^3.2.3",
|
|
45
|
-
"@iobroker/eslint-config": "^
|
|
45
|
+
"@iobroker/eslint-config": "^2.0.1",
|
|
46
46
|
"@iobroker/types": "^7.0.6",
|
|
47
47
|
"@tsconfig/node16": "^16.1.3",
|
|
48
48
|
"@types/chai": "^4.3.20",
|
|
@@ -50,13 +50,13 @@
|
|
|
50
50
|
"@types/debug": "4.1.12",
|
|
51
51
|
"@types/fs-extra": "^11.0.4",
|
|
52
52
|
"@types/mocha": "^10.0.10",
|
|
53
|
-
"@types/node": "^22.
|
|
54
|
-
"@types/sinon": "^17.0.
|
|
53
|
+
"@types/node": "^22.13.13",
|
|
54
|
+
"@types/sinon": "^17.0.4",
|
|
55
55
|
"@types/sinon-chai": "^3.2.12",
|
|
56
56
|
"rimraf": "^6.0.1",
|
|
57
57
|
"source-map-support": "^0.5.21",
|
|
58
58
|
"ts-node": "^10.9.2",
|
|
59
|
-
"typescript": "~5.
|
|
59
|
+
"typescript": "~5.8.2"
|
|
60
60
|
},
|
|
61
61
|
"dependencies": {
|
|
62
62
|
"alcalzone-shared": "~5.0.0",
|
|
@@ -64,8 +64,8 @@
|
|
|
64
64
|
"chai-as-promised": "^7.1.2",
|
|
65
65
|
"debug": "^4.4.0",
|
|
66
66
|
"fs-extra": "^11.3.0",
|
|
67
|
-
"mocha": "^11.0
|
|
68
|
-
"sinon": "^19.0.
|
|
67
|
+
"mocha": "^11.1.0",
|
|
68
|
+
"sinon": "^19.0.4",
|
|
69
69
|
"sinon-chai": "^3.7.0"
|
|
70
70
|
}
|
|
71
71
|
}
|