@etsoo/shared 1.2.55 → 1.2.56

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.
@@ -253,7 +253,7 @@ test("Tests for getCulture", () => {
253
253
  });
254
254
 
255
255
  test("Tests for getLocationKey", () => {
256
- expect(DomUtils.getLocationKey("test")).toBe("http://localhost/:test");
256
+ expect(DomUtils.getLocationKey("test")).toBe("http://localhost:3000/:test");
257
257
  });
258
258
 
259
259
  test("Tests for headersToObject", () => {
@@ -292,7 +292,7 @@ test("Tests for mergeURLSearchParams", () => {
292
292
 
293
293
  test("Tests for setFocus", () => {
294
294
  // Arrange
295
- const focus = jest.fn();
295
+ const focus = vi.fn();
296
296
 
297
297
  const root = document.body;
298
298
  const container = document.createElement("div");
@@ -419,7 +419,7 @@ test("Tests for getUserAgentData 8", () => {
419
419
 
420
420
  test("Tests for setupLogging", async () => {
421
421
  // Arrange
422
- const action = jest.fn((data: ErrorData) => {
422
+ const action = vi.fn((data: ErrorData) => {
423
423
  expect(data.message).toBe("Test");
424
424
  });
425
425
  DomUtils.setupLogging(action, true, globalThis.self);
@@ -29,13 +29,13 @@ test("Tests for history", () => {
29
29
  });
30
30
 
31
31
  test("Tests for events", () => {
32
- const navigatorFn = jest.fn();
33
- const navigatorStopFn = jest.fn((event: EHistoryNavigateEvent) => {
32
+ const navigatorFn = vi.fn();
33
+ const navigatorStopFn = vi.fn((event: EHistoryNavigateEvent) => {
34
34
  event.stopImmediatePropagation();
35
35
  });
36
- const clearFn = jest.fn();
37
- const pushFn = jest.fn();
38
- const replaceFn = jest.fn();
36
+ const clearFn = vi.fn();
37
+ const pushFn = vi.fn();
38
+ const replaceFn = vi.fn();
39
39
 
40
40
  const history = new LHistory(3);
41
41
 
@@ -25,7 +25,7 @@ test("Tests for applyMixins", () => {
25
25
 
26
26
  test("Tests for delayedExecutor", () => {
27
27
  // Arrange
28
- const f = jest.fn();
28
+ const f = vi.fn();
29
29
 
30
30
  const e = ExtendUtils.delayedExecutor(f, 50);
31
31
 
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "compilerOptions": {
3
3
  "target": "ES2020",
4
- "module": "ESNext",
5
- "moduleResolution": "Node10",
4
+ "module": "ES2022",
5
+ "moduleResolution": "bundler",
6
6
  "allowJs": false,
7
7
  "skipLibCheck": true,
8
8
  "esModuleInterop": true,
@@ -12,6 +12,7 @@
12
12
  "resolveJsonModule": true,
13
13
  "isolatedModules": true,
14
14
  "noEmit": true,
15
- "declaration": true
15
+ "declaration": true,
16
+ "types": ["vitest/globals"]
16
17
  }
17
18
  }
@@ -158,7 +158,7 @@ export declare namespace Utils {
158
158
  * @param ignoreFields Ignore fields
159
159
  * @returns
160
160
  */
161
- function getDataChanges(input: object, initData: object, ignoreFields?: string[]): string[];
161
+ function getDataChanges<T extends object>(input: T, initData: object, ignoreFields?: string[]): (keyof T & string)[];
162
162
  /**
163
163
  * Get nested value from object
164
164
  * @param data Data
@@ -158,7 +158,7 @@ export declare namespace Utils {
158
158
  * @param ignoreFields Ignore fields
159
159
  * @returns
160
160
  */
161
- function getDataChanges(input: object, initData: object, ignoreFields?: string[]): string[];
161
+ function getDataChanges<T extends object>(input: T, initData: object, ignoreFields?: string[]): (keyof T & string)[];
162
162
  /**
163
163
  * Get nested value from object
164
164
  * @param data Data
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etsoo/shared",
3
- "version": "1.2.55",
3
+ "version": "1.2.56",
4
4
  "description": "TypeScript shared utilities and functions",
5
5
  "main": "lib/cjs/index.js",
6
6
  "module": "lib/mjs/index.js",
@@ -14,23 +14,7 @@
14
14
  "sideEffects": false,
15
15
  "scripts": {
16
16
  "build": "tsc -p tsconfig.json && tsc -p tsconfig.cjs.json",
17
- "test": "jest",
18
- "test:debug": "node --inspect-brk ./node_modules/jest/bin/jest.js --runInBand"
19
- },
20
- "jest": {
21
- "automock": false,
22
- "testMatch": [
23
- "<rootDir>/__tests__/**/*.ts"
24
- ],
25
- "testEnvironment": "jsdom",
26
- "moduleFileExtensions": [
27
- "js",
28
- "ts",
29
- "d.ts"
30
- ],
31
- "transform": {
32
- ".+\\.ts$": "ts-jest"
33
- }
17
+ "test": "vitest"
34
18
  },
35
19
  "repository": {
36
20
  "type": "git",
@@ -54,10 +38,10 @@
54
38
  "devDependencies": {
55
39
  "@types/jest": "^29.5.14",
56
40
  "@types/lodash.isequal": "^4.5.8",
57
- "jest": "^29.7.0",
58
- "jest-environment-jsdom": "^29.7.0",
59
- "ts-jest": "^29.2.5",
60
- "typescript": "^5.7.2"
41
+ "@vitejs/plugin-react": "^4.3.4",
42
+ "jsdom": "^26.0.0",
43
+ "typescript": "^5.7.3",
44
+ "vitest": "^2.1.8"
61
45
  },
62
46
  "dependencies": {
63
47
  "lodash.isequal": "^4.5.0"
package/src/Utils.ts CHANGED
@@ -403,13 +403,13 @@ export namespace Utils {
403
403
  * @param ignoreFields Ignore fields
404
404
  * @returns
405
405
  */
406
- export function getDataChanges(
407
- input: object,
406
+ export function getDataChanges<T extends object>(
407
+ input: T,
408
408
  initData: object,
409
409
  ignoreFields: string[] = ["id"]
410
- ): string[] {
410
+ ): (keyof T & string)[] {
411
411
  // Changed fields
412
- const changes: string[] = [];
412
+ const changes: (keyof T & string)[] = [];
413
413
 
414
414
  Object.entries(input).forEach(([key, value]) => {
415
415
  // Ignore fields, no process
@@ -431,7 +431,7 @@ export namespace Utils {
431
431
  Reflect.deleteProperty(input, key);
432
432
  return;
433
433
  }
434
- changes.push(key);
434
+ changes.push(key as any);
435
435
  return;
436
436
  }
437
437
 
@@ -451,7 +451,7 @@ export namespace Utils {
451
451
  }
452
452
 
453
453
  // Hold the key
454
- changes.push(key);
454
+ changes.push(key as any);
455
455
  });
456
456
 
457
457
  return changes;
package/tsconfig.cjs.json CHANGED
@@ -10,7 +10,7 @@
10
10
  "declaration": true,
11
11
  "strict": true,
12
12
  "esModuleInterop": true,
13
- "skipLibCheck": true,
13
+ "skipLibCheck": false,
14
14
  "forceConsistentCasingInFileNames": true,
15
15
  "lib": ["dom", "dom.iterable", "ESNext"]
16
16
  },
package/tsconfig.json CHANGED
@@ -2,15 +2,15 @@
2
2
  "compilerOptions": {
3
3
  /* Visit https://aka.ms/tsconfig.json to read more about this file */
4
4
  "target": "ES2020",
5
- "module": "ESNext",
6
- "moduleResolution": "Node10",
5
+ "module": "ES2020",
6
+ "moduleResolution": "bundler",
7
7
  "isolatedModules": true,
8
8
  "outDir": "./lib/mjs",
9
9
  "noEmit": false,
10
10
  "declaration": true,
11
11
  "strict": true,
12
12
  "esModuleInterop": true,
13
- "skipLibCheck": true,
13
+ "skipLibCheck": false,
14
14
  "forceConsistentCasingInFileNames": true,
15
15
  "lib": ["dom", "dom.iterable", "esnext"]
16
16
  },
@@ -0,0 +1,11 @@
1
+ import { defineConfig } from "vitest/config";
2
+ import react from "@vitejs/plugin-react";
3
+
4
+ export default defineConfig({
5
+ plugins: [react()],
6
+ test: {
7
+ globals: true,
8
+ environment: "jsdom",
9
+ include: ["__tests__/**/*.ts(x)?"]
10
+ }
11
+ });