@rokkit/helpers 1.0.0-next.149 → 1.0.0-next.151

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rokkit/helpers",
3
- "version": "1.0.0-next.149",
3
+ "version": "1.0.0-next.151",
4
4
  "description": "Custom matchers for vitest, mocks and simulators for testing.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -5,41 +5,37 @@ if (!global.Element.prototype.getAnimations) {
5
5
  global.Element.prototype.getAnimations = vi.fn().mockReturnValue([])
6
6
  }
7
7
 
8
- if (!global.Element.prototype.animate) {
9
- global.Element.prototype.animate = vi.fn().mockImplementation(() => {
10
- // Use getter/setter so Svelte's `animation.onfinish = callback` assignment
11
- // immediately queues the callback, simulating instant animation completion.
12
- let _onfinish = null
13
- let _oncancel = null
14
- return {
15
- play: vi.fn(),
16
- pause: vi.fn(),
17
- finish: vi.fn(),
18
- cancel: vi.fn(),
19
- reverse: vi.fn(),
20
- persist: vi.fn(),
21
- get onfinish() {
22
- return _onfinish
23
- },
24
- set onfinish(cb) {
25
- _onfinish = cb
26
- if (cb) queueMicrotask(() => cb())
27
- },
28
- get oncancel() {
29
- return _oncancel
30
- },
31
- set oncancel(cb) {
32
- _oncancel = cb
33
- },
34
- currentTime: 0,
35
- startTime: 0,
36
- playbackRate: 1,
37
- playState: 'finished',
38
- finished: Promise.resolve(),
39
- effect: {
40
- getTiming: vi.fn(),
41
- getComputedTiming: vi.fn()
42
- }
8
+ // Use getter/setter so Svelte's `animation.onfinish = callback` assignment
9
+ // immediately queues the callback, simulating instant animation completion.
10
+ function createAnimationMock() {
11
+ let _onfinish = null
12
+ let _oncancel = null
13
+ return {
14
+ play: vi.fn(),
15
+ pause: vi.fn(),
16
+ finish: vi.fn(),
17
+ cancel: vi.fn(),
18
+ reverse: vi.fn(),
19
+ persist: vi.fn(),
20
+ get onfinish() { return _onfinish },
21
+ set onfinish(cb) {
22
+ _onfinish = cb
23
+ if (cb) queueMicrotask(() => cb())
24
+ },
25
+ get oncancel() { return _oncancel },
26
+ set oncancel(cb) { _oncancel = cb },
27
+ currentTime: 0,
28
+ startTime: 0,
29
+ playbackRate: 1,
30
+ playState: 'finished',
31
+ finished: Promise.resolve(),
32
+ effect: {
33
+ getTiming: vi.fn(),
34
+ getComputedTiming: vi.fn()
43
35
  }
44
- })
36
+ }
37
+ }
38
+
39
+ if (!global.Element.prototype.animate) {
40
+ global.Element.prototype.animate = vi.fn().mockImplementation(createAnimationMock)
45
41
  }