Plato on Github
Report Home
request/tests/test-promise.js
Maintainability
85.25
Lines of code
52
Difficulty
8.27
Estimated Errors
0.36
Function weight
By Complexity
By SLOC
'use strict' var http = require('http') , request = require('../index') , tape = require('tape') , Promise = require('bluebird') var s = http.createServer(function(req, res) { res.writeHead(200, {}) res.end('ok') }) tape('setup', function(t) { s.listen(6767, function() { t.end() }) }) tape('promisify convenience method', function(t) { var get = request.get var p = Promise.promisify(get) p('http://localhost:6767') .then(function (results) { var res = results[0] t.equal(res.statusCode, 200) t.end() }) }) tape('promisify request function', function(t) { var p = Promise.promisify(request) p('http://localhost:6767') .spread(function (res, body) { t.equal(res.statusCode, 200) t.end() }) }) tape('promisify all methods', function(t) { Promise.promisifyAll(request) request.getAsync('http://localhost:6767') .spread(function (res, body) { t.equal(res.statusCode, 200) t.end() }) }) tape('cleanup', function(t) { s.close(function() { t.end() }) })