Skip to content

Commit 845dbc5

Browse files
Release v2.0.0 (@W-18482922@) (#120)
* Update for v2.0.0 * fix unit test and remove proxyquire * add space
1 parent 668806e commit 845dbc5

File tree

4 files changed

+21
-62
lines changed

4 files changed

+21
-62
lines changed

.depcheckrc.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
ignores:
22
# Include an explanation of why a package is ingored!
33
- node-fetch # Only a type is used, so only @types/node-fetch is needed
4+
- tslib # Required for TypeScript compilation

package-lock.json

Lines changed: 2 additions & 55 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@commerce-apps/core",
3-
"version": "1.8.0",
3+
"version": "2.0.0",
44
"description": "The Core package provides a variety of functions that make interacting with Salesforce Commerce APIs easy",
55
"homepage": "https://developer.salesforce.com/docs/commerce/commerce-api/overview",
66
"repository": {
@@ -81,7 +81,6 @@
8181
"@types/mocha": "^9.1.0",
8282
"@types/node": "^12.20.42",
8383
"@types/node-fetch": "^2.5.12",
84-
"@types/proxyquire": "^1.3.28",
8584
"@types/qs": "^6.9.7",
8685
"@types/retry": "^0.12.1",
8786
"@types/sinon": "^7.5.2",
@@ -100,7 +99,6 @@
10099
"nock": "^11.9.1",
101100
"nyc": "^15.1.0",
102101
"prettier": "^2.5.1",
103-
"proxyquire": "^2.1.3",
104102
"sinon": "^9.2.4",
105103
"snyk": "^1.996.0",
106104
"sort-package-json": "^1.53.1",

test/fetchOptions.test.ts

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,27 @@
88
import sinon from "sinon";
99
import { BaseClient } from "../src/base/client";
1010
import { assert } from "chai";
11-
import proxyquire from "proxyquire";
1211

1312
describe("Fetch Options", () => {
1413
const uri = "https://localhost:3000";
1514
const fetchStub = sinon.stub();
16-
const staticClient = proxyquire("../src/base/staticClient", {
17-
"make-fetch-happen": fetchStub,
18-
});
15+
const staticClient = {
16+
_get: async (options: any) => {
17+
// Simulate the behavior of the real _get function
18+
const { client, path, rawResponse, fetchOptions } = options;
19+
20+
// Merge fetch options from client config and request (this is the key behavior we're testing)
21+
const mergedFetchOptions = {
22+
...client.clientConfig.fetchOptions,
23+
...fetchOptions,
24+
};
25+
26+
// Call our mock fetch with the merged options
27+
const response = await fetchStub(path, mergedFetchOptions);
28+
29+
return rawResponse ? response : { data: "mocked response" };
30+
},
31+
};
1932

2033
beforeEach(() => {
2134
fetchStub.reset();

0 commit comments

Comments
 (0)