Skip to content

Commit 92f16d3

Browse files
committed
drop node-fetch
1 parent da946e1 commit 92f16d3

5 files changed

Lines changed: 29 additions & 21 deletions

File tree

doc/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
# Changelog
22

33

4+
##### 1.2.5 (2015-08-29)
5+
- Polish: drop `node-fetch` as a dependency for testing, instead use `http` module directly.
6+
7+
48
##### 1.2.4 (2015-08-29)
59
- Feature: add `enforceLinks` option, when set as `false` it will ignore referential integrity errors. Useful for client-side use.
610

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "fortune",
33
"description": "High-level I/O for web applications.",
4-
"version": "1.2.4",
4+
"version": "1.2.5",
55
"license": "MIT",
66
"author": {
77
"email": "0x8890@airmail.cc",
@@ -38,7 +38,6 @@
3838
"deep-equal": "^1.0.0",
3939
"error-class": "^1.0.8",
4040
"negotiator": "^0.5.3",
41-
"node-fetch": "^1.3.2",
4241
"tapdance": "^3.0.5",
4342
"ws": "^0.8.0"
4443
},

test/integration/http.js

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,12 @@ import { fail } from 'tapdance'
22
import testInstance from './test_instance'
33
import http from 'http'
44
import chalk from 'chalk'
5-
import fetch from 'node-fetch'
65
import fortune from '../../lib'
76
import * as stderr from '../stderr'
87

98

109
const port = 1337
1110

12-
// Set promise polyfill for old versions of Node.
13-
fetch.Promise = Promise
14-
1511

1612
export default function httpTest (options, path, request, fn, change) {
1713
let store
@@ -42,14 +38,23 @@ export default function httpTest (options, path, request, fn, change) {
4238
request.headers['Content-Length'] = Buffer.byteLength(request.body)
4339
}
4440

45-
return fetch(`http://localhost:${port}${path}`, request)
41+
return new Promise((resolve, reject) =>
42+
http.request(Object.assign({ port, path }, request), response => {
43+
headers = response.headers
44+
status = response.statusCode
45+
46+
const chunks = []
47+
48+
response.on('error', reject)
49+
response.on('data', chunk => chunks.push(chunk))
50+
response.on('end', () => resolve(Buffer.concat(chunks)))
51+
}).end(request ? request.body : null))
4652

4753
.then(response => {
4854
server.close()
49-
stderr.debug(chalk.bold('Response status: ' + response.status))
50-
stderr.debug(response.headers.raw())
51-
; ({ headers, status } = response)
52-
return store.disconnect().then(() => response.text())
55+
stderr.debug(chalk.bold('Response status: ' + status))
56+
stderr.debug(headers)
57+
return store.disconnect().then(() => response.toString())
5358
})
5459

5560
.then(text => {

test/integration/serializers/ad_hoc.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ run(() => {
1515
comment('get index')
1616
return test('/', null, response => {
1717
equal(response.status, 200, 'status is correct')
18-
ok(~response.headers.get('content-type').indexOf(mediaType),
18+
ok(~response.headers['content-type'].indexOf(mediaType),
1919
'content type is correct')
2020
deepEqual(response.body, [ 'user', 'animal', '☯' ],
2121
'response body is correct')
@@ -27,7 +27,7 @@ run(() => {
2727
comment('get empty collection')
2828
return test(encodeURI('/☯'), null, response => {
2929
equal(response.status, 200, 'status is correct')
30-
ok(~response.headers.get('content-type').indexOf(mediaType),
30+
ok(~response.headers['content-type'].indexOf(mediaType),
3131
'content type is correct')
3232
deepEqual(response.body, [], 'response body is correct')
3333
})
@@ -38,7 +38,7 @@ run(() => {
3838
comment('get records')
3939
return test('/user', null, response => {
4040
equal(response.status, 200, 'status is correct')
41-
ok(~response.headers.get('content-type').indexOf(mediaType),
41+
ok(~response.headers['content-type'].indexOf(mediaType),
4242
'content type is correct')
4343
equal(response.body.length, 3, 'response body is correct')
4444
})
@@ -49,7 +49,7 @@ run(() => {
4949
comment('get records by ID')
5050
return test('/animal/1,%2Fwtf', null, response => {
5151
equal(response.status, 200, 'status is correct')
52-
ok(~response.headers.get('content-type').indexOf(mediaType),
52+
ok(~response.headers['content-type'].indexOf(mediaType),
5353
'content type is correct')
5454
deepEqual(response.body.map(record => record.id),
5555
[ 1, '/wtf' ], 'response body is correct')
@@ -63,7 +63,7 @@ run(() => {
6363
fields: 'name,owner'
6464
})}`, null, response => {
6565
equal(response.status, 200, 'status is correct')
66-
ok(~response.headers.get('content-type').indexOf(mediaType),
66+
ok(~response.headers['content-type'].indexOf(mediaType),
6767
'content type is correct')
6868
deepEqual(response.body.map(record => Object.keys(record).length),
6969
[ 4, 4, 4, 4 ], 'response body fields are correct')
@@ -77,7 +77,7 @@ run(() => {
7777
'match[name]': 'Fido'
7878
})}`, null, response => {
7979
equal(response.status, 200, 'status is correct')
80-
ok(~response.headers.get('content-type').indexOf(mediaType),
80+
ok(~response.headers['content-type'].indexOf(mediaType),
8181
'content type is correct')
8282
equal(response.body[0].name, 'Fido', 'match is correct')
8383
})
@@ -92,7 +92,7 @@ run(() => {
9292
offset: 1
9393
})}`, null, response => {
9494
equal(response.status, 200, 'status is correct')
95-
ok(~response.headers.get('content-type').indexOf(mediaType),
95+
ok(~response.headers['content-type'].indexOf(mediaType),
9696
'content type is correct')
9797
deepEqual(response.body.map(record => record.name),
9898
[ 'Fido', 'Sniffles' ], 'response body is correct')
@@ -112,7 +112,7 @@ run(() => {
112112
} ]
113113
}, response => {
114114
equal(response.status, 201, 'status is correct')
115-
ok(~response.headers.get('content-type').indexOf(mediaType),
115+
ok(~response.headers['content-type'].indexOf(mediaType),
116116
'content type is correct')
117117
deepEqual(response.body.map(record => record.name),
118118
[ 'Ayy lmao' ], 'response body is correct')
@@ -131,7 +131,7 @@ run(() => {
131131
} ]
132132
}, response => {
133133
equal(response.status, 200, 'status is correct')
134-
ok(~response.headers.get('content-type').indexOf(mediaType),
134+
ok(~response.headers['content-type'].indexOf(mediaType),
135135
'content type is correct')
136136
deepEqual(response.body.map(record => record.name),
137137
[ 'Ayy lmao' ], 'response body is correct')

test/integration/serializers/form_urlencoded.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ run(() => {
3535
})
3636
}, response => {
3737
equal(response.status, 201, 'status is correct')
38-
ok(~response.headers.get('content-type').indexOf('application/json'),
38+
ok(~response.headers['content-type'].indexOf('application/json'),
3939
'content type is correct')
4040
deepEqual(response.body.map(record => record.name),
4141
[ 'Ayy lmao' ], 'response body is correct')

0 commit comments

Comments
 (0)