Skip to content

Commit c2c5e30

Browse files
committed
test(components): add highlight layer test
1 parent bcaeb33 commit c2c5e30

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

packages/library/src/components/hosts/MeshHost.test.tsx

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
import { ActionManager, Mesh, Vector3 } from '@babylonjs/core';
1+
import { ActionManager, Color3, HighlightLayer, Mesh, Vector3 } from '@babylonjs/core';
2+
import type { MeshProps } from '@props';
3+
import type { BabylonEntity } from '@types';
24
import { render } from '@utils/TestUtils';
35
import jest from 'jest-mock';
46

@@ -58,4 +60,20 @@ describe('Meshes tests', () => {
5860
const instanceBox = scene.getMeshByName(instanceBoxName) as Mesh;
5961
expect(instanceBox.position.equals(box.position)).toBeTruthy();
6062
});
63+
64+
test('should create an highlight layer and add a mesh to it', async () => {
65+
const highlightLayerName = 'hl';
66+
const boxName = 'box';
67+
const { scene } = render(
68+
<>
69+
<highlightLayer name={highlightLayerName}>
70+
<box name={boxName} highlightLayer={{ color: Color3.Yellow() }} />
71+
</highlightLayer>
72+
</>,
73+
);
74+
const highlightLayer = scene.getHighlightLayerByName(highlightLayerName) as HighlightLayer;
75+
const box = scene.getMeshById(boxName) as BabylonEntity<MeshProps & Mesh>;
76+
expect(box.highlightLayerParent).toBeTruthy();
77+
expect(highlightLayer.hasMesh(box)).toBeTruthy();
78+
});
6179
});

0 commit comments

Comments
 (0)