-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #783 from splitio/nodejs_http_support
Add HTTP protocol support for NodeJS
- Loading branch information
Showing
8 changed files
with
87 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,33 @@ | ||
import tape from 'tape-catch'; | ||
import { getFetch } from '../node'; | ||
import sinon from 'sinon'; | ||
import { getFetch, __setFetch } from '../node'; | ||
|
||
tape('getFetch returns node-fetch module in Node', assert => { | ||
assert.equal(getFetch(), require('node-fetch')); | ||
tape('getFetch returns a wrapped node-fetch module in Node', assert => { | ||
assert.equal(typeof getFetch(), 'function'); | ||
|
||
assert.end(); | ||
}); | ||
|
||
tape('getFetch passes an agent object to HTTPs requests', assert => { | ||
const fetchMock = sinon.stub(); | ||
__setFetch(fetchMock); | ||
|
||
const fetch = getFetch(); | ||
|
||
fetch('http://test.com'); | ||
assert.true(fetchMock.calledWithExactly('http://test.com', { agent: undefined })); | ||
|
||
fetch('https-https://', { option: 'value' }); | ||
assert.true(fetchMock.calledWithExactly('https-https://', { option: 'value', agent: undefined })); | ||
|
||
fetch('https://test.com'); | ||
assert.true(fetchMock.calledWithExactly('https://test.com', { agent: sinon.match.object })); | ||
|
||
fetch('https://test.com', { option: 'value' }); | ||
assert.true(fetchMock.calledWithExactly('https://test.com', { option: 'value', agent: sinon.match.object })); | ||
|
||
// Restore | ||
__setFetch(require('node-fetch')); | ||
|
||
assert.end(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
export const packageVersion = '10.24.1'; | ||
export const packageVersion = '10.25.0'; |