Skip to content

Commit

Permalink
feat(wrappednodefetch.test.ts): added a check to compare the recorded…
Browse files Browse the repository at this point in the history
… output with response

Added a check to compare the recorded output with response to ensure wrappedNodeFetch functionality

test #354
  • Loading branch information
Hermione2408 committed Mar 9, 2023
1 parent 036c66e commit 0aeedc0
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions test/wrappedNodeFetch.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,14 @@ describe('wrappedNodeFetch', () => {
const updatedctx= getExecutionContext().context;
const mocks=updatedctx.mocks.length;
const deps=updatedctx.deps.length;
const responseBody = await response.text();
const recordedOutput = updatedctx.mocks[0].Spec.Res.Body;
expect(mockFetch).toHaveBeenCalledWith(url, options);
expect(response).toBeInstanceOf(Response);
expect(mocks).toBeGreaterThan(0);
expect(deps).toBeGreaterThan(0);
expect(response).toHaveProperty('body');
expect(responseBody).toEqual(recordedOutput);
});

it('should return mocked response in test mode', async () => {
Expand All @@ -41,12 +45,12 @@ describe('wrappedNodeFetch', () => {
Spec: {
Metadata: {
name: 'node-fetch',
url: 'http://localhost:8080',
url: 'http://example.com',
options: { method: 'GET' },
type: 'HTTP_CLIENT',
},
Req: {
URL: 'http://localhost:8080',
URL: 'http://example.com',
Body: '',
Header: {},
Method: 'GET',
Expand Down

0 comments on commit 0aeedc0

Please sign in to comment.