@iobroker/testing 4.1.3 → 5.0.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.
Files changed (41) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +2 -2
  3. package/build/index.d.ts +1 -1
  4. package/build/lib/adapterTools.d.ts +7 -2
  5. package/build/lib/adapterTools.js +47 -31
  6. package/build/lib/executeCommand.d.ts +3 -3
  7. package/build/lib/executeCommand.js +32 -32
  8. package/build/lib/str2regex.js +5 -6
  9. package/build/lib/testAdapter.d.ts +1 -0
  10. package/build/lib/testAdapter.js +1 -0
  11. package/build/tests/index.d.ts +9 -9
  12. package/build/tests/index.js +0 -1
  13. package/build/tests/integration/index.d.ts +1 -3
  14. package/build/tests/integration/index.js +46 -41
  15. package/build/tests/integration/lib/adapterSetup.d.ts +1 -1
  16. package/build/tests/integration/lib/adapterSetup.js +55 -42
  17. package/build/tests/integration/lib/controllerSetup.d.ts +1 -10
  18. package/build/tests/integration/lib/controllerSetup.js +59 -56
  19. package/build/tests/integration/lib/dbConnection.d.ts +12 -16
  20. package/build/tests/integration/lib/dbConnection.js +71 -69
  21. package/build/tests/integration/lib/harness.d.ts +9 -12
  22. package/build/tests/integration/lib/harness.js +70 -50
  23. package/build/tests/integration/lib/logger.d.ts +0 -1
  24. package/build/tests/integration/lib/logger.js +2 -4
  25. package/build/tests/integration/lib/tools.d.ts +6 -1
  26. package/build/tests/integration/lib/tools.js +32 -18
  27. package/build/tests/packageFiles/index.js +93 -77
  28. package/build/tests/unit/harness/createMocks.d.ts +3 -3
  29. package/build/tests/unit/harness/createMocks.js +1 -3
  30. package/build/tests/unit/index.js +6 -6
  31. package/build/tests/unit/mocks/mockAdapter.d.ts +3 -4
  32. package/build/tests/unit/mocks/mockAdapter.js +198 -164
  33. package/build/tests/unit/mocks/mockAdapterCore.d.ts +4 -10
  34. package/build/tests/unit/mocks/mockAdapterCore.js +24 -16
  35. package/build/tests/unit/mocks/mockDatabase.d.ts +13 -14
  36. package/build/tests/unit/mocks/mockDatabase.js +41 -45
  37. package/build/tests/unit/mocks/mockLogger.d.ts +1 -2
  38. package/build/tests/unit/mocks/mockLogger.js +2 -3
  39. package/build/tests/unit/mocks/tools.d.ts +2 -3
  40. package/build/tests/unit/mocks/tools.js +17 -15
  41. package/package.json +28 -32
@@ -1,29 +1,34 @@
1
1
  /**
2
2
  * Locates the directory where JS-Controller is installed for integration tests
3
+ *
3
4
  * @param appName The branded name of "iobroker"
4
5
  * @param testDir The directory the integration tests are executed in
5
6
  */
6
7
  export declare function getTestControllerDir(appName: string, testDir: string): string;
7
8
  /**
8
9
  * Locates the directory where JS-Controller stores its data for integration tests
10
+ *
9
11
  * @param appName The branded name of "iobroker"
10
12
  * @param testDir The directory the integration tests are executed in
11
13
  */
12
14
  export declare function getTestDataDir(appName: string, testDir: string): string;
13
15
  /**
14
16
  * Locates the directory where JS-Controller stores its logs for integration tests
17
+ *
15
18
  * @param appName The branded name of "iobroker"
16
19
  * @param testDir The directory the integration tests are executed in
17
20
  */
18
21
  export declare function getTestLogDir(appName: string, testDir: string): string;
19
22
  /**
20
23
  * Locates the directory where JS-Controller stores its sqlite db during integration tests
24
+ *
21
25
  * @param appName The branded name of "iobroker"
22
26
  * @param testDir The directory the integration tests are executed in
23
27
  */
24
28
  export declare function getTestDBDir(appName: string, testDir: string): string;
25
29
  /**
26
- * Locates the directory where the adapter will be be stored for integration tests
30
+ * Locates the directory where the adapter will be stored for integration tests
31
+ *
27
32
  * @param adapterDir The root directory of the adapter
28
33
  * @param testDir The directory the integration tests are executed in
29
34
  */
