Skip to content

Commit d7fd70c

Browse files
test(layers): convert ColumnGeometry cap test to vitest
1 parent 46be1ef commit d7fd70c

1 file changed

Lines changed: 19 additions & 30 deletions

File tree

test/modules/layers/column-geometry.spec.ts

Lines changed: 19 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -93,29 +93,26 @@ test('ColumnGeometry#tesselation', () => {
9393
]), 'positions generated').toBeTruthy();
9494
});
9595

96-
test('ColumnGeometry#cap', t => {
96+
test('ColumnGeometry#cap', () => {
9797
const nradial = 4;
9898
const vertsAroundEdge = nradial + 1;
9999

100-
t.comment('cone cap');
101100
// capSegs = 1 for cone
102-
const capSegs_cone = 1;
103-
const expectedConeVerts = vertsAroundEdge * 2 * (1 + capSegs_cone) + capSegs_cone + 1;
101+
const capSegsCone = 1;
102+
const expectedConeVerts = vertsAroundEdge * 2 * (1 + capSegsCone) + capSegsCone + 1;
104103
let geometry = new ColumnGeometry({radius: 1, height: 1, nradial, cap: 'cone'});
105104
let attributes = geometry.getAttributes();
106105

107-
t.is(
108-
attributes.POSITION.value.length,
109-
expectedConeVerts * 3,
110-
'cone cap POSITION has correct size'
106+
expect(attributes.POSITION.value.length, 'cone cap POSITION has correct size').toBe(
107+
expectedConeVerts * 3
111108
);
112-
t.is(
113-
attributes.NORMAL.value.length,
114-
expectedConeVerts * 3,
115-
'cone cap NORMAL has correct size'
109+
expect(attributes.NORMAL.value.length, 'cone cap NORMAL has correct size').toBe(
110+
expectedConeVerts * 3
116111
);
117112
// wireframe indices unchanged (covers sides only)
118-
t.is(attributes.indices.value.length, nradial * 3 * 2, 'cone cap indices has correct size');
113+
expect(attributes.indices.value.length, 'cone cap indices has correct size').toBe(
114+
nradial * 3 * 2
115+
);
119116

120117
// Verify apex vertices (ring_1 = theta=PI/2) have z = height/2 + radius = 1/2 + 1 = 1.5
121118
// and position (0, 0, 1.5) (radius * cos(PI/2) = 0)
@@ -129,40 +126,32 @@ test('ColumnGeometry#cap', t => {
129126
foundApex = true;
130127
}
131128
}
132-
t.ok(foundApex, 'cone cap has apex vertex at (0, 0, height/2 + radius)');
129+
expect(foundApex, 'cone cap has apex vertex at (0, 0, height/2 + radius)').toBeTruthy();
133130

134-
t.comment('dome cap');
135131
// capSegs = max(2, round(nradial/4)) for dome; nradial=4 → max(2,1) = 2
136-
const capSegs_dome = Math.max(2, Math.round(nradial / 4));
137-
const expectedDomeVerts = vertsAroundEdge * 2 * (1 + capSegs_dome) + capSegs_dome + 1;
132+
const capSegsDome = Math.max(2, Math.round(nradial / 4));
133+
const expectedDomeVerts = vertsAroundEdge * 2 * (1 + capSegsDome) + capSegsDome + 1;
138134
geometry = new ColumnGeometry({radius: 1, height: 1, nradial, cap: 'dome'});
139135
attributes = geometry.getAttributes();
140136

141-
t.is(
142-
attributes.POSITION.value.length,
143-
expectedDomeVerts * 3,
144-
'dome cap POSITION has correct size'
137+
expect(attributes.POSITION.value.length, 'dome cap POSITION has correct size').toBe(
138+
expectedDomeVerts * 3
145139
);
146140

147141
// Verify side geometry is preserved (first 8 side vertices unchanged from flat)
148142
const flatGeometry = new ColumnGeometry({radius: 1, height: 1, nradial});
149143
const flatAttributes = flatGeometry.getAttributes();
150-
t.ok(
144+
expect(
151145
equals(
152146
attributes.POSITION.value.slice(0, 3 * 8),
153147
flatAttributes.POSITION.value.slice(0, 3 * 8)
154148
),
155149
'dome cap: side positions match flat'
156-
);
150+
).toBeTruthy();
157151

158-
t.comment('cap prop ignored when not extruded');
159152
geometry = new ColumnGeometry({radius: 1, height: 0, nradial, cap: 'dome'});
160153
attributes = geometry.getAttributes();
161-
t.is(
162-
attributes.POSITION.value.length,
163-
nradial * 3,
164-
'cap ignored when height=0 (not extruded)'
154+
expect(attributes.POSITION.value.length, 'cap ignored when height=0 (not extruded)').toBe(
155+
nradial * 3
165156
);
166-
167-
t.end();
168157
});

0 commit comments

Comments
 (0)