Skip to content

Commit 39c691d

Browse files
committed
docs(ClipPolyData): migrate testClipPolyData to vitest
1 parent ed7c3c4 commit 39c691d

File tree

2 files changed

+21
-18
lines changed

2 files changed

+21
-18
lines changed

Sources/Common/DataModel/Triangle/test/testTriangle.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ it('Test vtkTriangle intersectWithTriangle coplanar', () => {
207207
expect(intersection3.coplanar).toBe(true);
208208
});
209209

210-
test('Test vtkTriangle clip', (t) => {
210+
it('Test vtkTriangle clip', () => {
211211
const points = vtkPoints.newInstance();
212212
points.setData(Float32Array.from([-1, 0, 0, 1, 0, 0, 1, 1, 0]), 3);
213213

@@ -242,12 +242,12 @@ test('Test vtkTriangle clip', (t) => {
242242
false
243243
);
244244

245-
t.equal(tris.getNumberOfCells(), 2, 'Should clip triangle into 2 triangles');
246-
t.equal(
245+
expect(tris.getNumberOfCells(), 'Should clip triangle into 2 triangles').toBe(
246+
2
247+
);
248+
expect(
247249
locatorPoints.getNumberOfPoints(),
248250
4,
249251
'Should create 4 unique kept points'
250-
);
251-
252-
t.end();
252+
).toBe(4);
253253
});

Sources/Filters/Core/ClipPolyData/test/testClipPolyData.js

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import test from 'tape';
1+
import { it, expect } from 'vitest';
22
import vtkCellArray from 'vtk.js/Sources/Common/Core/CellArray';
33
import vtkDataArray from 'vtk.js/Sources/Common/Core/DataArray';
44
import vtkPoints from 'vtk.js/Sources/Common/Core/Points';
@@ -31,7 +31,7 @@ function createSquareAsTriangles() {
3131
return polydata;
3232
}
3333

34-
test('vtkClipPolyData clips a triangle mesh and produces clipped output', (t) => {
34+
it('vtkClipPolyData clips a triangle mesh and produces clipped output', () => {
3535
const plane = vtkPlane.newInstance({
3636
origin: [0, 0, 0],
3737
normal: [1, 0, 0],
@@ -48,25 +48,28 @@ test('vtkClipPolyData clips a triangle mesh and produces clipped output', (t) =>
4848
const kept = clipper.getOutputData();
4949
const clipped = clipper.getOutputData(1);
5050

51-
t.equal(kept.getNumberOfPolys(), 3, 'kept side is triangulated into 3 polys');
52-
t.equal(
51+
expect(
52+
kept.getNumberOfPolys(),
53+
'kept side is triangulated into 3 polys'
54+
).toBe(3);
55+
expect(
5356
clipped.getNumberOfPolys(),
5457
3,
5558
'clipped side is triangulated into 3 polys'
56-
);
57-
t.equal(
59+
).toBe(3);
60+
expect(
5861
kept.getNumberOfPoints(),
5962
7,
6063
'shared point set contains originals and intersections'
64+
).toBe(7);
65+
expect(clipped.getNumberOfPoints(), 'clipped output shares point set').toBe(
66+
7
6167
);
62-
t.equal(clipped.getNumberOfPoints(), 7, 'clipped output shares point set');
6368

6469
const keptScalars = kept.getPointData().getScalars().getData();
65-
t.equal(keptScalars.length, 7, 'generated clip scalars were attached');
66-
t.ok(
70+
expect(keptScalars.length, 'generated clip scalars were attached').toBe(7);
71+
expect(
6772
Array.from(keptScalars).includes(0),
6873
'intersection points carry the clip value'
69-
);
70-
71-
t.end();
74+
).toBeTruthy();
7275
});

0 commit comments

Comments
 (0)