Skip to content

Commit

Permalink
Remove request-promise (deprecation) (#435)
Browse files Browse the repository at this point in the history
Co-authored-by: Joey <jrogues@hubside.com>
  • Loading branch information
joeyrogues and Joey committed May 13, 2020
1 parent ceaf102 commit 59bbb73
Show file tree
Hide file tree
Showing 6 changed files with 138 additions and 317 deletions.
3 changes: 1 addition & 2 deletions package.json
Expand Up @@ -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",
Expand Down
7 changes: 4 additions & 3 deletions packages/micro/README.md
Expand Up @@ -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) => {
Expand All @@ -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()
})
```
Expand Down
23 changes: 10 additions & 13 deletions test/development.js
@@ -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');

Expand All @@ -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 => {
Expand All @@ -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 => {
Expand All @@ -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.