@iobroker/legacy-testing 0.0.4 → 0.1.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/README.md CHANGED
@@ -4,13 +4,19 @@ Legacy test modules for ioBroker
4
4
  **This is a legacy repository. Please use the new test framework `@iobroker/testing` for new adapters**
5
5
 
6
6
  ## How to replace existing tests
7
- 1. add to package.json=>devDependencies: `"@iobroker/legacy-testing": "^0.0.1"`
8
- 2. Remove from package.json=>devDependencies: `chai` and `mocha`
7
+ 1. add to package.json=>devDependencies: `"@iobroker/legacy-testing": "^0.0.4"`
8
+ 2. Remove from package.json=>devDependencies: `chai`
9
9
  3. Replace in `tests/testAdapter.js` the code `const setup = require('./lib/setup');` with `const setup = require('@iobroker/legacy-testing');`
10
10
  4. Replace whole file `tests/testPackageFiles.js` with `require('@iobroker/legacy-testing/tests/testPackageFiles');`
11
11
 
12
12
  ## Changelog
13
13
  <!-- ### **WORK IN PROGRESS** -->
14
+ ### 0.1.1 (2022-12-22)
15
+ * (bluefox) Extended testPackageFiles.js with checks
16
+
17
+ ### 0.1.0 (2022-12-22)
18
+ * (bluefox) Corrected testPackageFiles.js
19
+
14
20
  ### 0.0.4 (2022-11-21)
15
21
  * (bluefox) Added testPackageFiles.js
16
22
 
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.0.4",
2
+ "version": "0.1.1",
3
3
  "name": "@iobroker/legacy-testing",
4
4
  "main": "setup.js",
5
5
  "files": [
@@ -7,14 +7,17 @@
7
7
  const expect = require('chai').expect;
8
8
  const fs = require('fs');
9
9
 
10
+ // node_modules/@iobroker/legacy-testing/tests/testPackageFiles.js
11
+ const adapterDir = `${__dirname}/../../../../`;
12
+
10
13
  describe('Test package.json and io-package.json', () => {
11
14
  it('Test package files', done => {
12
15
  console.log();
13
16
 
14
- const fileContentIOPackage = fs.readFileSync(`${__dirname}/../io-package.json`, 'utf8');
17
+ const fileContentIOPackage = fs.readFileSync(`${adapterDir}/io-package.json`, 'utf8');
15
18
  const ioPackage = JSON.parse(fileContentIOPackage);
16
19
 
17
- const fileContentNPMPackage = fs.readFileSync(`${__dirname}/../package.json`, 'utf8');
20
+ const fileContentNPMPackage = fs.readFileSync(`${adapterDir}/package.json`, 'utf8');
18
21
  const npmPackage = JSON.parse(fileContentNPMPackage);
19
22
 
20
23
  expect(ioPackage).to.be.an('object');
@@ -49,7 +52,7 @@ describe('Test package.json and io-package.json', () => {
49
52
  console.log();
50
53
  }
51
54
 
52
- expect(fs.existsSync(`${__dirname}/../README.md`), 'ERROR: README.md needs to exist! Please create one with description, detail information and changelog. English is mandatory.').to.be.true;
55
+ expect(fs.existsSync(`${adapterDir}/README.md`), 'ERROR: README.md needs to exist! Please create one with description, detail information and changelog. English is mandatory.').to.be.true;
53
56
 
54
57
  if (!ioPackage.common.titleLang || typeof ioPackage.common.titleLang !== 'object') {
55
58
  console.log('WARNING: titleLang is not existing in io-package.json. Please add');
@@ -67,13 +70,22 @@ describe('Test package.json and io-package.json', () => {
67
70
  }
68
71
 
69
72
  if (!ioPackage.common.controller && !ioPackage.common.onlyWWW && !ioPackage.common.noConfig) {
70
- if (ioPackage.common.materialize) {
71
- expect(fs.existsSync(`${__dirname}/../admin/index_m.html`), 'Admin3 support is enabled in io-package.json, but index_m.html is missing!').to.be.true;
73
+ if (ioPackage.common.materialize || (ioPackage.common.adminUI && ioPackage.common.adminUI.conifg === 'materialize')) {
74
+ expect(fs.existsSync(`${adapterDir}/admin/index_m.html`), 'Admin3 support is enabled in io-package.json, but index_m.html is missing!').to.be.true;
75
+ }
76
+ if (ioPackage.common.jsonConfig || (ioPackage.common.adminUI && ioPackage.common.adminUI.conifg === 'json')) {
77
+ expect(fs.existsSync(`${adapterDir}/admin/jsonConfig.json`) || fs.existsSync(`${adapterDir}/admin/jsonConfig.json5`), 'Admin3 support is enabled in io-package.json, but jsonConfig.json(5) is missing!').to.be.true;
78
+ }
79
+ if (ioPackage.common.adminUI && ioPackage.common.adminUI.custom === 'json') {
80
+ expect(fs.existsSync(`${adapterDir}/admin/jsonCustom.json`) || fs.existsSync(`${adapterDir}/admin/jsonCustom.json5`), 'Custom config support is enabled in io-package.json, but jsonCustom.json(5) is missing!').to.be.true;
81
+ }
82
+ if (ioPackage.common.adminUI && ioPackage.common.adminUI.tab === 'html') {
83
+ expect(fs.existsSync(`${adapterDir}/admin/tab.html`) || fs.existsSync(`${adapterDir}/admin/tab_m.html`), 'HTML-Tab support is enabled in io-package.json, but tab(_m).html is missing!').to.be.true;
72
84
  }
73
85
  }
74
86
 
75
- const licenseFileExists = fs.existsSync(`${__dirname}/../LICENSE`);
76
- const fileContentReadme = fs.readFileSync(`${__dirname}/../README.md`, 'utf8');
87
+ const licenseFileExists = fs.existsSync(`${adapterDir}/LICENSE`);
88
+ const fileContentReadme = fs.readFileSync(`${adapterDir}/README.md`, 'utf8');
77
89
 
78
90
  if (!fileContentReadme.includes('## Changelog')) {
79
91
  console.log('Warning: The README.md should have a section ## Changelog');