Skip to content

Commit

Permalink
fix header version test
Browse files Browse the repository at this point in the history
  • Loading branch information
benjlevesque committed Jan 18, 2024
1 parent 255780c commit 8e03773
Showing 1 changed file with 7 additions and 19 deletions.
26 changes: 7 additions & 19 deletions packages/request-client.js/test/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import { MockStorage } from '../src/mock-storage';
import * as RequestLogic from '@requestnetwork/types/src/request-logic-types';
import { http, HttpResponse } from 'msw';
import { setupServer, SetupServer } from 'msw/node';
import config from '../src/http-config-defaults';

const httpConfig: Partial<ClientTypes.IHttpDataAccessConfig> = {
getConfirmationDeferDelay: 0,
Expand Down Expand Up @@ -186,7 +187,12 @@ describe('request-client.js', () => {

beforeAll(() => {
mockServer = setupServer(
http.post('*/persistTransaction', () => HttpResponse.json(spyPersistTransaction())),
http.post('*/persistTransaction', ({ request }) => {
if (!request.headers.get(config.requestClientVersionHeader)) {
throw new Error('Missing version header');
}
return HttpResponse.json(spyPersistTransaction());
}),
http.get('*/getTransactionsByChannelId', () =>
HttpResponse.json(spyGetTransactionsByChannelId()),
),
Expand All @@ -203,21 +209,6 @@ describe('request-client.js', () => {
mockServer.close();
});

it('specify the Request Client version in the header', async () => {
const requestNetwork = new RequestNetwork({
httpConfig,
signatureProvider: TestData.fakeSignatureProvider,
paymentOptions: {
bitcoinDetectionProvider: mockBTCProvider,
},
});

const request = await requestNetwork.createRequest(requestCreationParams);
expect(spyPersistTransaction).toHaveBeenCalledTimes(1);

await request.waitForConfirmation();
});

it('uses http://localhost:3000 with signatureProvider and paymentNetwork', async () => {
const requestNetwork = new RequestNetwork({
httpConfig,
Expand Down Expand Up @@ -363,9 +354,6 @@ describe('request-client.js', () => {
beforeEach(() => {
hits = { get: 0, post: 0 };
});
afterEach(() => {
// mock.resetHandlers();
});
it('allows to create a request', async () => {
const requestNetwork = new RequestNetwork({
httpConfig,
Expand Down

0 comments on commit 8e03773

Please sign in to comment.