Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

lifx-http-api

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lifx-http-api - npm Package Compare versions

Comparing version 1.0.1 to 1.0.2

2

dist/utils.js

@@ -34,3 +34,3 @@ 'use strict';

// Special case HTTP code 422 Unprocessable Entity
if (response.statusCode === 422) {
if (response && response.statusCode === 422) {
error = body.error;

@@ -37,0 +37,0 @@ }

{
"name": "lifx-http-api",
"version": "1.0.1",
"version": "1.0.2",
"description": "Thin wrapper around the Lifx HTTP API",

@@ -9,3 +9,4 @@ "main": "source/lifx.js",

"build": "node_modules/.bin/babel source --presets babel-preset-es2015 --out-dir dist",
"test": "npm run build && node_modules/.bin/mocha"
"test": "npm run build && node_modules/.bin/istanbul cover -root dist/ node_modules/mocha/bin/_mocha --recursive test",
"report-coverage": "node_modules/.bin/codecov"
},

@@ -42,4 +43,6 @@ "keywords": [

"chai-http": "^2.0.1",
"codecov": "^1.0.1",
"istanbul": "^0.4.2",
"mocha": "^2.4.5"
}
}
# Lifx HTTP Api Node.js Wrapper
[![NPM Version](https://img.shields.io/npm/v/lifx-http-api.svg)](https://www.npmjs.com/package/lifx-http-api) ![Dependency Status](https://david-dm.org/klarstil/lifx-http-api.svg) [![Build Status](https://travis-ci.org/klarstil/lifx-http-api.svg?branch=master)](https://travis-ci.org/klarstil/lifx-http-api) [![License MIT](https://img.shields.io/badge/license-mit-brightgreen.svg)](https://github.com/klarstil/lifx-http-api/blob/master/LICENSE)
[![NPM Version](https://img.shields.io/npm/v/lifx-http-api.svg)](https://www.npmjs.com/package/lifx-http-api) ![Dependency Status](https://david-dm.org/klarstil/lifx-http-api.svg) [![Build Status](https://travis-ci.org/klarstil/lifx-http-api.svg?branch=master)](https://travis-ci.org/klarstil/lifx-http-api) [![License MIT](https://img.shields.io/badge/license-mit-brightgreen.svg)](https://github.com/klarstil/lifx-http-api/blob/master/LICENSE) [![codecov.io](https://codecov.io/github/klarstil/lifx-http-api/coverage.svg?branch=master)](https://codecov.io/github/klarstil/lifx-http-api?branch=master)

@@ -5,0 +5,0 @@ A thin Node.js API wrapper of the [Lifx HTTP protocol](http://api.developer.lifx.com/).

@@ -7,12 +7,16 @@ 'use strict';

lifx = require('../dist/lifx'),
utils = require('../dist/utils'),
expect = chai.expect,
client, token;
client, token,
process = require('process');
chai.use(chaiHttp);
if (process.env.BEARER_TOKEN) {
token = process.env.BEARER_TOKEN;
} else {
token = fs.readFileSync(__dirname + '/../bearer-token.txt', 'utf8');
}
describe('Lifx HTTP API wrapper', function() {
beforeEach(function() {
token = fs.readFileSync(__dirname + '/../bearer-token.txt', 'utf8');
});
describe('Client initialization', function() {

@@ -54,2 +58,3 @@ it('should create a client with a token', function() {

expect(client.setVersion(data)).to.be.true;
expect(client.setVersion()).to.be.false;
expect(client.getVersion()).to.equal(data);

@@ -66,2 +71,3 @@ });

expect(client.setUrl(data)).to.be.true;
expect(client.setUrl()).to.be.false;
expect(client.getUrl()).to.equal(data);

@@ -78,2 +84,3 @@ });

expect(client.setBearerToken(data)).to.be.true;
expect(client.setBearerToken()).to.be.false;
expect(client.getBearerToken()).to.equal(data);

@@ -102,2 +109,114 @@ });

});
describe('Utils tests', function() {
it('should validate selectors', function() {
expect(utils.verifySelector('all')).to.be.true;
expect(utils.verifySelector('label:test')).to.be.true;
expect(utils.verifySelector('label:test test')).to.be.true;
expect(utils.verifySelector('group_id:asd3212easdx')).to.be.true;
expect(utils.verifySelector('group:test')).to.be.true;
expect(utils.verifySelector('group:test test')).to.be.true;
expect(utils.verifySelector('location_id:asd3212easdx')).to.be.true;
expect(utils.verifySelector('location:test')).to.be.true;
expect(utils.verifySelector('location:test test')).to.be.true;
expect(utils.verifySelector('scene_id:asd3212easdx')).to.be.true;
expect(utils.verifySelector('test')).to.be.false;
expect(utils.verifySelector('test:label')).to.be.false;
})
});
describe('Client integration', function() {
it('should get all available lights', function() {
client = new lifx({
bearerToken: token
});
expect(function() {
client.listLights('testing');
}).to.throw(Error);
client.listLights('all', function(data) {
var light = data[0];
expect(light).to.have.keys([
'id', 'uuid', 'label', 'connected', 'power', 'color', 'brightness', 'group', 'location',
'last_seen', 'seconds_since_seen', 'product'
]);
});
});
it('should get all available scenes', function() {
client = new lifx({
bearerToken: token
});
client.listScenes(function(data) {
var scene = data[0];
expect(scene).to.have.keys([
'uuid', 'name', 'account', 'states', 'created_at', 'updated_at'
]);
});
});
it('should validate a color', function() {
client = new lifx({
bearerToken: token
});
expect(function() {
client.validateColor();
}).to.throw(Error);
client.validateColor('#ff000f', function(data) {
expect(data).to.have.keys([
'hue', 'saturation', 'brightness', 'kelvin'
]);
});
});
it('should toggle the power state', function() {
client = new lifx({
bearerToken: token
});
expect(function() {
client.setState('testing');
}).to.throw(Error);
client.togglePower('all', function(data) {
expect(data.result).to.be.instanceof(Array);
var result = data.result[0];
expect(result).to.have.keys([
'id', 'label', 'status'
]);
});
});
it('should set the state', function() {
client = new lifx({
bearerToken: token
});
expect(function() {
client.setState('testing');
}).to.throw(Error);
client.setState('all', {
power: 'on'
}, function(data) {
expect(data.result).to.be.instanceof(Array);
var result = data.result[0];
expect(result).to.have.keys([
'id', 'label', 'status'
]);
});
});
});
});

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc