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