@etsoo/react 1.8.69 → 1.8.71
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.
- package/__tests__/ReactUtils.tsx +51 -0
- package/package.json +9 -9
- package/__tests__/ReactUtils.ts +0 -6
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { useRefs } from "../src";
|
|
3
|
+
import { ReactUtils } from "../src/app/ReactUtils";
|
|
4
|
+
import { render, renderHook } from "@testing-library/react";
|
|
5
|
+
|
|
6
|
+
test("Tests for ReactUtils.formatInputValue", () => {
|
|
7
|
+
expect(ReactUtils.formatInputValue([1, "a"])).toEqual([1, "a"]);
|
|
8
|
+
expect(ReactUtils.formatInputValue(true)).toEqual("true");
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
test("Tests for ReactUtils.updateRefValues", () => {
|
|
12
|
+
// Input refs
|
|
13
|
+
const refFields = ["name", "retailPrice", "qty"] as const;
|
|
14
|
+
|
|
15
|
+
// Hook
|
|
16
|
+
const { result: refs } = renderHook(() => useRefs(refFields));
|
|
17
|
+
|
|
18
|
+
// Act
|
|
19
|
+
render(
|
|
20
|
+
<div>
|
|
21
|
+
<input name="name" ref={refs.current.name} />
|
|
22
|
+
<input
|
|
23
|
+
name="price.retailPrice"
|
|
24
|
+
type="number"
|
|
25
|
+
ref={refs.current.retailPrice}
|
|
26
|
+
/>
|
|
27
|
+
<input name="qty" type="number" ref={refs.current.qty} />
|
|
28
|
+
</div>
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
const data = {
|
|
32
|
+
name: "Test",
|
|
33
|
+
price: { retailPrice: 300.5 },
|
|
34
|
+
qty: 2
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
ReactUtils.updateRefs(refs.current, data);
|
|
38
|
+
|
|
39
|
+
expect(refs.current.name.current?.value).toBe(data.name);
|
|
40
|
+
expect(refs.current.retailPrice.current?.value).toBe(
|
|
41
|
+
data.price.retailPrice.toString()
|
|
42
|
+
);
|
|
43
|
+
expect(refs.current.qty.current?.value).toBe(data.qty.toString());
|
|
44
|
+
|
|
45
|
+
const newData: Partial<typeof data> = {};
|
|
46
|
+
ReactUtils.updateRefValues(refs.current, newData);
|
|
47
|
+
|
|
48
|
+
expect(newData.name).toBe(data.name);
|
|
49
|
+
expect(newData.price?.retailPrice).toBe(data.price.retailPrice);
|
|
50
|
+
expect(newData.qty).toBe(data.qty);
|
|
51
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@etsoo/react",
|
|
3
|
-
"version": "1.8.
|
|
3
|
+
"version": "1.8.71",
|
|
4
4
|
"description": "TypeScript ReactJs UI Independent Framework",
|
|
5
5
|
"main": "lib/cjs/index.js",
|
|
6
6
|
"module": "lib/mjs/index.js",
|
|
@@ -38,27 +38,27 @@
|
|
|
38
38
|
"@emotion/css": "^11.13.5",
|
|
39
39
|
"@emotion/react": "^11.14.0",
|
|
40
40
|
"@emotion/styled": "^11.14.1",
|
|
41
|
-
"@etsoo/appscript": "^1.6.
|
|
41
|
+
"@etsoo/appscript": "^1.6.53",
|
|
42
42
|
"@etsoo/notificationbase": "^1.1.66",
|
|
43
43
|
"@etsoo/shared": "^1.2.80",
|
|
44
44
|
"react": "^19.2.3",
|
|
45
45
|
"react-dom": "^19.2.3",
|
|
46
46
|
"react-router-dom": "^7.12.0",
|
|
47
|
-
"react-window": "^2.2.
|
|
47
|
+
"react-window": "^2.2.5"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
|
-
"@babel/cli": "^7.28.
|
|
51
|
-
"@babel/core": "^7.28.
|
|
50
|
+
"@babel/cli": "^7.28.6",
|
|
51
|
+
"@babel/core": "^7.28.6",
|
|
52
52
|
"@babel/plugin-transform-runtime": "^7.28.5",
|
|
53
|
-
"@babel/preset-env": "^7.28.
|
|
54
|
-
"@babel/runtime-corejs3": "^7.28.
|
|
53
|
+
"@babel/preset-env": "^7.28.6",
|
|
54
|
+
"@babel/runtime-corejs3": "^7.28.6",
|
|
55
55
|
"@testing-library/jest-dom": "^6.9.1",
|
|
56
56
|
"@testing-library/react": "^16.3.1",
|
|
57
|
-
"@types/react": "^19.2.
|
|
57
|
+
"@types/react": "^19.2.8",
|
|
58
58
|
"@types/react-dom": "^19.2.3",
|
|
59
59
|
"@vitejs/plugin-react": "^5.1.2",
|
|
60
60
|
"jsdom": "^27.4.0",
|
|
61
61
|
"typescript": "^5.9.3",
|
|
62
|
-
"vitest": "^4.0.
|
|
62
|
+
"vitest": "^4.0.17"
|
|
63
63
|
}
|
|
64
64
|
}
|
package/__tests__/ReactUtils.ts
DELETED