@thepalaceproject/circulation-admin 1.18.0 → 1.19.0-post.1

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.
@@ -43,12 +43,40 @@ object-assign
43
43
 
44
44
  /*! http://mths.be/fromcodepoint v0.1.0 by @mathias */
45
45
 
46
- /*! https://mths.be/punycode v1.3.2 by @mathias */
46
+ /*! https://mths.be/punycode v1.4.1 by @mathias */
47
47
 
48
48
  /*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
49
49
 
50
50
  /*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */
51
51
 
52
+ /**
53
+ * match-sorter-utils
54
+ *
55
+ * Copyright (c) TanStack
56
+ *
57
+ * This source code is licensed under the MIT license found in the
58
+ * LICENSE.md file in the root directory of this source tree.
59
+ *
60
+ * @license MIT
61
+ */
62
+
63
+ /**
64
+ * @license React
65
+ * use-sync-external-store-shim.production.min.js
66
+ *
67
+ * Copyright (c) Facebook, Inc. and its affiliates.
68
+ *
69
+ * This source code is licensed under the MIT license found in the
70
+ * LICENSE file in the root directory of this source tree.
71
+ */
72
+
73
+ /**
74
+ * @name match-sorter
75
+ * @license MIT license.
76
+ * @copyright (c) 2099 Kent C. Dodds
77
+ * @author Kent C. Dodds <me@kentcdodds.com> (https://kentcdodds.com)
78
+ */
79
+
52
80
  /** @license React v0.19.1
53
81
  * scheduler.production.min.js
54
82
  *
@@ -122,4 +150,4 @@ object-assign
122
150
 
123
151
  //! momentjs.com
124
152
 
125
- //! version : 2.29.4
153
+ //! version : 2.30.1
package/package.json CHANGED
@@ -36,6 +36,7 @@
36
36
  },
37
37
  "dependencies": {
38
38
  "@nypl/dgx-svg-icons": "0.3.4",
39
+ "@tanstack/react-query": "^4.36.1",
39
40
  "@thepalaceproject/web-opds-client": "^1.0.1",
40
41
  "bootstrap": "^3.3.6",
41
42
  "classnames": "^2.3.1",
@@ -67,8 +68,10 @@
67
68
  "url": "^0.11.0"
68
69
  },
69
70
  "devDependencies": {
71
+ "@tanstack/react-query-devtools": "^4.36.1",
70
72
  "@testing-library/jest-dom": "^5.16.5",
71
73
  "@testing-library/react": "^12.1.5",
74
+ "@testing-library/react-hooks": "^8.0.1",
72
75
  "@testing-library/user-event": "^14.4.3",
73
76
  "@types/jest": "^29.2.6",
74
77
  "@types/mocha": "^10.0.1",
@@ -96,6 +99,7 @@
96
99
  "eslint-plugin-react": "^7.19.0",
97
100
  "eslint-plugin-react-hooks": "^4.0.0",
98
101
  "fetch-mock": "^7.3.1",
102
+ "fetch-mock-jest": "^1.5.1",
99
103
  "file-loader": "^6.2.0",
100
104
  "follow-redirects": "^1.15.6",
101
105
  "husky": "^4.3.0",
@@ -110,6 +114,7 @@
110
114
  "nightwatch": "^3.2.0",
111
115
  "prettier": "2.1.2",
112
116
  "react-axe": "^3.3.0",
117
+ "react-test-renderer": "^16.14.0",
113
118
  "redux-mock-store": "^1.5.4",
114
119
  "sass": "^1.64.2",
115
120
  "sass-lint": "^1.13.1",
@@ -141,5 +146,5 @@
141
146
  "*.{js,jsx,ts,tsx,css,md}": "prettier --write",
142
147
  "*.{js,css,md}": "prettier --write"
143
148
  },
144
- "version": "1.18.0"
149
+ "version": "1.19.0-post.1"
145
150
  }
@@ -0,0 +1,60 @@
1
+ import {
2
+ DEFAULT_BASE_ENDPOINT_URL,
3
+ getInventoryReportInfo,
4
+ requestInventoryReport,
5
+ } from "../../../src/api/admin";
6
+ import * as fetchMock from "fetch-mock-jest";
7
+
8
+ const sampleInfoResponseData = { collections: [] };
9
+ const sampleGenerateResponseData = { message: "some message" };
10
+
11
+ const testAlternateBaseUrl = "/test/base/url";
12
+ const libraryKey = "short-name";
13
+
14
+ const testEndpoints = ({
15
+ title,
16
+ baseEndpointUrl: baseEndpointUrl = undefined,
17
+ expectedUrl = DEFAULT_BASE_ENDPOINT_URL,
18
+ }) => {
19
+ describe(title, () => {
20
+ beforeEach(() => {
21
+ fetchMock
22
+ .get("*", { body: sampleInfoResponseData, status: 200 })
23
+ .post("*", { body: sampleGenerateResponseData, status: 202 });
24
+ });
25
+
26
+ afterEach(() => {
27
+ fetchMock.mockReset();
28
+ });
29
+
30
+ it("requests inventory report information", async () => {
31
+ const response = await getInventoryReportInfo({
32
+ library: libraryKey,
33
+ baseEndpointUrl,
34
+ });
35
+ expect(response).toStrictEqual(sampleInfoResponseData);
36
+ expect(fetchMock).toHaveBeenCalledWith(expectedUrl);
37
+ });
38
+
39
+ it("requests report generation via a post to the endpoint", async () => {
40
+ const response = await requestInventoryReport({
41
+ library: libraryKey,
42
+ baseEndpointUrl,
43
+ });
44
+ expect(response).toStrictEqual(sampleGenerateResponseData);
45
+ expect(fetchMock).toHaveBeenCalledWith(expectedUrl, { method: "POST" });
46
+ });
47
+ });
48
+ };
49
+
50
+ describe("Inventory report API", () => {
51
+ testEndpoints({
52
+ title: "default endpoints",
53
+ expectedUrl: `${DEFAULT_BASE_ENDPOINT_URL}/${libraryKey}`,
54
+ });
55
+ testEndpoints({
56
+ title: "alternative test endpoints",
57
+ baseEndpointUrl: testAlternateBaseUrl,
58
+ expectedUrl: `${testAlternateBaseUrl}/${libraryKey}`,
59
+ });
60
+ });