-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjest.setup.js
More file actions
68 lines (63 loc) · 1.35 KB
/
Copy pathjest.setup.js
File metadata and controls
68 lines (63 loc) · 1.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
// Mock Three.js and Socket.IO since they're browser-specific
global.THREE = {
Scene: jest.fn(),
PerspectiveCamera: jest.fn(),
WebGLRenderer: jest.fn(() => ({
setSize: jest.fn(),
render: jest.fn(),
domElement: document.createElement('canvas')
})),
Mesh: jest.fn(),
Group: jest.fn(() => ({
add: jest.fn(),
remove: jest.fn(),
children: []
})),
Color: jest.fn(),
Vector2: jest.fn(),
Vector3: jest.fn(),
Raycaster: jest.fn(),
MeshPhongMaterial: jest.fn(),
ShaderMaterial: jest.fn(),
TextGeometry: jest.fn(),
FontLoader: jest.fn(() => ({
load: jest.fn((url, callback) => callback({}))
}))
};
// Mock Socket.IO
global.io = jest.fn(() => ({
on: jest.fn(),
emit: jest.fn()
}));
// Mock DOM elements and functions
global.document = {
createElement: jest.fn(tag => ({
style: {},
classList: {
add: jest.fn(),
remove: jest.fn()
},
appendChild: jest.fn(),
addEventListener: jest.fn()
})),
getElementById: jest.fn(id => ({
style: {},
classList: {
add: jest.fn(),
remove: jest.fn()
},
appendChild: jest.fn(),
addEventListener: jest.fn()
}))
};
global.window = {
innerWidth: 1024,
innerHeight: 768,
addEventListener: jest.fn()
};
// Mock requestAnimationFrame
global.requestAnimationFrame = jest.fn(callback => setTimeout(callback, 0));
// Reset all mocks before each test
beforeEach(() => {
jest.clearAllMocks();
});