Skip to content

Commit 85c4af5

Browse files
committed
docs: adjust testing in release blog
1 parent fb2459a commit 85c4af5

File tree

1 file changed

+27
-1
lines changed
  • apps/astro-docs/src/content/docs/blog

1 file changed

+27
-1
lines changed

apps/astro-docs/src/content/docs/blog/v2.mdx

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,9 +396,35 @@ The testing API is currently in Developer Preview and may be subject to changes
396396

397397
Here's a simple example of how you might use the testing utilities:
398398

399-
```ts
399+
```angular-ts
400400
import { NgtTestBed } from 'angular-three/testing';
401401
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+
402428
describe('MyThreeComponent', () => {
403429
it('should render a mesh', async () => {
404430
const { scene, fireEvent, advance } = NgtTestBed.create(MyThreeComponent);

0 commit comments

Comments
 (0)