Skip to content

Commit

Permalink
Merge branch '1.x.x'
Browse files Browse the repository at this point in the history
  • Loading branch information
jkutianski committed Sep 19, 2015
2 parents 6225e9f + 6fb062e commit 738325d
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 14 deletions.
2 changes: 0 additions & 2 deletions lib/meetup.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ try {
var MeetupAPIkey,
APIRequest = {};

var test = ['x','y'];

/*
* Constructor
*
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"node" : ">=4.0.0"
},
"dependencies": {
"superagent": "1.3.x",
"superagent": "1.4.x",
"websocket-stream": "2.0.x",
"JSONStream": "1.0.x",
"event-stream": "3.3.x"
Expand Down
35 changes: 24 additions & 11 deletions test/testEndpoints.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,27 @@ assert(process.env.MEETUP_KEY, 'MEETUP_KEY variable isn\'t set on enviroment (us

var meetup = require('../lib/meetup')();

// for (var i in meetup) { console.log(i) }

var endpoints = require('../lib/endpoints.json');

assert(meetup.version, 'Can\'t get Version');
try {
meetup.version = '0.0.0';
} catch(err) {}
assert(meetup.version === '1.0.0', 'Version not read only');

console.log('%s ver %s Test\n\n', meetup.description, meetup.version);

console.log('Get version\t\tPASS');

assert(!meetup.authkey, 'Authkey getter failed');
console.log('Authkey getter\t\tPASS');
meetup.authkey = process.env.MEETUP_KEY;
assert(meetup.authkey, 'Authkey setter failed');
console.log('Authkey setter\t\tPASS');

assert(meetup.dependencies.superagent, 'Superagent version not set');
try {
meetup.dependencies.superagent = 0;
} catch (err) {}
Expand All @@ -41,7 +53,7 @@ var checkEndpoint = {};
checkEndpoint.http = function(endpointkey, cb) {
if (endpoints[endpointkey].chunked) {
var chnk = meetup[endpointkey](endpoints[endpointkey].test.params)
.on('data', function(ret) {
.on('data', ret => {
chnk.abort();
assert.equal(objectType(ret), endpoints[endpointkey].test.return.type, endpointkey + ' not return an ' + endpoints[endpointkey].test.return.type);
switch (objectType(ret)) {
Expand All @@ -61,8 +73,9 @@ checkEndpoint.http = function(endpointkey, cb) {
cb();
});
} else {
meetup[endpointkey](endpoints[endpointkey].test.params, function(err, ret) {
(function(errors) {
meetup[endpointkey](endpoints[endpointkey].test.params, (err, ret) => {
((errors) => {
ret = ret || {};
ret.problem = errors || ret.problem;
ret.code = errors && errors.code || ret.problem;
ret.details = errors && errors.message || ret.details;
Expand All @@ -81,7 +94,7 @@ checkEndpoint.http = function(endpointkey, cb) {
case 'object':
assert(endpoints[endpointkey].test.return.keys, endpointkey + ' hasn\'t defined keys on endpoints.json');

endpoints[endpointkey].test.return.keys.forEach(function(returnkey) {
endpoints[endpointkey].test.return.keys.forEach(returnkey => {
assert(ret.hasOwnProperty(returnkey), endpointkey + ' not return the ' + returnkey + ' key');
});

Expand All @@ -98,7 +111,7 @@ checkEndpoint.http = function(endpointkey, cb) {

checkEndpoint.ws = function(endpointkey, cb) {
var ws = meetup[endpointkey](endpoints[endpointkey].params)
.on('data', function(ret) {
.on('data', (ret) => {
ws.abort();
switch (objectType(ret)) {
case 'object':
Expand All @@ -112,24 +125,24 @@ checkEndpoint.ws = function(endpointkey, cb) {
default:
}
})
.on('close', function() {
.on('close', () => {
console.log('%s\t\tPASS', endpointkey);
cb();
});
};

meetup.commands = (process.argv[2]) ? process.argv[2].split(',') : meetup.commands;
var meetup_commands = (process.argv[2]) ? process.argv[2].split(',') : meetup.commands;

forAllAsync(meetup.commands
.filter(function(command) {
forAllAsync(meetup_commands
.filter(command => {
return endpoints[command].hasOwnProperty('test') &&
!endpoints[command].test.hasOwnProperty('disabled');
}),
function(next, command) {
(next, command) => {
if (endpoints[command].resource.match(/^ws\:/)) {
checkEndpoint.ws(command, next);
} else {
setTimeout(function() {
setTimeout(() => {
checkEndpoint.http(command, next);
}, 1000);
}
Expand Down

0 comments on commit 738325d

Please sign in to comment.