@@ -15,60 +15,74 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
15
15
  }) : function(o, v) {
16
16
  o["default"] = v;
17
17
  });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
25
35
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.getTestAdapterDir = exports.getTestDBDir = exports.getTestLogDir = exports.getTestDataDir = exports.getTestControllerDir = void 0;
36
+ exports.getTestControllerDir = getTestControllerDir;
37
+ exports.getTestDataDir = getTestDataDir;
38
+ exports.getTestLogDir = getTestLogDir;
39
+ exports.getTestDBDir = getTestDBDir;
40
+ exports.getTestAdapterDir = getTestAdapterDir;
27
41
  const path = __importStar(require("path"));
28
42
  const adapterTools_1 = require("../../../lib/adapterTools");
29
43
  /**
30
44
  * Locates the directory where JS-Controller is installed for integration tests
45
+ *
31
46
  * @param appName The branded name of "iobroker"
32
47
  * @param testDir The directory the integration tests are executed in
33
48
  */
34
49
  function getTestControllerDir(appName, testDir) {
35
- return path.resolve(testDir, "node_modules", `${appName}.js-controller`);
50
+ return path.resolve(testDir, 'node_modules', `${appName}.js-controller`);
36
51
  }
37
- exports.getTestControllerDir = getTestControllerDir;
38
52
  /**
39
53
  * Locates the directory where JS-Controller stores its data for integration tests
54
+ *
40
55
  * @param appName The branded name of "iobroker"
41
56
  * @param testDir The directory the integration tests are executed in
42
57
  */
43
58
  function getTestDataDir(appName, testDir) {
44
59
  return path.resolve(testDir, `${appName}-data`);
45
60
  }
46
- exports.getTestDataDir = getTestDataDir;
47
61
  /**
48
62
  * Locates the directory where JS-Controller stores its logs for integration tests
63
+ *
49
64
  * @param appName The branded name of "iobroker"
50
65
  * @param testDir The directory the integration tests are executed in
51
66
  */
52
67
  function getTestLogDir(appName, testDir) {
53
- return path.resolve(testDir, "log");
68
+ return path.resolve(testDir, 'log');
54
69
  }
55
- exports.getTestLogDir = getTestLogDir;
56
70
  /**
57
71
  * Locates the directory where JS-Controller stores its sqlite db during integration tests
72
+ *
58
73
  * @param appName The branded name of "iobroker"
59
74
  * @param testDir The directory the integration tests are executed in
60
75
  */
61
76
  function getTestDBDir(appName, testDir) {
62
- return path.resolve(getTestDataDir(appName, testDir), "sqlite");
77
+ return path.resolve(getTestDataDir(appName, testDir), 'sqlite');
63
78
  }
64
- exports.getTestDBDir = getTestDBDir;
65
79
  /**
66
- * Locates the directory where the adapter will be be stored for integration tests
80
+ * Locates the directory where the adapter will be stored for integration tests
81
+ *
67
82
  * @param adapterDir The root directory of the adapter
68
83
  * @param testDir The directory the integration tests are executed in
69
84
  */
70
85
  function getTestAdapterDir(adapterDir, testDir) {
71
86
  const adapterName = (0, adapterTools_1.getAdapterFullName)(adapterDir);
72
- return path.resolve(testDir, "node_modules", adapterName);
87
+ return path.resolve(testDir, 'node_modules', adapterName);
73
88
  }
74
- exports.getTestAdapterDir = getTestAdapterDir;
@@ -15,16 +15,25 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
15
15
  }) : function(o, v) {
16
16
  o["default"] = v;
17
17
  });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
25
35
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.validatePackageFiles = void 0;
27
- /* eslint-disable @typescript-eslint/no-var-requires */
36
+ exports.validatePackageFiles = validatePackageFiles;
28
37
  const typeguards_1 = require("alcalzone-shared/typeguards");
29
38
  const chai_1 = require("chai");
30
39
  const fs = __importStar(require("fs"));
@@ -34,27 +43,27 @@ const path = __importStar(require("path"));
34
43
  * This is meant to be executed in a mocha context.
35
44
  */
