mirror of
https://github.com/Koenkk/zigbee2mqtt.git
synced 2026-07-03 02:21:38 +00:00
bb6c226d55
* 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
49 lines
1.3 KiB
JavaScript
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));
|
|
});
|
|
});
|
|
});
|