@spearwolf/twopoint5d
Version:
a library to create 2.5d realtime graphics and pixelart with three.js
32 lines • 1.28 kB
JavaScript
import { Object3D } from 'three';
import { describe, expect, it } from 'vitest';
import { findRootNode } from './findRootNode.js';
describe('findRootNode', () => {
it('should return the root node when given a child node', () => {
const rootNode = new Object3D();
const childNode = new Object3D();
rootNode.add(childNode);
const result = findRootNode(childNode);
expect(result).toBe(rootNode);
});
it('should return the root node when given a grandchild node', () => {
const rootNode = new Object3D();
const childNode = new Object3D();
rootNode.add(childNode);
const grandchildNode = new Object3D();
childNode.add(grandchildNode);
const result = findRootNode(grandchildNode);
expect(result).toBe(rootNode);
});
it('should return the same node when given a root node', () => {
const rootNode = new Object3D();
const result = findRootNode(rootNode);
expect(result).toBe(rootNode);
});
it('should return the node itself when given a node without a parent', () => {
const node = new Object3D();
const result = findRootNode(node);
expect(result).toBe(node);
});
});
//# sourceMappingURL=findRootNode.spec.js.map