diff --git a/test/testEndpoints.js b/test/testEndpoints.js index b74c795..eacf91c 100644 --- a/test/testEndpoints.js +++ b/test/testEndpoints.js @@ -3,7 +3,8 @@ console.log('NOTE: Don\'t abuse with the test, or your credentials will be throttled!!!'); -var assert = require('assert'); +var assert = require('assert'), + forAllAsync = require('forallasync').forAllAsync; assert(process.env.MEETUP_KEY, 'MEETUP_KEY variable isn\'t set on enviroment (use \'set \"MEETUP_KEY=key\"\' on Windows)'); @@ -130,20 +131,24 @@ checkEndpoint.ws = function(endpointkey, cb) { }); }; -function* test(method) { - var protocol = (endpoints[method].resource.match(/^ws\:/)) ? 'ws' : 'http'; - yield checkEndpoint[protocol](method, () => test(method).next); - console.log(method); -}; - - -for (var method of meetup) { - if (endpoints[method].hasOwnProperty('test') && !endpoints[method].test.hasOwnProperty('disabled')) { - setTimeout(() => { - test(method).next(); - }, 100); - } -} +var meetup_commands = (process.argv[2]) ? process.argv[2].split(',') : meetup.commands; + +forAllAsync(meetup_commands + .filter(command => { + return endpoints[command].hasOwnProperty('test') && + !endpoints[command].test.hasOwnProperty('disabled'); + }), + (next, command) => { + if (endpoints[command].resource.match(/^ws\:/)) { + checkEndpoint.ws(command, next); + } else { + setTimeout(() => { + checkEndpoint.http(command, next); + }, 1000); + } + }, + 1 +); process.on('exit', function(code) { if (!code) {