@iobroker/legacy-testing 0.0.3 → 0.1.0
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 +7 -1
- package/package.json +1 -1
- package/tests/testPackageFiles.js +99 -0
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.
|
|
7
|
+
1. add to package.json=>devDependencies: `"@iobroker/legacy-testing": "^0.0.4"`
|
|
8
8
|
2. Remove from package.json=>devDependencies: `chai` and `mocha`
|
|
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.0 (2022-12-22)
|
|
15
|
+
* (bluefox) Corrected testPackageFiles.js
|
|
16
|
+
|
|
17
|
+
### 0.0.4 (2022-11-21)
|
|
18
|
+
* (bluefox) Added testPackageFiles.js
|
|
19
|
+
|
|
14
20
|
### 0.0.3 (2022-11-21)
|
|
15
21
|
* (bluefox) initial release
|
|
16
22
|
|
package/package.json
CHANGED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/* jshint -W097 */
|
|
2
|
+
/* jshint strict:false */
|
|
3
|
+
/* jslint node: true */
|
|
4
|
+
/* jshint expr: true */
|
|
5
|
+
'use strict';
|
|
6
|
+
|
|
7
|
+
const expect = require('chai').expect;
|
|
8
|
+
const fs = require('fs');
|
|
9
|
+
|
|
10
|
+
// node_modules/@iobroker/legacy-testing/tests/testPackageFiles.js
|
|
11
|
+
const adapterDir = `${__dirname}/../../../../`;
|
|
12
|
+
|
|
13
|
+
describe('Test package.json and io-package.json', () => {
|
|
14
|
+
it('Test package files', done => {
|
|
15
|
+
console.log();
|
|
16
|
+
|
|
17
|
+
const fileContentIOPackage = fs.readFileSync(`${adapterDir}/io-package.json`, 'utf8');
|
|
18
|
+
const ioPackage = JSON.parse(fileContentIOPackage);
|
|
19
|
+
|
|
20
|
+
const fileContentNPMPackage = fs.readFileSync(`${adapterDir}/package.json`, 'utf8');
|
|
21
|
+
const npmPackage = JSON.parse(fileContentNPMPackage);
|
|
22
|
+
|
|
23
|
+
expect(ioPackage).to.be.an('object');
|
|
24
|
+
expect(npmPackage).to.be.an('object');
|
|
25
|
+
|
|
26
|
+
expect(ioPackage.common.version, 'ERROR: Version number in io-package.json needs to exist').to.exist;
|
|
27
|
+
expect(npmPackage.version, 'ERROR: Version number in package.json needs to exist').to.exist;
|
|
28
|
+
|
|
29
|
+
expect(ioPackage.common.version, 'ERROR: Version numbers in package.json and io-package.json needs to match').to.be.equal(npmPackage.version);
|
|
30
|
+
|
|
31
|
+
if (!ioPackage.common.news || !ioPackage.common.news[ioPackage.common.version]) {
|
|
32
|
+
console.log('WARNING: No news entry for current version exists in io-package.json, no rollback in Admin possible!');
|
|
33
|
+
console.log();
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
expect(npmPackage.author, 'ERROR: Author in package.json needs to exist').to.exist;
|
|
37
|
+
expect(ioPackage.common.authors, 'ERROR: Authors in io-package.json needs to exist').to.exist;
|
|
38
|
+
|
|
39
|
+
expect(ioPackage.common.license, 'ERROR: License missing in io-package in common.license').to.exist;
|
|
40
|
+
|
|
41
|
+
if (ioPackage.common.name.includes('template')) {
|
|
42
|
+
if (Array.isArray(ioPackage.common.authors)) {
|
|
43
|
+
expect(ioPackage.common.authors.length, 'ERROR: Author in io-package.json needs to be set').to.not.be.equal(0);
|
|
44
|
+
if (ioPackage.common.authors.length === 1) {
|
|
45
|
+
expect(ioPackage.common.authors[0], 'ERROR: Author in io-package.json needs to be a real name').to.not.be.equal('my Name <my@email.com>');
|
|
46
|
+
}
|
|
47
|
+
} else {
|
|
48
|
+
expect(ioPackage.common.authors, 'ERROR: Author in io-package.json needs to be a real name').to.not.be.equal('my Name <my@email.com>');
|
|
49
|
+
}
|
|
50
|
+
} else {
|
|
51
|
+
console.log('WARNING: Testing for set authors field in io-package skipped because template adapter');
|
|
52
|
+
console.log();
|
|
53
|
+
}
|
|
54
|
+
|
|
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;
|
|
56
|
+
|
|
57
|
+
if (!ioPackage.common.titleLang || typeof ioPackage.common.titleLang !== 'object') {
|
|
58
|
+
console.log('WARNING: titleLang is not existing in io-package.json. Please add');
|
|
59
|
+
console.log();
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
if (
|
|
63
|
+
ioPackage.common.title.includes('iobroker') ||
|
|
64
|
+
ioPackage.common.title.includes('ioBroker') ||
|
|
65
|
+
ioPackage.common.title.includes('adapter') ||
|
|
66
|
+
ioPackage.common.title.includes('Adapter')
|
|
67
|
+
) {
|
|
68
|
+
console.log('WARNING: title contains Adapter or ioBroker. It is clear anyway, that it is adapter for ioBroker.');
|
|
69
|
+
console.log();
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
if (!ioPackage.common.controller && !ioPackage.common.onlyWWW && !ioPackage.common.noConfig) {
|
|
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
|
+
}
|
|
77
|
+
|
|
78
|
+
const licenseFileExists = fs.existsSync(`${adapterDir}/LICENSE`);
|
|
79
|
+
const fileContentReadme = fs.readFileSync(`${adapterDir}/README.md`, 'utf8');
|
|
80
|
+
|
|
81
|
+
if (!fileContentReadme.includes('## Changelog')) {
|
|
82
|
+
console.log('Warning: The README.md should have a section ## Changelog');
|
|
83
|
+
console.log();
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
expect((licenseFileExists || fileContentReadme.includes('## License')), 'A LICENSE must exist as LICENSE file or as part of the README.md').to.be.true;
|
|
87
|
+
|
|
88
|
+
if (!licenseFileExists) {
|
|
89
|
+
console.log('Warning: The License should also exist as LICENSE file');
|
|
90
|
+
console.log();
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
if (!fileContentReadme.includes('## License')) {
|
|
94
|
+
console.log('Warning: The README.md should also have a section ## License to be shown in Admin3');
|
|
95
|
+
console.log();
|
|
96
|
+
}
|
|
97
|
+
done();
|
|
98
|
+
});
|
|
99
|
+
});
|