Skip to content

Commit

Permalink
Remove client name param from createHttpClientTestSuite. (#1238)
Browse files Browse the repository at this point in the history
  • Loading branch information
dcr-stripe authored Sep 10, 2021
1 parent b4298e6 commit 09836a8
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 20 deletions.
10 changes: 4 additions & 6 deletions test/net/FetchHttpClient.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,8 @@ const createFetchHttpClient = () => {

const {createHttpClientTestSuite, ArrayReadable} = require('./helpers');

createHttpClientTestSuite(
'FetchHttpClient',
createFetchHttpClient,
(setupNock, sendRequest) => {
describe('FetchHttpClient', () => {
createHttpClientTestSuite(createFetchHttpClient, (setupNock, sendRequest) => {
describe('raw stream', () => {
it('getRawResponse()', async () => {
setupNock().reply(200);
Expand Down Expand Up @@ -57,5 +55,5 @@ createHttpClientTestSuite(
});
});
});
}
);
});
});
10 changes: 4 additions & 6 deletions test/net/NodeHttpClient.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@ const {createNodeHttpClient} = require('../../lib/Stripe');

const {createHttpClientTestSuite, ArrayReadable} = require('./helpers');

createHttpClientTestSuite(
'NodeHttpClient',
createNodeHttpClient,
(setupNock, sendRequest) => {
describe('NodeHttpClient', () => {
createHttpClientTestSuite(createNodeHttpClient, (setupNock, sendRequest) => {
describe('raw stream', () => {
it('getRawResponse()', async () => {
setupNock().reply(200);
Expand Down Expand Up @@ -60,5 +58,5 @@ createHttpClientTestSuite(
});
});
});
}
);
});
});
11 changes: 3 additions & 8 deletions test/net/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,13 @@ class ArrayReadable extends Readable {
* Test runner which runs a common set of tests for a given HTTP client to make
* sure the client meets the interface expectations.
*
* This takes in a client name (for the test description) and function to create
* a client.
* This takes in a function to create the client.
*
* This can be configured to run extra tests, providing the nock setup function
* and request function for those tests.
*/
const createHttpClientTestSuite = (
httpClientName,
createHttpClientFn,
extraTestsFn
) => {
describe(`${httpClientName}`, () => {
const createHttpClientTestSuite = (createHttpClientFn, extraTestsFn) => {
describe('HttpClientTestSuite', () => {
const setupNock = () => {
return nock('http://stripe.com').get('/test');
};
Expand Down

0 comments on commit 09836a8

Please sign in to comment.