11import { describe , it , expect , beforeEach , afterEach } from "vitest" ;
22import { GlyphSceneElement } from "./GlyphSceneElement" ;
33import { GlyphPerspectiveCameraElement } from "./GlyphPerspectiveCameraElement" ;
4+ import { GlyphOrthographicCameraElement } from "./GlyphOrthographicCameraElement" ;
45
56// Register elements if not already registered.
67if ( ! customElements . get ( "glyph-scene" ) ) {
@@ -9,6 +10,13 @@ if (!customElements.get("glyph-scene")) {
910if ( ! customElements . get ( "glyph-perspective-camera" ) ) {
1011 customElements . define ( "glyph-perspective-camera" , GlyphPerspectiveCameraElement ) ;
1112}
13+ if ( ! customElements . get ( "glyph-orthographic-camera" ) ) {
14+ customElements . define ( "glyph-orthographic-camera" , GlyphOrthographicCameraElement ) ;
15+ }
16+ if ( ! customElements . get ( "glyph-camera" ) ) {
17+ class GlyphCameraElement extends GlyphOrthographicCameraElement { }
18+ customElements . define ( "glyph-camera" , GlyphCameraElement ) ;
19+ }
1220
1321describe ( "GlyphSceneElement" , ( ) => {
1422 let camEl : GlyphPerspectiveCameraElement ;
@@ -139,8 +147,17 @@ describe("GlyphSceneElement", () => {
139147 expect ( ( ) => {
140148 document . body . appendChild ( orphanScene ) ;
141149 } ) . toThrow (
142- "glyphcss: <glyph-scene> must be placed inside a <glyph-perspective-camera> or <glyph-orthographic-camera>." ,
150+ "glyphcss: <glyph-scene> must be placed inside a <glyph-camera>, <glyph- perspective-camera>, or <glyph-orthographic-camera>." ,
143151 ) ;
144152 orphanScene . remove ( ) ;
145153 } ) ;
154+
155+ it ( "mounts inside the <glyph-camera> alias (orthographic alias)" , ( ) => {
156+ const aliasCam = document . createElement ( "glyph-camera" ) ;
157+ const aliasHost = document . createElement ( "glyph-scene" ) as GlyphSceneElement ;
158+ aliasCam . appendChild ( aliasHost ) ;
159+ expect ( ( ) => { document . body . appendChild ( aliasCam ) ; } ) . not . toThrow ( ) ;
160+ expect ( aliasHost . getScene ( ) ) . not . toBeNull ( ) ;
161+ aliasCam . remove ( ) ;
162+ } ) ;
146163} ) ;
0 commit comments