-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(extension): add test for curved-edge
- Loading branch information
1 parent
79203f1
commit c2a92dc
Showing
2 changed files
with
70 additions
and
24 deletions.
There are no files selected for viewing
43 changes: 43 additions & 0 deletions
43
packages/extension/src/materials/curved-edge/__test__/curved-edge.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { getCurvedEdgePath } from '../index'; | ||
|
||
describe('test curved edge ', () => { | ||
test('path calculation', () => { | ||
const radius = 5; | ||
|
||
const points1 = '460,150 670,150'; | ||
const path1 = 'M460 150 L 670 150'; | ||
expect( | ||
getCurvedEdgePath( | ||
points1.split(' ').map((p) => p.split(',').map((a) => +a)), | ||
radius, | ||
), | ||
).toBe(path1); | ||
|
||
const points2 = '510,250 540,250 540,175 490,175 490,100 520,100'; | ||
const path2 = 'M510 250L 510 250L 535 250 Q 540 250 540 245L 540 245L 540 180 Q 540 175 535 175L 535 175L 495 175 Q 490 175 490 170L 490 170L 490 105 Q 490 100 495 100L 520 100'; | ||
expect( | ||
getCurvedEdgePath( | ||
points2.split(' ').map((p) => p.split(',').map((a) => +a)), | ||
radius, | ||
), | ||
).toBe(path2); | ||
|
||
const points3 = '690,120 720,120 720,50 560,50 560,260 690,260'; | ||
const path3 = 'M690 120L 690 120L 715 120 Q 720 120 720 115L 720 115L 720 55 Q 720 50 715 50L 715 50L 565 50 Q 560 50 560 55L 560 55L 560 255 Q 560 260 565 260L 690 260'; | ||
expect( | ||
getCurvedEdgePath( | ||
points3.split(' ').map((p) => p.split(',').map((a) => +a)), | ||
radius, | ||
), | ||
).toBe(path3); | ||
|
||
const point4 = '690,180 690,210 660,210 660,190 630,190 630,220'; | ||
const path4 = 'M690 180L 690 180L 690 205 Q 690 210 685 210L 685 210L 665 210 Q 660 210 660 205L 660 205L 660 195 Q 660 190 655 190L 655 190L 635 190 Q 630 190 630 195L 630 220'; | ||
expect( | ||
getCurvedEdgePath( | ||
point4.split(' ').map((p) => p.split(',').map((a) => +a)), | ||
radius, | ||
), | ||
).toBe(path4); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters