Files
zigbee2mqtt/test/deviceAvailability.test.js
T
Mihal Malostanidis bb6c226d55 Test improvements (#1207)
* Add missing `zcl-id` dependency

* Improve devicePublish test

Now passes in both mocha and jest
Each test now waits for all publishes, such as readbacks,
and asserts their number.
Replaced `calledOnce` and such with numeric assertion,
for a more informative error message.

* Use sinon default sandbox

* Take assert out of chai

Improves clutter, but also `jest-codemods` also makes use of this.

* Replace proxyquire with simple cache delete

* Reduce shared mutable state in settings.test
2019-03-08 16:56:53 +01:00

49 lines
1.3 KiB
JavaScript

const assert = require('chai').assert;
const sinon = require('sinon');
const Availability = require('../lib/extension/deviceAvailability');
const utils = require('./utils');
describe('Availability', () => {
let availability;
beforeEach(() => {
utils.stubLogger(sinon);
availability = new Availability(null, null, null, () => {});
});
afterEach(() => {
sinon.restore();
});
describe('Determine pingable devices', () => {
it('Router device should be a pingable device', () => {
const device = {
powerSource: 'Mains (single phase)',
type: 'Router',
};
assert.isTrue(availability.isPingable(device));
});
it('Battery device should not be a pingable device', () => {
const device = {
powerSource: 'Battery',
type: 'EndDevice',
};
assert.isFalse(availability.isPingable(device));
});
it('E11-G13 should be a pingable device', () => {
const device = {
powerSource: 'Mains (single phase)',
type: 'EndDevice',
modelId: 'E11-G13',
manufId: 4448,
};
assert.isTrue(availability.isPingable(device));
});
});
});