@rokkit/helpers 1.4.0 → 1.4.2

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.
@@ -8,7 +8,7 @@ export function updateMedia(): void;
8
8
  * @param {string} query
9
9
  * @returns {Object}
10
10
  */
11
- export const matchMediaMock: import("vitest").Mock<(...args: any[]) => any>;
11
+ export const matchMediaMock: import("vitest").Mock<import("@vitest/spy").Procedure>;
12
12
  export type MediaQuery = {
13
13
  "min-width"?: integer;
14
14
  "max-width"?: integer;
@@ -7,8 +7,8 @@
7
7
  export function simulateMouseEvent(x: number, y: number): {
8
8
  clientX: number;
9
9
  clientY: number;
10
- stopPropagation: import("vitest").Mock<(...args: any[]) => any>;
11
- preventDefault: import("vitest").Mock<(...args: any[]) => any>;
10
+ stopPropagation: import("vitest").Mock<import("@vitest/spy").Procedure>;
11
+ preventDefault: import("vitest").Mock<import("@vitest/spy").Procedure>;
12
12
  };
13
13
  /**
14
14
  * Simulates a touch event on a given node.
@@ -21,8 +21,8 @@ export function simulateTouchEvent(clientX: number, clientY: number): {
21
21
  clientX: number;
22
22
  clientY: number;
23
23
  }[];
24
- preventDefault: import("vitest").Mock<(...args: any[]) => any>;
25
- stopPropagation: import("vitest").Mock<(...args: any[]) => any>;
24
+ preventDefault: import("vitest").Mock<import("@vitest/spy").Procedure>;
25
+ stopPropagation: import("vitest").Mock<import("@vitest/spy").Procedure>;
26
26
  };
27
27
  /**
28
28
  * Simulates a touch swipe on a given node.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rokkit/helpers",
3
- "version": "1.4.0",
3
+ "version": "1.4.2",
4
4
  "description": "Custom matchers for vitest, mocks and simulators for testing.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -42,10 +42,12 @@
42
42
  "prepublishOnly": "cp ../../LICENSE . && tsc --project tsconfig.build.json",
43
43
  "postpublish": "rm -f LICENSE",
44
44
  "clean": "rm -rf dist",
45
- "build": "bun clean && bun prepublishOnly"
45
+ "build": "bun clean && bun prepublishOnly",
46
+ "check:build": "bun run clean && tsc --project tsconfig.build.json"
46
47
  },
47
48
  "dependencies": {
48
- "@vitest/expect": "^4.0.18",
49
+ "@vitest/expect": "^4.1.11",
50
+ "@vitest/spy": "^4.1.11",
49
51
  "ramda": "^0.32.0"
50
52
  }
51
53
  }
@@ -1,6 +1,12 @@
1
1
  import { vi } from 'vitest'
2
2
 
3
- global.Touch = vi.fn().mockImplementation((input) => input)
3
+ // `function`, not an arrow: callers do `new Touch({...})`, and arrows have no
4
+ // [[Construct]]. vitest 3 wrapped the implementation in a constructable shim;
5
+ // vitest 4 invokes it directly, so an arrow here throws "is not a constructor".
6
+ // A constructor returning an object yields that object, so `new Touch(x) === x`.
7
+ global.Touch = vi.fn().mockImplementation(function (input) {
8
+ return input
9
+ })
4
10
 
5
11
  /**
6
12
  * Simulates a mouse event on a given node.