This is not GitHub.com

Like what you see? Install OctoLinker now!

Skip to content
Permalink
Browse files

Remove duplicated code "getUrl" (tests) (#436)

Co-authored-by: Joey <jrogues@hubside.com>
  • Loading branch information
joeyrogues and Joey committed May 16, 2020
1 parent 59bbb73 commit c85f41d68e4a53355df9458cf01b80e9c1ec22cf
Showing with 6 additions and 16 deletions.
  1. +3 −0 test/_test-utils.js
  2. +1 −5 test/development.js
  3. +1 −6 test/index.js
  4. +1 −5 test/production.js
@@ -0,0 +1,3 @@
module.exports = ({http, micro, listen}) => ({
getUrl: fn => listen(new http.Server(micro(fn)))
});
@@ -7,11 +7,7 @@ const http = require('http');
process.env.NODE_ENV = 'development';
const micro = require('../packages/micro/lib');

const getUrl = fn => {
const srv = new http.Server(micro(fn));

return listen(srv);
};
const {getUrl} = require('./_test-utils')({http, micro, listen});

test('send(200, <Object>) is pretty-printed', async t => {
const fn = () => ({woot: 'yes'});
@@ -6,15 +6,10 @@ const sleep = require('then-sleep');
const resumer = require('resumer');
const listen = require('test-listen');
const micro = require('../packages/micro/lib');
const {getUrl} = require('./_test-utils')({http, micro, listen});

const {send, sendError, buffer, json} = micro;

const getUrl = fn => {
const srv = new http.Server(micro(fn));

return listen(srv);
};

test('send(200, <String>)', async t => {
const fn = async (req, res) => {
send(res, 200, 'woot');
@@ -7,11 +7,7 @@ const listen = require('test-listen');
process.env.NODE_ENV = 'production';
const micro = require('../packages/micro');

const getUrl = fn => {
const srv = new http.Server(micro(fn));

return listen(srv);
};
const {getUrl} = require('./_test-utils')({http, micro, listen});

test.serial('errors are printed in console in production', async t => {
let logged = false;

0 comments on commit c85f41d

Please sign in to comment.
You can’t perform that action at this time.