@@ -3,10 +3,8 @@ import * as THREE from 'three'
3
3
import { ReconcilerRoot , createRoot , act , extend , ThreeElement } from '../src/index'
4
4
import { suspend } from 'suspend-react'
5
5
6
- class CustomElement extends THREE . Object3D { }
7
-
8
6
class Mock extends THREE . Group {
9
- static instances : string [ ] = [ ]
7
+ static instances : string [ ]
10
8
constructor ( name : string ) {
11
9
super ( )
12
10
this . name = name
@@ -16,12 +14,11 @@ class Mock extends THREE.Group {
16
14
17
15
declare module '@react-three/fiber' {
18
16
interface ThreeElements {
19
- customElement : ThreeElement < typeof CustomElement >
20
17
mock : ThreeElement < typeof Mock >
21
18
}
22
19
}
23
20
24
- extend ( { CustomElement , Mock } )
21
+ extend ( { Mock } )
25
22
26
23
type ComponentMesh = THREE . Mesh < THREE . BoxBufferGeometry , THREE . MeshBasicMaterial >
27
24
@@ -44,7 +41,10 @@ const expectToThrow = async (callback: () => any) => {
44
41
describe ( 'renderer' , ( ) => {
45
42
let root : ReconcilerRoot < HTMLCanvasElement > = null !
46
43
47
- beforeEach ( ( ) => ( root = createRoot ( document . createElement ( 'canvas' ) ) ) )
44
+ beforeEach ( ( ) => {
45
+ root = createRoot ( document . createElement ( 'canvas' ) )
46
+ Mock . instances = [ ]
47
+ } )
48
48
afterEach ( async ( ) => act ( async ( ) => root . unmount ( ) ) )
49
49
50
50
it ( 'should render empty JSX' , async ( ) => {
@@ -63,11 +63,11 @@ describe('renderer', () => {
63
63
} )
64
64
65
65
it ( 'should render extended elements' , async ( ) => {
66
- const store = await act ( async ( ) => root . render ( < customElement /> ) )
66
+ const store = await act ( async ( ) => root . render ( < mock /> ) )
67
67
const { scene } = store . getState ( )
68
68
69
69
expect ( scene . children . length ) . toBe ( 1 )
70
- expect ( scene . children [ 0 ] ) . toBeInstanceOf ( CustomElement )
70
+ expect ( scene . children [ 0 ] ) . toBeInstanceOf ( Mock )
71
71
} )
72
72
73
73
it ( 'should render primitives' , async ( ) => {
0 commit comments