This is not GitHub.com

Like what you see? Install OctoLinker now!

Skip to content
Permalink
Browse files

Remove request-promise (deprecation) (#435)

Co-authored-by: Joey <jrogues@hubside.com>
  • Loading branch information
joeyrogues and Joey committed May 13, 2020
1 parent ceaf102 commit 59bbb73989c046aaa3567bbe5ac83f97e678c2d6
Showing with 138 additions and 317 deletions.
  1. +1 −2 package.json
  2. +4 −3 packages/micro/README.md
  3. +10 −13 test/development.js
  4. +101 −147 test/index.js
  5. +5 −8 test/production.js
  6. +17 −144 yarn.lock
@@ -13,15 +13,14 @@
},
"license": "MIT",
"devDependencies": {
"node-fetch": "2.6.0",
"lerna": "^3.4.0",
"@zeit/eslint-config-node": "0.2.13",
"@zeit/git-hooks": "0.1.4",
"ava": "0.23.0",
"eslint": "4.19.1",
"husky": "0.14.3",
"nyc": "11.3.0",
"request": "2.83.0",
"request-promise": "4.2.2",
"resumer": "0.0.0",
"rewire": "3.0.2",
"sinon": "4.4.3",
@@ -338,7 +338,7 @@ const http = require('http')
const micro = require('micro')
const test = require('ava')
const listen = require('test-listen')
const request = require('request-promise')
const fetch = require('node-fetch')
test('my endpoint', async t => {
const service = new http.Server(micro(async (req, res) => {
@@ -348,9 +348,10 @@ test('my endpoint', async t => {
}))
const url = await listen(service)
const body = await request(url)
const response = await fetch(url)
const body = await response.json()
t.deepEqual(JSON.parse(body).test, 'woot')
t.deepEqual(body.test, 'woot')
service.close()
})
```
@@ -1,6 +1,6 @@
// Packages
const test = require('ava');
const request = require('request-promise');
const fetch = require('node-fetch');
const listen = require('test-listen');
const http = require('http');

@@ -17,9 +17,10 @@ test('send(200, <Object>) is pretty-printed', async t => {
const fn = () => ({woot: 'yes'});

const url = await getUrl(fn);
const res = await request(url);
const res = await fetch(url);
const body = await res.text();

t.deepEqual(res, `{\n "woot": "yes"\n}`);
t.deepEqual(body, `{\n "woot": "yes"\n}`);
});

test('sendError shows stack in development without statusCode', async t => {
@@ -28,11 +29,9 @@ test('sendError shows stack in development without statusCode', async t => {
};

const url = await getUrl(fn);
try {
await request(url);
} catch (err) {
t.true(err.message.indexOf('at fn (') !== -1);
}
const res = await fetch(url);
const body = await res.text();
t.true(body.indexOf('at fn (') !== -1);
});

test('sendError shows stack in development with statusCode', async t => {
@@ -43,9 +42,7 @@ test('sendError shows stack in development with statusCode', async t => {
};

const url = await getUrl(fn);
try {
await request(url);
} catch (err) {
t.true(err.message.indexOf('at fn (') !== -1);
}
const res = await fetch(url);
const body = await res.text();
t.true(body.indexOf('at fn (') !== -1);
});

0 comments on commit 59bbb73

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