@lalalic/markcut 3.2.54 → 3.2.56

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,24 @@
1
+ import {describe, it, expect} from 'vitest';
2
+ import {projectSchematicRoute, pointAtRouteProgress, routeSvgPath} from '../src/utils/schematic-route';
3
+
4
+ describe('offline Markcut schematic route', () => {
5
+ it('keeps endpoints in bounds and animates marker between them', () => {
6
+ const pts = projectSchematicRoute([{lat:45.4236,lng:-75.7009,label:'Start'},{lat:45.4295,lng:-75.709,label:'End'}],540,960);
7
+ expect(pts).toHaveLength(2);
8
+ expect(pts.every(p=>p.x>0&&p.x<540&&p.y>0&&p.y<960)).toBe(true);
9
+ expect(pointAtRouteProgress(pts,0)).toMatchObject({x:pts[0]!.x,y:pts[0]!.y});
10
+ expect(pointAtRouteProgress(pts,1)).toMatchObject({x:pts[1]!.x,y:pts[1]!.y});
11
+ const mid = pointAtRouteProgress(pts,.5);
12
+ expect(mid.x).toBeCloseTo((pts[0]!.x+pts[1]!.x)/2,3);
13
+ expect(routeSvgPath(pts)).toMatch(/^M .* L /);
14
+ });
15
+ it('unwraps the dateline, rather than sending the route across the world', () => {
16
+ const pts=projectSchematicRoute([{lat:0,lng:179.7},{lat:0,lng:-179.7}],540,960);
17
+ expect(pts[0]!.x).toBeLessThan(pts[1]!.x);
18
+ });
19
+ it('handles stationary route and rejects invalid coordinates', () => {
20
+ const pts=projectSchematicRoute([{lat:45,lng:-75},{lat:45,lng:-75}],540,960);
21
+ expect(pointAtRouteProgress(pts,.75)).toMatchObject({x:pts[0]!.x,y:pts[0]!.y});
22
+ expect(() => projectSchematicRoute([{lat:91,lng:1}],540,960)).toThrow(/Invalid route coordinate/);
23
+ });
24
+ });