File tree Expand file tree Collapse file tree 1 file changed +27
-1
lines changed
apps/astro-docs/src/content/docs/blog Expand file tree Collapse file tree 1 file changed +27
-1
lines changed Original file line number Diff line number Diff line change @@ -396,9 +396,35 @@ The testing API is currently in Developer Preview and may be subject to changes
396
396
397
397
Here's a simple example of how you might use the testing utilities:
398
398
399
- ``` ts
399
+ ``` angular- ts
400
400
import { NgtTestBed } from 'angular-three/testing';
401
401
402
+ @Component({
403
+ standalone: true,
404
+ template: `
405
+ <ngt-mesh #mesh (click)="clicked.set(!clicked())">
406
+ <ngt-box-geometry />
407
+ <ngt-mesh-standard-material [color]="color()" />
408
+ </ngt-mesh>
409
+ `,
410
+ schemas: [CUSTOM_ELEMENTS_SCHEMA],
411
+ changeDetection: ChangeDetectionStrategy.OnPush,
412
+ })
413
+ class MyThreeComponent {
414
+ clicked = signal(false);
415
+ color = computed(() => (this.clicked() ? 'hotpink' : 'orange'));
416
+
417
+ meshRef = viewChild.required<ElementRef<Mesh>>('mesh');
418
+
419
+ constructor() {
420
+ injectBeforeRender(({ delta }) => {
421
+ const mesh = this.meshRef().nativeElement;
422
+ mesh.rotation.x += delta;
423
+ mesh.rotation.y += delta;
424
+ });
425
+ }
426
+ }
427
+
402
428
describe('MyThreeComponent', () => {
403
429
it('should render a mesh', async () => {
404
430
const { scene, fireEvent, advance } = NgtTestBed.create(MyThreeComponent);
You can’t perform that action at this time.
0 commit comments