From 4dccf461ce92a761c7ab02164ffeb09140c0d1fb Mon Sep 17 00:00:00 2001 From: Jonathan Dahan Date: Wed, 4 Oct 2023 17:28:32 -0400 Subject: [PATCH] Refactor planning test to make it easier to figure out motions Co-authored-by: Alex Ruddick --- src/__tests__/planning.test.ts | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/src/__tests__/planning.test.ts b/src/__tests__/planning.test.ts index 86553df8..55429ee3 100644 --- a/src/__tests__/planning.test.ts +++ b/src/__tests__/planning.test.ts @@ -1,7 +1,13 @@ -import {Plan, plan, Device, AxidrawFast, XYMotion, PenMotion} from '../planning'; +import {Plan, plan, Device, AxidrawFast, XYMotion, PenMotion, defaultPlanOptions} from '../planning'; import {Vec2} from '../vec'; describe("plan", () => { + const device = Device.Axidraw + const positions = { + up: AxidrawFast.penUpPos, + down: AxidrawFast.penDownPos, + zero: device.penPctToPos(0) + } it.skip("handles an empty input", () => { expect(plan([], AxidrawFast)).toEqual(new Plan([])) }); @@ -24,8 +30,8 @@ describe("plan", () => { expect(xyMotions(p)).toEqual([ {from: {x: 0, y: 0}, to: {x: 10, y: 10}, penPos: 0}, - {from: {x: 10, y: 10}, to: {x: 10, y: 10}, penPos: AxidrawFast.penDownPos}, - {from: {x: 10, y: 10}, to: {x: 0, y: 0}, penPos: Device.Axidraw.penPctToPos(0)}, + {from: {x: 10, y: 10}, to: {x: 10, y: 10}, penPos: positions.down}, + {from: {x: 10, y: 10}, to: {x: 0, y: 0}, penPos: positions.zero}, ]); }); @@ -34,8 +40,8 @@ describe("plan", () => { expect(xyMotions(p)).toEqual([ {from: {x: 0, y: 0}, to: {x: 10, y: 10}, penPos: 0}, - {from: {x: 10, y: 10}, to: {x: 20, y: 10}, penPos: AxidrawFast.penDownPos}, - {from: {x: 20, y: 10}, to: {x: 0, y: 0}, penPos: Device.Axidraw.penPctToPos(0)}, + {from: {x: 10, y: 10}, to: {x: 20, y: 10}, penPos: positions.down}, + {from: {x: 20, y: 10}, to: {x: 0, y: 0}, penPos: positions.zero}, ]); }); @@ -47,10 +53,10 @@ describe("plan", () => { expect(xyMotions(p)).toEqual([ {from: {x: 0, y: 0}, to: {x: 10, y: 10}, penPos: 0}, - {from: {x: 10, y: 10}, to: {x: 20, y: 10}, penPos: AxidrawFast.penDownPos}, - {from: {x: 20, y: 10}, to: {x: 10, y: 20}, penPos: AxidrawFast.penUpPos}, - {from: {x: 10, y: 20}, to: {x: 20, y: 20}, penPos: AxidrawFast.penDownPos}, - {from: {x: 20, y: 20}, to: {x: 0, y: 0}, penPos: Device.Axidraw.penPctToPos(0)}, + {from: {x: 10, y: 10}, to: {x: 20, y: 10}, penPos: positions.down}, + {from: {x: 20, y: 10}, to: {x: 10, y: 20}, penPos: positions.up}, + {from: {x: 10, y: 20}, to: {x: 20, y: 20}, penPos: positions.down}, + {from: {x: 20, y: 20}, to: {x: 0, y: 0}, penPos: positions.zero}, ]); });