-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #19 from packethost/improve-tests
Replace grunt ci tasks with npm scripts
- Loading branch information
Showing
20 changed files
with
167 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
**.orig | ||
# Logs | ||
logs | ||
*.log | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"preset": "google", | ||
"validateIndentation": 4, | ||
"maximumLineLength": 100 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
{ | ||
"indent" : 4, // {int} Number of spaces to use for indentation | ||
"latedef" : false, // true: Require variables/functions to be defined before being used | ||
"newcap" : true, // true: Require capitalization of all constructor functions e.g. `new F()` | ||
"noarg" : true, // true: Prohibit use of `arguments.caller` and `arguments.callee` | ||
"noempty" : true, // true: Prohibit use of empty blocks | ||
"nonbsp" : true, // true: Prohibit "non-breaking whitespace" characters. | ||
"nonew" : false, // true: Prohibit use of constructors for side-effects (without assignment) | ||
"plusplus" : false, // true: Prohibit use of `++` & `--` | ||
"quotmark" : "single", // Quotation mark consistency: | ||
// false : do nothing (default) | ||
// true : ensure whatever is used is consistent | ||
// "single" : require single quotes | ||
// "double" : require double quotes | ||
"undef" : true, // true: Require all non-global variables to be declared (prevents global leaks) | ||
"unused" : true, // Unused variables: | ||
// true : all variables, last function parameter | ||
// "vars" : all variables only | ||
// "strict" : all variables, all function parameters | ||
"strict" : true, // true: Requires all functions run in ES5 Strict Mode | ||
"maxparams" : false, // {int} Max number of formal params allowed per function | ||
"maxdepth" : false, // {int} Max depth of nested blocks (within functions) | ||
"maxstatements" : false, // {int} Max number statements per function | ||
"maxcomplexity" : false, // {int} Max cyclomatic complexity per function | ||
"maxlen" : false, // {int} Max number of characters per line | ||
|
||
"node" : true, // Node.js | ||
"mocha" : true, // Mocha testing framework | ||
|
||
// Custom Globals | ||
"globals" : {} // additional predefined global variables | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
{ | ||
"apiUrl": "https://api.packet.net" | ||
} | ||
"apiUrl": "https://api.packet.net" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,40 @@ | ||
'use strict'; | ||
|
||
var nock = require('nock'); | ||
var Packet = new require('../lib/packet'); | ||
var uuid = require('node-uuid'); | ||
var apiConfig = require('../lib/config/config.json'); | ||
var expect = require('chai').expect; | ||
var projectId; | ||
var deviceId; | ||
var api = new Packet(''); | ||
describe('Client Devices Methods', function() { | ||
beforeEach(function() { | ||
projectId = uuid.v4(); | ||
deviceId = uuid.v4(); | ||
}); | ||
}); | ||
describe('getDevices', function() { | ||
it('should get a list of devices', function(done) { | ||
var mock = nock(apiConfig.apiUrl) | ||
.intercept('/projects/' + projectId + '/devices/', 'GET') | ||
.reply(200, {devices:[{name:'device 1'}]}); | ||
api.getDevices(projectId, false, false, function(err, data) { | ||
expect(err).to.equal(null); | ||
expect(data.devices).to.deep.equal([{name:'device 1'}]); | ||
done(); | ||
mock.done(); | ||
}); | ||
}); | ||
it('should get a single device', function(done) { | ||
var mock = nock(apiConfig.apiUrl) | ||
.intercept('/devices/' + deviceId + '/', 'GET') | ||
.reply(200, {name:'device 1'}); | ||
api.getDevices(false, deviceId, false, function(err, data) { | ||
expect(err).to.equal(null); | ||
expect(data).to.deep.equal({name:'device 1'}); | ||
done(); | ||
mock.done(); | ||
}); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,32 @@ | ||
'use strict'; | ||
// jshint ignore: start | ||
var nock = require('nock'); | ||
var Packet = new require('../lib/packet'); | ||
var uuid = require('node-uuid'); | ||
var apiConfig = require('../lib/config/config.json'); | ||
var expect = require('chai').expect; | ||
var notificationId; | ||
var api = new Packet(''); | ||
describe('Client Notification Methods', function() { | ||
describe('getNotifications', function() { | ||
describe('getNotifications', function() { | ||
it('should get a list of notifications', function(done) { | ||
var randomId_1 = uuid.v4(); | ||
var randomId_2 = uuid.v4(); | ||
var randomId1 = uuid.v4(); | ||
var randomId2 = uuid.v4(); | ||
var mock = nock(apiConfig.apiUrl) | ||
.intercept('/notifications/', 'GET') | ||
.reply(200, { | ||
notifications:[ | ||
{id:randomId_1}, | ||
{id:randomId_2} | ||
]}); | ||
{id:randomId1}, | ||
{id:randomId2} | ||
]}); | ||
api.getNotifications(false, false, function(err, data) { | ||
expect(data).to.deep.equal({notifications:[{id:randomId_1}, {id:randomId_2}]}); | ||
expect(err).to.equal(null); | ||
expect(data).to.deep.equal({notifications:[ | ||
{id:randomId1}, | ||
{id:randomId2} | ||
]}); | ||
mock.done(); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.