|
| 1 | +import { test, expect } from 'vitest'; |
| 2 | +import { BufferGeometry, Vector3 } from 'three'; |
| 3 | +import { ExtrusionGeometry } from '../extrusion-geometry'; |
| 4 | + |
| 5 | +test('ExtrusionGeometry should be defined', () => { |
| 6 | + expect(ExtrusionGeometry).toBeDefined(); |
| 7 | +}); |
| 8 | + |
| 9 | +test('ExtrusionGeometry extends BufferGeometry', () => { |
| 10 | + const geometry = new ExtrusionGeometry(); |
| 11 | + expect(geometry).toBeInstanceOf(ExtrusionGeometry); |
| 12 | + expect(geometry).toBeInstanceOf(BufferGeometry); |
| 13 | +}); |
| 14 | + |
| 15 | +test('ExtrusionGeometry should be of type "ExtrusionGeometry"', () => { |
| 16 | + const geometry = new ExtrusionGeometry(); |
| 17 | + expect(geometry.type).toBe('ExtrusionGeometry'); |
| 18 | +}); |
| 19 | + |
| 20 | +test('ExtrusionGeometry should have default values', () => { |
| 21 | + const geometry = new ExtrusionGeometry(); |
| 22 | + expect(geometry.parameters.points).toEqual([new Vector3()]); |
| 23 | + expect(geometry.parameters.lineWidth).toBe(0.6); |
| 24 | + expect(geometry.parameters.lineHeight).toBe(0.2); |
| 25 | + expect(geometry.parameters.radialSegments).toBe(8); |
| 26 | +}); |
| 27 | + |
| 28 | +test('ExtrusionGeometry constructor should set values', () => { |
| 29 | + const points = [new Vector3(), new Vector3()]; |
| 30 | + const lineWidth = 0.5; |
| 31 | + const lineHeight = 0.3; |
| 32 | + const radialSegments = 10; |
| 33 | + const geometry = new ExtrusionGeometry(points, lineWidth, lineHeight, radialSegments); |
| 34 | + expect(geometry.parameters.points).toEqual(points); |
| 35 | + expect(geometry.parameters.lineWidth).toBe(lineWidth); |
| 36 | + expect(geometry.parameters.lineHeight).toBe(lineHeight); |
| 37 | + expect(geometry.parameters.radialSegments).toBe(radialSegments); |
| 38 | +}); |
| 39 | + |
| 40 | +test('ExtrusionGeometry should set normals, uvs and indices', () => { |
| 41 | + const points = [new Vector3(0, 0, 0), new Vector3(1, 0, 0)]; |
| 42 | + const geometry = new ExtrusionGeometry(points); |
| 43 | + expect(geometry.attributes.position).toBeDefined(); |
| 44 | + expect(geometry.attributes.normal).toBeDefined(); |
| 45 | + expect(geometry.attributes.uv).toBeDefined(); |
| 46 | +}); |
| 47 | + |
| 48 | +test('ExtrusionGeometry should generate buffer data', () => { |
| 49 | + const points = [new Vector3(0, 0, 0), new Vector3(1, 0, 0)]; |
| 50 | + const geometry = new ExtrusionGeometry(points); |
| 51 | + expect(geometry.attributes.position.array.length).toBeGreaterThan(0); |
| 52 | + expect(geometry.attributes.normal.array.length).toBeGreaterThan(0); |
| 53 | + expect(geometry.attributes.uv.array.length).toBeGreaterThan(0); |
| 54 | +}); |
0 commit comments