Skip to content

Commit bef0c64

Browse files
committed
test: Added storeMock for easier mocking xr state in the tests
1 parent 172257c commit bef0c64

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

src/mocks/storeMock.ts

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import create from 'zustand'
2+
import * as React from 'react'
3+
import * as THREE from 'three'
4+
import { XRState } from '../context'
5+
import { Group } from 'three'
6+
import { XRInteractionHandler, XRInteractionType } from '@react-three/xr'
7+
8+
export const createStoreMock = () =>
9+
create<XRState>((set, get) => ({
10+
set,
11+
get,
12+
13+
controllers: [],
14+
isPresenting: false,
15+
isHandTracking: false,
16+
player: new Group(),
17+
session: null,
18+
foveation: 0,
19+
referenceSpace: 'local-floor',
20+
21+
hoverState: {
22+
left: new Map(),
23+
right: new Map(),
24+
none: new Map()
25+
},
26+
interactions: new Map(),
27+
hasInteraction(_object: THREE.Object3D, _eventType: XRInteractionType) {
28+
return false
29+
},
30+
getInteraction(_object: THREE.Object3D, _eventType: XRInteractionType) {
31+
return []
32+
},
33+
addInteraction(_object: THREE.Object3D, _eventType: XRInteractionType, _handlerRef: React.RefObject<XRInteractionHandler>) {},
34+
removeInteraction(_object: THREE.Object3D, _eventType: XRInteractionType, _handlerRef: React.RefObject<XRInteractionHandler>) {}
35+
}))

0 commit comments

Comments
 (0)