Files
ewelink-api/test/user.spec.js
Martin M 098011b285 Release v2.0.0 (#44)
* Added arpTableSolver (#18)

* Added arpTableSolver

* fix package import

* linting class

* changed arp library

* refactor arp class

* using arpping fork

* refactor arpTableSolver class

* Added Zero Conf functionality (LAN mode) (#46)

* added crypto-js

* zeroconf helper functions

* zeroconf update payload

* new method to save devices cache file

* class renamed

* refactor Zeroconf class

* return cached device if exists

* moved method to get local ip address

* fix mac addresses without leading zeroes

* refactor Zeroconf class

* using new zeroconf functionality

* zeroconf working with single and multichannel devices

* save device mixin enhancement

* working on zeroconf test cases

* catch errors on filesystem methods

* zeroconf: added extra test cases

* better error handling

* zeroconf: 100% code coverage

* removed deprecated login method

* updates on credentials file

* version bump

* Docs for v2.0 (#52)

* added v1 docs

* added zeroconf docs

* updated readme

* docs updated

* removed zeroconf article warning

* updated vscode config

Co-authored-by: Luis Llamas <luisllamas@hotmail.com>
2020-01-11 01:39:29 -03:00

38 lines
1.3 KiB
JavaScript

const ewelink = require('../main');
const { email, password, region } = require('./_setup/credentials.js');
const { regionExpectations } = require('./_setup/expectations');
describe('check user information', () => {
test('region should be returned', async () => {
const connection = new ewelink({ email, password });
const response = await connection.getRegion();
expect(response).toMatchObject(regionExpectations);
expect(typeof response).toBe('object');
expect(response.email).toBe(email);
expect(response.region).toBe(region);
});
test('invalid credentials should fail', async () => {
const connection = new ewelink({
email: 'invalid',
password: 'credentials',
});
const response = await connection.getRegion();
expect(typeof response).toBe('object');
expect(response.msg).toBe('Authentication error');
expect(response.error).toBe(400);
});
test('invalid initialization should warn user', async () => {
const connection = new ewelink({ at: 'access token' });
const response = await connection.getRegion();
expect(typeof response).toBe('object');
expect(response.msg).toBe(
'Library needs to be initialized using email and password'
);
expect(response.error).toBe(406);
});
});