Skip to content

Commit ec06fa3

Browse files
committed
test: fix tests
1 parent 5ad9823 commit ec06fa3

File tree

4 files changed

+19
-4
lines changed

4 files changed

+19
-4
lines changed

src/__tests__/createChart.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ export default function createChart<
5959

6060
const ctx = canvas.getContext('2d')!;
6161

62+
// remove Path2D since not properly working
63+
(window as any).Path2D = null;
6264
const t = new Chart<TYPE, DATA, LABEL>(ctx, config);
6365

6466
return {

src/controllers/EulerDiagramController.spec.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { EulerDiagramController } from './EulerDiagramController';
33
import { extractSets } from '../data';
44
import { ArcSlice } from '../elements';
55
import createChart from '../__tests__/createChart';
6-
import { describe, beforeAll, test } from 'vitest';
6+
import { describe, beforeAll, test, expect } from 'vitest';
77
describe('Euler', () => {
88
beforeAll(() => {
99
registry.addControllers(EulerDiagramController);
@@ -26,9 +26,15 @@ describe('Euler', () => {
2626
{
2727
type: EulerDiagramController.id,
2828
data,
29+
options: {
30+
borderColor: 'transparent',
31+
},
2932
},
3033
1000,
3134
500
32-
).toMatchImageSnapshot();
35+
).toMatchImageSnapshot({
36+
failureThreshold: 0.02,
37+
failureThresholdType: 'percent',
38+
});
3339
});
3440
});

src/controllers/VennDiagramController.spec.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { VennDiagramController } from './VennDiagramController';
33
import { extractSets } from '../data';
44
import { ArcSlice } from '../elements';
55
import createChart from '../__tests__/createChart';
6-
import { describe, beforeAll, test } from 'vitest';
6+
import { describe, beforeAll, test, expect } from 'vitest';
77
describe('venn', () => {
88
beforeAll(() => {
99
registry.addControllers(VennDiagramController);
@@ -26,9 +26,15 @@ describe('venn', () => {
2626
{
2727
type: VennDiagramController.id as 'venn',
2828
data,
29+
options: {
30+
borderColor: 'transparent',
31+
},
2932
},
3033
1000,
3134
500
32-
).toMatchImageSnapshot();
35+
).toMatchImageSnapshot({
36+
failureThreshold: 0.02,
37+
failureThresholdType: 'percent',
38+
});
3339
});
3440
});

src/elements/ArcSlice.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ export class ArcSlice extends Element<IArcSliceProps, IArcSliceOptions> implemen
157157
// no proper angle rotation
158158
ctx.ellipse(ref.cx, ref.cy, rx, ry, rot, 0, Math.PI * 2, !arc.sweep);
159159
}
160+
ctx.closePath();
160161
}
161162

162163
if (options.backgroundColor) {

0 commit comments

Comments
 (0)