@thepalaceproject/circulation-admin 1.28.1-post.2 → 1.28.1-post.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -29,7 +29,7 @@ object-assign
|
|
|
29
29
|
* @license MIT
|
|
30
30
|
*/
|
|
31
31
|
|
|
32
|
-
/*! @license DOMPurify | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/
|
|
32
|
+
/*! @license DOMPurify 3.2.4 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.2.4/LICENSE */
|
|
33
33
|
|
|
34
34
|
/*! @preserve
|
|
35
35
|
* numeral.js
|
package/package.json
CHANGED
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"@nypl/dgx-svg-icons": "0.3.4",
|
|
39
39
|
"@reduxjs/toolkit": "^2.2.5",
|
|
40
40
|
"@tanstack/react-query": "^4.36.1",
|
|
41
|
-
"@thepalaceproject/web-opds-client": "^1.0
|
|
41
|
+
"@thepalaceproject/web-opds-client": "^1.1.0",
|
|
42
42
|
"bootstrap": "^3.3.6",
|
|
43
43
|
"classnames": "^2.3.1",
|
|
44
44
|
"draft-convert": "^2.1.5",
|
|
@@ -151,5 +151,5 @@
|
|
|
151
151
|
"*.{js,jsx,ts,tsx,css,md}": "prettier --write",
|
|
152
152
|
"*.{js,css,md}": "prettier --write"
|
|
153
153
|
},
|
|
154
|
-
"version": "1.28.1-post.
|
|
154
|
+
"version": "1.28.1-post.6"
|
|
155
155
|
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
// Need to manually mock DataFetcher before importing NoCacheDataFetcher
|
|
2
|
+
const mockSuperFetch = jest.fn();
|
|
3
|
+
|
|
4
|
+
// Mock the DataFetcher module
|
|
5
|
+
jest.mock("@thepalaceproject/web-opds-client/lib/DataFetcher", () => ({
|
|
6
|
+
__esModule: true,
|
|
7
|
+
default: class MockDataFetcher {
|
|
8
|
+
fetch(url: string, options?: any) {
|
|
9
|
+
return mockSuperFetch(url, options);
|
|
10
|
+
}
|
|
11
|
+
},
|
|
12
|
+
}));
|
|
13
|
+
|
|
14
|
+
// Import after mocking
|
|
15
|
+
import NoCacheDataFetcher from "../../../src/utils/NoCacheDataFetcher";
|
|
16
|
+
|
|
17
|
+
const TEST_URL = "http://example.com";
|
|
18
|
+
|
|
19
|
+
describe("NoCacheDataFetcher", () => {
|
|
20
|
+
let fetcher: NoCacheDataFetcher;
|
|
21
|
+
|
|
22
|
+
beforeEach(() => {
|
|
23
|
+
// Clear mocks between tests
|
|
24
|
+
mockSuperFetch.mockClear();
|
|
25
|
+
|
|
26
|
+
// Create instance of class under test
|
|
27
|
+
fetcher = new NoCacheDataFetcher();
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
it("adds no-cache headers to fetch requests", async () => {
|
|
31
|
+
await fetcher.fetch(TEST_URL);
|
|
32
|
+
|
|
33
|
+
expect(mockSuperFetch).toHaveBeenCalledWith(
|
|
34
|
+
TEST_URL,
|
|
35
|
+
expect.objectContaining({
|
|
36
|
+
headers: { "Cache-Control": "no-cache" },
|
|
37
|
+
cache: "no-cache",
|
|
38
|
+
})
|
|
39
|
+
);
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
it("preserves existing headers when adding no-cache headers", async () => {
|
|
43
|
+
const options = {
|
|
44
|
+
headers: { "Content-Type": "application/json" },
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
await fetcher.fetch(TEST_URL, options);
|
|
48
|
+
|
|
49
|
+
expect(mockSuperFetch).toHaveBeenCalledWith(
|
|
50
|
+
TEST_URL,
|
|
51
|
+
expect.objectContaining({
|
|
52
|
+
headers: {
|
|
53
|
+
"Cache-Control": "no-cache",
|
|
54
|
+
"Content-Type": "application/json",
|
|
55
|
+
},
|
|
56
|
+
cache: "no-cache",
|
|
57
|
+
})
|
|
58
|
+
);
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
it("passes through other options to super.fetch", async () => {
|
|
62
|
+
await fetcher.fetch(TEST_URL, {
|
|
63
|
+
credentials: "include",
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
expect(mockSuperFetch).toHaveBeenCalledWith(
|
|
67
|
+
TEST_URL,
|
|
68
|
+
expect.objectContaining({
|
|
69
|
+
headers: { "Cache-Control": "no-cache" },
|
|
70
|
+
cache: "no-cache",
|
|
71
|
+
credentials: "include",
|
|
72
|
+
})
|
|
73
|
+
);
|
|
74
|
+
});
|
|
75
|
+
});
|