|
1 | | -import { test, expect } from 'vitest'; |
| 1 | +import { test, expect, describe } from 'vitest'; |
2 | 2 | import { Path, PathType } from '../path'; |
3 | 3 | import { ExtrusionGeometry } from '../extrusion-geometry'; |
4 | 4 | import { BufferGeometry } from 'three'; |
@@ -64,66 +64,90 @@ test('.path returns an array of Vector3', () => { |
64 | 64 | expect(result[1]).toEqual({ x: 1, y: 2, z: 3 }); |
65 | 65 | }); |
66 | 66 |
|
67 | | -test('.geometry returns an ExtrusionGeometry from the path', () => { |
68 | | - const path = new Path(PathType.Travel, undefined, undefined, undefined); |
| 67 | +describe('.geometry', () => { |
| 68 | + test('returns an ExtrusionGeometry from the path', () => { |
| 69 | + const path = new Path(PathType.Travel, undefined, undefined, undefined); |
69 | 70 |
|
70 | | - path.vertices = [0, 0, 0, 1, 2, 3]; |
| 71 | + path.vertices = [0, 0, 0, 1, 2, 3]; |
71 | 72 |
|
72 | | - const result = path.geometry() as ExtrusionGeometry; |
| 73 | + const result = path.geometry() as ExtrusionGeometry; |
73 | 74 |
|
74 | | - expect(result).not.toBeNull(); |
75 | | - expect(result).toBeInstanceOf(ExtrusionGeometry); |
76 | | - expect(result.parameters.points.length).toEqual(2); |
77 | | - expect(result.parameters.closed).toEqual(false); |
78 | | -}); |
| 75 | + expect(result).not.toBeNull(); |
| 76 | + expect(result).toBeInstanceOf(ExtrusionGeometry); |
| 77 | + expect(result.parameters.points.length).toEqual(2); |
| 78 | + expect(result.parameters.closed).toEqual(false); |
| 79 | + }); |
79 | 80 |
|
80 | | -test('.geometry returns an ExtrusionGeometry with the path extrusion width', () => { |
81 | | - const path = new Path(PathType.Travel, 9, undefined, undefined); |
| 81 | + test('returns an ExtrusionGeometry with the path extrusion width', () => { |
| 82 | + const path = new Path(PathType.Travel, 9, undefined, undefined); |
82 | 83 |
|
83 | | - path.vertices = [0, 0, 0, 1, 2, 3]; |
| 84 | + path.vertices = [0, 0, 0, 1, 2, 3]; |
84 | 85 |
|
85 | | - const result = path.geometry() as ExtrusionGeometry; |
| 86 | + const result = path.geometry() as ExtrusionGeometry; |
86 | 87 |
|
87 | | - expect(result.parameters.lineWidth).toEqual(9); |
88 | | -}); |
| 88 | + expect(result.parameters.lineWidth).toEqual(9); |
| 89 | + }); |
89 | 90 |
|
90 | | -test('.geometry returns an ExtrusionGeometry with the path line height', () => { |
91 | | - const path = new Path(PathType.Travel, undefined, 5, undefined); |
| 91 | + test('returns an ExtrusionGeometry with the path line height', () => { |
| 92 | + const path = new Path(PathType.Travel, undefined, 5, undefined); |
92 | 93 |
|
93 | | - path.vertices = [0, 0, 0, 1, 2, 3]; |
| 94 | + path.vertices = [0, 0, 0, 1, 2, 3]; |
94 | 95 |
|
95 | | - const result = path.geometry() as ExtrusionGeometry; |
| 96 | + const result = path.geometry() as ExtrusionGeometry; |
96 | 97 |
|
97 | | - expect(result.parameters.lineHeight).toEqual(5); |
98 | | -}); |
| 98 | + expect(result.parameters.lineHeight).toEqual(5); |
| 99 | + }); |
99 | 100 |
|
100 | | -test('.geometry returns an empty BufferGeometry if there are less than 3 vertices', () => { |
101 | | - const path = new Path(PathType.Travel, undefined, undefined, undefined); |
| 101 | + test('returns an ExtrusionGeometry with the extrusionWidthOverride when passed', () => { |
| 102 | + const path = new Path(PathType.Travel, 9, undefined, undefined); |
102 | 103 |
|
103 | | - const result = path.geometry(); |
| 104 | + path.vertices = [0, 0, 0, 1, 2, 3]; |
104 | 105 |
|
105 | | - expect(result).not.toBeNull(); |
106 | | - expect(result).toBeInstanceOf(BufferGeometry); |
107 | | -}); |
| 106 | + const result = path.geometry({ extrusionWidthOverride: 2 }) as ExtrusionGeometry; |
108 | 107 |
|
109 | | -test('.line returns a BufferGeometry from the path', () => { |
110 | | - const path = new Path(PathType.Travel, undefined, undefined, undefined); |
| 108 | + expect(result.parameters.lineWidth).toEqual(2); |
| 109 | + }); |
111 | 110 |
|
112 | | - path.vertices = [0, 0, 0, 1, 2, 3]; |
| 111 | + test('returns an ExtrusionGeometry with the lineHeightOverride when passed', () => { |
| 112 | + const path = new Path(PathType.Travel, undefined, 5, undefined); |
113 | 113 |
|
114 | | - const result = path.line(); |
| 114 | + path.vertices = [0, 0, 0, 1, 2, 3]; |
115 | 115 |
|
116 | | - expect(result).not.toBeNull(); |
117 | | - expect(result).toBeInstanceOf(BufferGeometry); |
118 | | - expect(result.getAttribute('position').count).toEqual(2); |
| 116 | + const result = path.geometry({ lineHeightOverride: 7 }) as ExtrusionGeometry; |
| 117 | + |
| 118 | + expect(result.parameters.lineHeight).toEqual(7); |
| 119 | + }); |
| 120 | + |
| 121 | + test('returns an empty BufferGeometry if there are less than 3 vertices', () => { |
| 122 | + const path = new Path(PathType.Travel, undefined, undefined, undefined); |
| 123 | + |
| 124 | + const result = path.geometry(); |
| 125 | + |
| 126 | + expect(result).not.toBeNull(); |
| 127 | + expect(result).toBeInstanceOf(BufferGeometry); |
| 128 | + }); |
119 | 129 | }); |
120 | 130 |
|
121 | | -test('.line returns a BufferGeometry when there are no vertices', () => { |
122 | | - const path = new Path(PathType.Travel, undefined, undefined, undefined); |
| 131 | +describe('.line', () => { |
| 132 | + test('returns a BufferGeometry from the path', () => { |
| 133 | + const path = new Path(PathType.Travel, undefined, undefined, undefined); |
123 | 134 |
|
124 | | - const result = path.line(); |
| 135 | + path.vertices = [0, 0, 0, 1, 2, 3]; |
125 | 136 |
|
126 | | - expect(result).not.toBeNull(); |
127 | | - expect(result).toBeInstanceOf(BufferGeometry); |
128 | | - expect(result.getAttribute('position').count).toEqual(0); |
| 137 | + const result = path.line(); |
| 138 | + |
| 139 | + expect(result).not.toBeNull(); |
| 140 | + expect(result).toBeInstanceOf(BufferGeometry); |
| 141 | + expect(result.getAttribute('position').count).toEqual(2); |
| 142 | + }); |
| 143 | + |
| 144 | + test('returns a BufferGeometry when there are no vertices', () => { |
| 145 | + const path = new Path(PathType.Travel, undefined, undefined, undefined); |
| 146 | + |
| 147 | + const result = path.line(); |
| 148 | + |
| 149 | + expect(result).not.toBeNull(); |
| 150 | + expect(result).toBeInstanceOf(BufferGeometry); |
| 151 | + expect(result.getAttribute('position').count).toEqual(0); |
| 152 | + }); |
129 | 153 | }); |
0 commit comments