Skip to content

Commit

Permalink
Refactor planning test to make it easier to figure out motions
Browse files Browse the repository at this point in the history
Co-authored-by: Alex Ruddick <[email protected]>
  • Loading branch information
Jonathan Dahan and alexrudd2 committed Oct 26, 2023
1 parent d28d2c3 commit 4dccf46
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions src/__tests__/planning.test.ts
Original file line number Diff line number Diff line change
@@ -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([]))
});
Expand All @@ -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},
]);
});

Expand All @@ -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},
]);
});

Expand All @@ -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},
]);
});

Expand Down

0 comments on commit 4dccf46

Please sign in to comment.