36
45
  function validatePackageFiles(adapterDir) {
37
- const packageJsonPath = path.join(adapterDir, "package.json");
38
- const ioPackageJsonPath = path.join(adapterDir, "io-package.json");
46
+ const packageJsonPath = path.join(adapterDir, 'package.json');
47
+ const ioPackageJsonPath = path.join(adapterDir, 'io-package.json');
39
48
  // This allows us to skip tests that require valid JSON files
40
49
  const invalidFiles = {
41
- "package.json": false,
42
- "io-package.json": false,
50
+ 'package.json': false,
51
+ 'io-package.json': false,
43
52
  };
44
53
  function skipIfInvalid(...filenames) {
45
- if (filenames.some((f) => invalidFiles[f]))
54
+ if (filenames.some(f => invalidFiles[f])) {
46
55
  return this.skip();
56
+ }
47
57
  }
48
58
  function markAsInvalid(filename) {
49
- if (this.currentTest.state === "failed" &&
50
- invalidFiles[filename] === false) {
59
+ if (this.currentTest.state === 'failed' && invalidFiles[filename] === false) {
51
60
  invalidFiles[filename] = true;
52
61
  console.error(`Skipping subsequent tests including "${filename}" because they require valid JSON files!`);
53
62
  }
54
63
  }
55
64
  /** Ensures that a given property exists on the target object */
56
65
  function ensurePropertyExists(propertyPath, targetObj) {
57
- const propertyParts = propertyPath.split(".");
66
+ const propertyParts = propertyPath.split('.');
58
67
  it(`The property "${propertyPath}" exists`, () => {
59
68
  let prev = targetObj;
60
69
  for (const part of propertyParts) {
@@ -65,7 +74,7 @@ function validatePackageFiles(adapterDir) {
65
74
  }
66
75
  describe(`Validate the package files`, () => {
67
76
  describe(`Ensure they are readable`, () => {
68
- for (const filename of ["package.json", "io-package.json"]) {
77
+ for (const filename of ['package.json', 'io-package.json']) {
69
78
  const packagePath = path.join(adapterDir, filename);
70
79
  describe(`${filename}`, () => {
71
80
  afterEach(function () {
@@ -74,41 +83,41 @@ function validatePackageFiles(adapterDir) {
74
83
  beforeEach(function () {
75
84
  skipIfInvalid.call(this, filename);
76
85
  });
77
- it("exists", () => {
86
+ it('exists', () => {
78
87
  (0, chai_1.expect)(fs.existsSync(packagePath), `${filename} is missing in the adapter dir. Please create it!`).to.be.true;
79
88
  });
80
- it("contains valid JSON", () => {
89
+ it('contains valid JSON', () => {
81
90
  (0, chai_1.expect)(() => {
82
- JSON.parse(fs.readFileSync(packagePath, "utf8"));
91
+ JSON.parse(fs.readFileSync(packagePath, 'utf8'));
83
92
  }, `${filename} contains invalid JSON!`).not.to.throw();
84
93
  });
85
- it("is an object", () => {
86
- (0, chai_1.expect)(require(packagePath), `${filename} must contain an object!`).to.be.an("object");
94
+ it('is an object', () => {
95
+ (0, chai_1.expect)(require(packagePath), `${filename} must contain an object!`).to.be.an('object');
87
96
  });
88
97
  });
89
98
  }
90
99
  });
91
100
  describe(`Check contents of package.json`, () => {
92
101
  beforeEach(function () {
93
- skipIfInvalid.call(this, "package.json");
102
+ skipIfInvalid.call(this, 'package.json');
94
103
  });
95
104
  const packageContent = require(packageJsonPath);
96
105
  const iopackContent = require(ioPackageJsonPath);
97
106
  const requiredProperties = [
98
- "name",
99
- "version",
100
- "description",
101
- "author",
102
- "license",
103
- "repository",
104
- "repository.type",
107
+ 'name',
108
+ 'version',
109
+ 'description',
110
+ 'author',
111
+ 'license',
112
+ 'repository',
113
+ 'repository.type',
105
114
  ];
106
- requiredProperties.forEach((prop) => ensurePropertyExists(prop, packageContent));
107
- it("The package name is correct", () => {
115
+ requiredProperties.forEach(prop => ensurePropertyExists(prop, packageContent));
116
+ it('The package name is correct', () => {
108
117
  let name = packageContent.name;
109
118
  (0, chai_1.expect)(name).to.match(/^iobroker\./, `The npm package name must start with lowercase "iobroker."!`);
110
- name = name.replace(/^iobroker\./, "");
111
- (0, chai_1.expect)(name).to.match(/[a-z0-9_\-]+/, `The adapter name must only contain lowercase letters, numbers, "-" and "_"!`);
119
+ name = name.replace(/^iobroker\./, '');
120
+ (0, chai_1.expect)(name).to.match(/[-a-z0-9_]+/, `The adapter name must only contain lowercase letters, numbers, "-" and "_"!`);
112
121
  (0, chai_1.expect)(name).to.match(/^[a-z]/, `The adapter name must start with a letter!`);
113
122
  (0, chai_1.expect)(name).to.match(/[a-z0-9]$/, `The adapter name must end with a letter or number!`);
114
123
  });
@@ -118,17 +127,17 @@ function validatePackageFiles(adapterDir) {
118
127
  });
119
128
  }
120
129
  it(`The repository type is "git"`, () => {
121
- (0, chai_1.expect)(packageContent.repository.type).to.equal("git");
130
+ (0, chai_1.expect)(packageContent.repository.type).to.equal('git');
122
131
  });
123
- it("npm is not listed as a dependency", () => {
132
+ it('npm is not listed as a dependency', () => {
124
133
  for (const depType of [
125
- "dependencies",
126
- "devDependencies",
127
- "optionalDependencies",
128
- "peerDependencies",
134
+ 'dependencies',
135
+ 'devDependencies',
136
+ 'optionalDependencies',
137
+ 'peerDependencies',
129
138
  ]) {
130
- if ((0, typeguards_1.isObject)(packageContent[depType]) &&
131
- "npm" in packageContent[depType]) {
139
+ if ((0, typeguards_1.isObject)(packageContent[depType]) && 'npm' in packageContent[depType]) {
140
+ // eslint-disable-next-line @typescript-eslint/only-throw-error
132
141
  throw new chai_1.AssertionError(`npm must not be listed in ${depType}, found "${packageContent[depType].npm}"!`);
133
142
  }
134
143
  }
@@ -136,29 +145,30 @@ function validatePackageFiles(adapterDir) {
136
145
  });
137
146
  describe(`Check contents of io-package.json`, () => {
138
147
  beforeEach(function () {
139
- skipIfInvalid.call(this, "io-package.json");
148
+ skipIfInvalid.call(this, 'io-package.json');
140
149
  });
141
150
  const iopackContent = require(ioPackageJsonPath);
142
151
  const requiredProperties = [
143
- "common.name",
144
- "common.titleLang",
145
- "common.version",
146
- "common.news",
147
- "common.desc",
148
- "common.icon",
149
- "common.extIcon",
150
- "common.type",
151
- "common.authors",
152
- "native",
152
+ 'common.name',
153
+ 'common.titleLang',
154
+ 'common.version',
155
+ 'common.news',
156
+ 'common.desc',
157
+ 'common.icon',
158
+ 'common.extIcon',
159
+ 'common.type',
160
+ 'common.authors',
161
+ 'native',
153
162
  ];
154
- requiredProperties.forEach((prop) => ensurePropertyExists(prop, iopackContent));
163
+ requiredProperties.forEach(prop => ensurePropertyExists(prop, iopackContent));
155
164
  it(`The title does not contain "adapter" or "iobroker"`, () => {
156
- if (!iopackContent.title)
165
+ if (!iopackContent.title) {
157
166
  return;
167
+ }
158
168
  (0, chai_1.expect)(iopackContent.common.title).not.to.match(/iobroker|adapter/i);
159
169
  });
160
170
  it(`titleLang is an object to support multiple languages`, () => {
161
- (0, chai_1.expect)(iopackContent.common.titleLang).to.be.an("object");
171
+ (0, chai_1.expect)(iopackContent.common.titleLang).to.be.an('object');
162
172
  });
163
173
  it(`titleLang does not contain "adapter" or "iobroker"`, () => {
164
174
  for (const title of Object.values(iopackContent.common.titleLang)) {
@@ -166,7 +176,7 @@ function validatePackageFiles(adapterDir) {
166
176
  }
167
177
  });
168
178
  it(`The description is an object to support multiple languages`, () => {
169
- (0, chai_1.expect)(iopackContent.common.desc).to.be.an("object");
179
+ (0, chai_1.expect)(iopackContent.common.desc).to.be.an('object');
170
180
  });
171
181
  it(`common.authors is an array that is not empty`, () => {
172
182
  const authors = iopackContent.common.authors;
@@ -180,19 +190,25 @@ function validatePackageFiles(adapterDir) {
180
190
  });
181
191
  if (iopackContent.common.licenseInformation) {
182
192
  it(`if common.licenseInformation exists, it is an object with required properties`, () => {
183
- (0, chai_1.expect)(iopackContent.common.licenseInformation).to.be.an("object");
184
- (0, chai_1.expect)(iopackContent.common.licenseInformation.type).to.be.oneOf(["free", "commercial", "paid", "limited"]);
185
- if (iopackContent.common.licenseInformation.type !== "free") {
186
- (0, chai_1.expect)(iopackContent.common.licenseInformation.link, "License link is missing").to.not.be.undefined;
193
+ (0, chai_1.expect)(iopackContent.common.licenseInformation).to.be.an('object');
194
+ (0, chai_1.expect)(iopackContent.common.licenseInformation.type).to.be.oneOf([
195
+ 'free',
196
+ 'commercial',
197
+ 'paid',
198
+ 'limited',
199
+ ]);
200
+ if (iopackContent.common.licenseInformation.type !== 'free') {
201
+ (0, chai_1.expect)(iopackContent.common.licenseInformation.link, 'License link is missing').to.not.be
202
+ .undefined;
187
203
  }
188
204
  });
189
205
  it(`common.license should not exist together with common.licenseInformation`, () => {
190
- (0, chai_1.expect)(iopackContent.common.license, "common.license must be removed").to.be.undefined;
206
+ (0, chai_1.expect)(iopackContent.common.license, 'common.license must be removed').to.be.undefined;
191
207
  });
192
208
  }
193
209
  else {
194
210
  it(`common.license must exist without common.licenseInformation`, () => {
195
- (0, chai_1.expect)(iopackContent.common.license, "common.licenseInformation (preferred) or common.license (deprecated) must exist").to.not.be.undefined;
211
+ (0, chai_1.expect)(iopackContent.common.license, 'common.licenseInformation (preferred) or common.license (deprecated) must exist').to.not.be.undefined;
196
212
  });
197
213
  }
198
214
  if (iopackContent.common.tier != undefined) {
@@ -203,31 +219,32 @@ function validatePackageFiles(adapterDir) {
203
219
  }
204
220
  // If the adapter has a configuration page, check that a supported admin UI is used
205
221
  const hasNoConfigPage = iopackContent.common.noConfig === true ||
206
- iopackContent.common.noConfig === "true" ||
207
- iopackContent.common.adminUI?.config === "none";
222
+ iopackContent.common.noConfig === 'true' ||
223
+ iopackContent.common.adminUI?.config === 'none';
208
224
  if (!hasNoConfigPage) {
209
- it("The adapter uses a supported admin UI", () => {
225
+ it('The adapter uses a supported admin UI', () => {
210
226
  const hasSupportedUI = !!iopackContent.common.materialize ||
211
- iopackContent.common.adminUI?.config === "html" ||
212
- iopackContent.common.adminUI?.config === "json" ||
213
- iopackContent.common.adminUI?.config === "materialize";
214
- (0, chai_1.expect)(hasSupportedUI, "Unsupported Admin UI, must be html, materialize or JSON config!").to.be.true;
227
+ iopackContent.common.adminUI?.config === 'html' ||
228
+ iopackContent.common.adminUI?.config === 'json' ||
229
+ iopackContent.common.adminUI?.config === 'materialize';
230
+ (0, chai_1.expect)(hasSupportedUI, 'Unsupported Admin UI, must be html, materialize or JSON config!').to.be
231
+ .true;
215
232
  });
216
233
  }
217
234
  });
218
235
  describe(`Compare contents of package.json and io-package.json`, () => {
219
236
  beforeEach(function () {
220
- skipIfInvalid.call(this, "package.json", "io-package.json");
237
+ skipIfInvalid.call(this, 'package.json', 'io-package.json');
221
238
  });
222
239
  const packageContent = require(packageJsonPath);
223
240
  const iopackContent = require(ioPackageJsonPath);
224
- it("The name matches", () => {
225
- (0, chai_1.expect)("iobroker." + iopackContent.common.name).to.equal(packageContent.name);
241
+ it('The name matches', () => {
242
+ (0, chai_1.expect)(`iobroker.${iopackContent.common.name}`).to.equal(packageContent.name);
226
243
  });
227
- it("The version matches", () => {
244
+ it('The version matches', () => {
228
245
  (0, chai_1.expect)(iopackContent.common.version).to.equal(packageContent.version);
229
246
  });
230
- it("The license matches", () => {
247
+ it('The license matches', () => {
231
248
  if (iopackContent.common.licenseInformation) {
232
249
  (0, chai_1.expect)(iopackContent.common.licenseInformation.license).to.equal(packageContent.license);
233
250
  }
@@ -255,4 +272,3 @@ function validatePackageFiles(adapterDir) {
255
272
  // });
256
273
  // });
257
274
  }
258
- exports.validatePackageFiles = validatePackageFiles;
@@ -1,10 +1,10 @@
1
- /// <reference types="iobroker" />
2
- import { MockDatabase } from "../mocks/mockDatabase";
1
+ import { type MockAdapter } from '../mocks/mockAdapter';
2
+ import { MockDatabase } from '../mocks/mockDatabase';
3
3
  /**
4
4
  * Creates a new set of mocks, including a mock database and a mock adapter.
5
5
  * To test the startup of an adapter, use `startMockAdapter` instead.
6
6
  */
7
7
  export declare function createMocks(adapterOptions: Partial<ioBroker.AdapterOptions>): {
8
8
  database: MockDatabase;
9
- adapter: import("../mocks/mockAdapter").MockAdapter;
9
+ adapter: MockAdapter;
10
10
  };
@@ -1,13 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createMocks = void 0;
3
+ exports.createMocks = createMocks;
4
4
  const mockAdapter_1 = require("../mocks/mockAdapter");
5
5
  const mockDatabase_1 = require("../mocks/mockDatabase");
6
6
  /**
7
7
  * Creates a new set of mocks, including a mock database and a mock adapter.
8
8
  * To test the startup of an adapter, use `startMockAdapter` instead.
9
9
  */
10
- // eslint-disable-next-line @typescript-eslint/explicit-function-return-type
11
10
  function createMocks(adapterOptions) {
12
11
  const databaseMock = new mockDatabase_1.MockDatabase();
13
12
  const adapterMock = mockAdapter_1.createAdapterMock.bind(undefined)(databaseMock, adapterOptions);
@@ -16,4 +15,3 @@ function createMocks(adapterOptions) {
16
15
  adapter: adapterMock,
17
16
  };
18
17
  }
19
- exports.createMocks = createMocks;
@@ -1,24 +1,24 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.testAdapterWithMocks = void 0;
3
+ exports.testAdapterWithMocks = testAdapterWithMocks;
4
4
  /**
5
5
  * @deprecated
6
6
  * Tests the adapter startup in offline mode (with mocks, no JS-Controller)
7
7
  * This is meant to be executed in a mocha context.
8
8
  */
9
9
  function testAdapterWithMocks(_adapterDir, options = {}) {
10
- describe(`Unit tests`, async () => {
10
+ describe(`Unit tests`, () => {
11
11
  // Call the user's tests
12
- if (typeof options.defineAdditionalTests === "function") {
12
+ if (typeof options.defineAdditionalTests === 'function') {
13
13
  options.defineAdditionalTests();
14
14
  }
15
15
  else {
16
- it("DEPRECATED!", () => {
17
- console.warn("\u001b[33mUnit tests for adapter startup are deprecated!");
16
+ it('DEPRECATED!', () => {
17
+ console.warn('\u001b[33mUnit tests for adapter startup are deprecated!');
18
18
  console.warn(`If you do not define your own tests, you can remove the "test:unit" script`);
19
19
  console.warn(`from package.json and from your Travis/Github Actions workflow.\u001b[0m`);
20
20
  });
21
21
  }
22
+ return Promise.resolve();
22
23
  });
23
24
  }
24
- exports.testAdapterWithMocks = testAdapterWithMocks;
@@ -1,7 +1,6 @@
1
- /// <reference types="iobroker" />
2
- import type { MockDatabase } from "./mockDatabase";
3
- import { MockLogger } from "./mockLogger";
4
- import { Mock } from "./tools";
1
+ import type { MockDatabase } from './mockDatabase';
2
+ import { type MockLogger } from './mockLogger';
3
+ import { type Mock } from './tools';
5
4
  export type MockAdapter = Mock<ioBroker.Adapter> & {
6
5
  readyHandler: ioBroker.ReadyHandler | undefined;
7
6
  objectChangeHandler: ioBroker.ObjectChangeHandler | undefined;