// -- RUN EVERYTHING ----------------------------------------------------------- step( function() { setTimeout(this, 100); }, // let the server start up function() { makeRequest('NO FIXTURES' , false, this); }, function() { makeRequest('YES FIXTURES', true , this); }, httpServer.close.bind(httpServer) );
// Start an HTTP server to mock API calls (telemetry server and Bitballoon) // Tests are using child processes, so we cannot use `nock` or similar library // that relies on monkey-patching global variables. const startServer = async function(path, response = {}, { status = 200 } = {}) { const requests = [] const server = createServer((req, res) => requestHandler({ req, res, requests, response, status, path })) await promisify(server.listen.bind(server))(0) const host = getHost(server) const stopServer = promisify(server.close.bind(server)) return { scheme: 'http', host, requests, stopServer } }
/** * Start API server with common port and augmented request handler * * @param {function} handler - request handler * @param {function} callback - invoked after server has started */ function startApiServer(handler, callback) { var server = http.createServer(agnostic(handler)).listen(common.api.port, function() { // supply endpoint to the consumer var tailoredOptions = util._extend(common.fbbot, {apiUrl: 'http://localhost:' + common.api.port + '/?access_token='}); callback(tailoredOptions, server.close.bind(server)); }); }
// -- RUN EVERYTHING ----------------------------------------------------------- step( function() { replayer.substitute('<OPAQUE_SECRET1>', function() { return 'TheActualSecret1'; }); replayer.substitute('<OPAQUE_SECRET2>', function() { return 'TheActualSecret2'; }); replayer.substitute('<OPAQUE_SECRET3>', function() { return 'TheActualSecret3'; }); replayer.substitute('<OPAQUE_SECRET4>', function() { return 'TheActualSecret4'; }); setTimeout(this, 100); }, // let the server start up function() { makeRequest('NO FIXTURES' , this); }, function() { makeRequest('YES FIXTURES', this); }, httpServer.close.bind(httpServer) );
// -- RUN EVERYTHING ----------------------------------------------------------- step( function() { setTimeout(this, 100); }, // let the server start up function() { makeRequest('NO FIXTURES' , false, this); }, function() { makeRequest('YES FIXTURES', true , this); }, httpServer.close.bind(httpServer) );