zigbee2mqtt/test/deviceAvailability.test.js

47 lines
1.3 KiB
JavaScript
Raw Normal View History

2019-02-13 12:55:14 -07:00
const Availability = require('../lib/extension/deviceAvailability');
const utils = require('./utils');
2019-02-02 10:15:03 -07:00
describe('Availability', () => {
let availability;
beforeEach(() => {
2019-03-09 15:34:19 -07:00
utils.stubLogger(jest);
2019-02-02 10:15:03 -07:00
availability = new Availability(null, null, null, () => {});
});
afterEach(() => {
2019-03-09 15:34:19 -07:00
jest.restoreAllMocks();
});
describe('Determine pingable devices', () => {
it('Router device should be a pingable device', () => {
const device = {
powerSource: 'Mains (single phase)',
type: 'Router',
};
expect(availability.isPingable(device)).toBe(true);
});
it('Battery device should not be a pingable device', () => {
const device = {
powerSource: 'Battery',
type: 'EndDevice',
};
expect(availability.isPingable(device)).toBe(false);
});
it('E11-G13 should be a pingable device', () => {
const device = {
powerSource: 'Mains (single phase)',
type: 'EndDevice',
modelId: 'E11-G13',
manufId: 4448,
};
expect(availability.isPingable(device)).toBe(true);
});
});
});