Release v1.4.1 (#13)

* specific error when requested channel is bigger than total

* fix for multi-channel devices

* updated test expectations

* fixes with uiid api changes

* fix wrong error message

* added new test cases

* return expected error on wrong channel number

* added more devices

* version bump
This commit is contained in:
Martin M
2019-09-11 23:46:17 -03:00
committed by GitHub
parent 171faa617b
commit 024aaa8a2c
10 changed files with 190 additions and 52 deletions

View File

@@ -1,7 +1,17 @@
const delay = require('delay');
const ewelink = require('../main');
const { deviceId, deviceIdWithPower } = require('./_setup/credentials.json');
const {
singleChannelDeviceId,
deviceIdWithPower,
} = require('./_setup/credentials.json');
describe('invalid credentials', () => {
beforeEach(async () => {
await delay(1000);
});
test('no credentials given', async () => {
const conn = new ewelink({});
expect(typeof conn).toBe('object');
@@ -26,7 +36,7 @@ describe('invalid credentials', () => {
test('get error response on specific device', async () => {
const conn = new ewelink({ email: 'invalid', password: 'credentials' });
const device = await conn.getDevice(deviceId);
const device = await conn.getDevice(singleChannelDeviceId);
expect(typeof device).toBe('object');
expect(device.msg).toBe('Authentication error');
expect(device.error).toBe(401);
@@ -34,7 +44,7 @@ describe('invalid credentials', () => {
test('get device power state should fail', async () => {
const conn = new ewelink({ email: 'invalid', password: 'credentials' });
const powerState = await conn.getDevicePowerState(deviceId);
const powerState = await conn.getDevicePowerState(singleChannelDeviceId);
expect(typeof powerState).toBe('object');
expect(powerState.msg).toBe('Authentication error');
expect(powerState.error).toBe(401);
@@ -43,7 +53,10 @@ describe('invalid credentials', () => {
test('set device power state should fail', async () => {
jest.setTimeout(30000);
const conn = new ewelink({ email: 'invalid', password: 'credentials' });
const powerState = await conn.setDevicePowerState(deviceId, 'on');
const powerState = await conn.setDevicePowerState(
singleChannelDeviceId,
'on'
);
expect(typeof powerState).toBe('object');
expect(powerState.msg).toBe('Authentication error');
expect(powerState.error).toBe(401);