Skip to content

Commit

Permalink
Wait for adapter to start
Browse files Browse the repository at this point in the history
  • Loading branch information
klein0r committed Nov 3, 2023
1 parent 2bf1695 commit 483cae5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 48 deletions.
3 changes: 1 addition & 2 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -716,8 +716,7 @@ class Statistics extends utils.Adapter {
}

async setupObjects(ids) {
for (let i = 0; i < ids.length; i++) {
const id = ids[i];
for (const id of ids) {
const obj = this.statDP[id];

if (obj.groupFactor && obj.groupFactor !== '0' && obj.groupFactor !== 0) {
Expand Down
59 changes: 13 additions & 46 deletions test/integration.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

const path = require('path');
const path = require('node:path');
const { tests } = require('@iobroker/testing');
const chai = require('chai');
const expect = chai.expect;
Expand Down Expand Up @@ -105,11 +105,6 @@ tests.integration(path.join(__dirname, '..'), {
await harness.stopAdapter();
});

beforeEach(async function() {
// Wait until adapter has created all objects/states
await sleep(1000);
});

it('enableStatistics - existing ID', async function () {
this.timeout(60000);

Expand Down Expand Up @@ -245,13 +240,9 @@ tests.integration(path.join(__dirname, '..'), {
await harness.stopAdapter();
});

beforeEach(async function() {
// Wait until adapter has created all objects/states
await sleep(1000);
});

it('calculation', async function () {
this.timeout(60000);
await sleep(1000);

const tempId = `${harness.adapterName}.0.temp.avg.${customNumberObjId}`;

Expand Down Expand Up @@ -352,13 +343,9 @@ tests.integration(path.join(__dirname, '..'), {
await harness.stopAdapter();
});

beforeEach(async function() {
// Wait until adapter has created all objects/states
await sleep(1000);
});

it('calculation', async function () {
this.timeout(60000);
await sleep(1000);

const saveId = `${harness.adapterName}.0.save.sumDelta.${customNumberObjId}`;
const tempId = `${harness.adapterName}.0.temp.sumDelta.${customNumberObjId}`;
Expand Down Expand Up @@ -456,13 +443,9 @@ tests.integration(path.join(__dirname, '..'), {
await harness.stopAdapter();
});

beforeEach(async function() {
// Wait until adapter has created all objects/states
await sleep(1000);
});

it('calculation', async function () {
this.timeout(60000);
await sleep(1000);

const saveId = `${harness.adapterName}.0.save.sumDelta.${customNumberObjId}`;
const tempId = `${harness.adapterName}.0.temp.sumDelta.${customNumberObjId}`;
Expand Down Expand Up @@ -568,13 +551,9 @@ tests.integration(path.join(__dirname, '..'), {
await harness.stopAdapter();
});

beforeEach(async function() {
// Wait until adapter has created all objects/states
await sleep(1000);
});

it('calculation', async function () {
this.timeout(60000);
await sleep(1000);

const saveId = `${harness.adapterName}.0.save.sumDelta.${customNumberObjId}`;
const tempId = `${harness.adapterName}.0.temp.avg.${customNumberObjId}`;
Expand Down Expand Up @@ -684,13 +663,9 @@ tests.integration(path.join(__dirname, '..'), {
await harness.stopAdapter();
});

beforeEach(async function() {
// Wait until adapter has created all objects/states
await sleep(1000);
});

it('calculation', async function () {
this.timeout(60000);
await sleep(1000);

for (let i = 1; i <= 5; i++) {
await harness.states.setStateAsync(customNumberObjId, { val: 1000 + (i * 3.3), ack: true });
Expand Down Expand Up @@ -768,13 +743,10 @@ tests.integration(path.join(__dirname, '..'), {
await harness.stopAdapter();
});

beforeEach(async function() {
// Wait until adapter has created all objects/states
await sleep(1000);
});

it('calculation', async function () {
this.timeout(60000);
await sleep(1000);

const tempId = `${harness.adapterName}.0.temp.count.${customBooleanObjId}`;

for (let i = 0; i < 10; i++) {
Expand All @@ -789,6 +761,8 @@ tests.integration(path.join(__dirname, '..'), {

it('calculation no false', async function () {
this.timeout(60000);
await sleep(1000);

const tempId = `${harness.adapterName}.0.temp.count.${customBooleanObjId}`;

for (let i = 0; i < 10; i++) {
Expand Down Expand Up @@ -861,13 +835,10 @@ tests.integration(path.join(__dirname, '..'), {
await harness.stopAdapter();
});

beforeEach(async function() {
// Wait until adapter has created all objects/states
await sleep(1000);
});

it('calculation', async function () {
this.timeout(60000);
await sleep(1000);

const tempId = `${harness.adapterName}.0.temp.sumCount.${customBooleanObjId}`;

for (let i = 0; i < 10; i++) {
Expand Down Expand Up @@ -986,13 +957,9 @@ tests.integration(path.join(__dirname, '..'), {
await harness.stopAdapter();
});

beforeEach(async function() {
// Wait until adapter has created all objects/states
await sleep(1000);
});

it('calculation', async function () {
this.timeout(60000);
await sleep(1000);

const tempId1 = `${harness.adapterName}.0.temp.sumDelta.${customNumberObjId1}`;
const tempId2 = `${harness.adapterName}.0.temp.sumDelta.${customNumberObjId2}`;
Expand Down

0 comments on commit 483cae5

Please sign in to comment.