Update packages

This commit is contained in:
GermanBluefox
2026-03-31 17:00:15 +02:00
parent 7bf04e494a
commit 92140fe771
17 changed files with 13927 additions and 8128 deletions
+26 -88
View File
@@ -1,107 +1,45 @@
/* jshint -W097 */// jshint strict:false
/*jslint node: true */
var expect = require('chai').expect;
var setup = require(__dirname + '/lib/setup');
/* jshint -W097 */
/* jshint strict: false */
/* jslint node: true */
const setup = require('@iobroker/legacy-testing');
var objects = null;
var states = null;
var onStateChanged = null;
var onObjectChanged = null;
var sendToID = 1;
let objects = null;
let states = null;
const onStateChanged = null;
var adapterShortName = setup.adapterName.substring(setup.adapterName.indexOf('.')+1);
const adapterShortName = setup.adapterName.substring(setup.adapterName.indexOf('.') + 1);
function checkConnectionOfAdapter(cb, counter) {
counter = counter || 0;
console.log('Try check #' + counter);
if (counter > 30) {
if (cb) cb('Cannot check connection');
return;
}
states.getState('system.adapter.' + adapterShortName + '.0.alive', function (err, state) {
if (err) console.error(err);
if (state && state.val) {
if (cb) cb();
} else {
setTimeout(function () {
checkConnectionOfAdapter(cb, counter + 1);
}, 1000);
}
});
}
function checkValueOfState(id, value, cb, counter) {
counter = counter || 0;
if (counter > 20) {
if (cb) cb('Cannot check value Of State ' + id);
return;
}
states.getState(id, function (err, state) {
if (err) console.error(err);
if (value === null && !state) {
if (cb) cb();
} else
if (state && (value === undefined || state.val === value)) {
if (cb) cb();
} else {
setTimeout(function () {
checkValueOfState(id, value, cb, counter + 1);
}, 500);
}
});
}
function sendTo(target, command, message, callback) {
onStateChanged = function (id, state) {
if (id === 'messagebox.system.adapter.test.0') {
callback(state.message);
}
};
states.pushMessage('system.adapter.' + target, {
command: command,
message: message,
from: 'system.adapter.test.0',
callback: {
message: message,
id: sendToID++,
ack: false,
time: (new Date()).getTime()
}
});
}
describe('Test ' + adapterShortName + ' adapter', function() {
before('Test ' + adapterShortName + ' adapter: Start js-controller', function (_done) {
describe(`Test ${adapterShortName} adapter`, function () {
before(`Test ${adapterShortName} adapter: Start js-controller`, function (_done) {
this.timeout(600000); // because of first install from npm
setup.setupController(async function () {
var config = await setup.getAdapterConfig();
setup.setupController(async () => {
const config = await setup.getAdapterConfig();
// enable adapter
config.common.enabled = true;
config.common.enabled = true;
config.common.loglevel = 'debug';
//config.native.dbtype = 'sqlite';
await setup.setAdapterConfig(config.common, config.native);
setup.startController(true, function(id, obj) {}, function (id, state) {
if (onStateChanged) onStateChanged(id, state);
},
function (_objects, _states) {
setup.startController(
true,
(id, obj) => {},
(id, state) => onStateChanged?.(id, state),
(_objects, _states) => {
objects = _objects;
states = _states;
states = _states;
_done();
});
},
);
});
});
/*
/*
ENABLE THIS WHEN ADAPTER RUNS IN DEAMON MODE TO CHECK THAT IT HAS STARTED SUCCESSFULLY
*/
/*
/*
it('Test ' + adapterShortName + ' adapter: Check if connected', function (done) {
this.timeout(60000);
setTimeout(function () {
@@ -115,11 +53,11 @@ describe('Test ' + adapterShortName + ' adapter', function() {
}, 5000);
});
*/
after('Test ' + adapterShortName + ' adapter: Stop js-controller', function (done) {
after(`Test ${adapterShortName} adapter: Stop js-controller`, function (done) {
this.timeout(10000);
setup.stopController(function (normalTerminated) {
console.log('Adapter normal terminated: ' + normalTerminated);
setup.stopController(normalTerminated => {
console.log(`Adapter normal terminated: ${normalTerminated}`);
done();
});
});