fixing issues with cutonfold and dimension tests
This commit is contained in:
parent
20c2e43ee3
commit
936a23c44c
5 changed files with 360 additions and 284 deletions
|
@ -7,7 +7,6 @@ let plugin = require("../dist/index.js");
|
|||
describe("plugin-cutonfold", function() {
|
||||
it("Should set the plugin name:version attribute", () => {
|
||||
let pattern = new freesewing.Pattern().use(plugin);
|
||||
pattern.render();
|
||||
expect(pattern.svg.attributes.get("freesewing:plugin-cutonfold")).to.equal(
|
||||
version
|
||||
);
|
||||
|
@ -26,7 +25,6 @@ describe("plugin-cutonfold", function() {
|
|||
to: pattern.parts.test.points.to
|
||||
});
|
||||
let c = pattern.parts.test.paths.cutonfold;
|
||||
console.log(c.ops);
|
||||
expect(c.attributes.get("class")).to.equal("note");
|
||||
expect(c.attributes.get("marker-start")).to.equal("url(#cutonfoldFrom)");
|
||||
expect(c.attributes.get("marker-end")).to.equal("url(#cutonfoldTo)");
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
import freesewing from "@freesewing/core";
|
||||
import { version } from "../../plugin-dimension/package.json";
|
||||
import { version } from "../package.json";
|
||||
let expect = require("chai").expect;
|
||||
let plugin = require("../dist/index.js");
|
||||
const { Console } = require("console");
|
||||
let round = freesewing.utils.round;
|
||||
|
||||
describe("The dimension plugin", function() {
|
||||
|
||||
describe("plugin-dimension", function() {
|
||||
it("Should set the plugin name:version attribute", () => {
|
||||
let pattern = new freesewing.Pattern().use(plugin);
|
||||
pattern.render();
|
||||
|
@ -13,7 +14,8 @@ describe("plugin-dimension", function() {
|
|||
);
|
||||
});
|
||||
|
||||
it("Should run the hd macro", () => {
|
||||
describe("Measures horizontal dimensions", function() {
|
||||
|
||||
let pattern = new freesewing.Pattern();
|
||||
pattern.draft = function() {};
|
||||
pattern.use(plugin);
|
||||
|
@ -25,8 +27,10 @@ describe("plugin-dimension", function() {
|
|||
from: pattern.parts.test.points.from,
|
||||
to: pattern.parts.test.points.to,
|
||||
y: 35
|
||||
});
|
||||
let c = pattern.parts.test.paths[1];
|
||||
})
|
||||
|
||||
it("should draw a line and add text to indicate its length", () => {
|
||||
let c = pattern.parts.test.paths["__paperless1"];
|
||||
expect(c.attributes.get("class")).to.equal("mark");
|
||||
expect(c.attributes.get("marker-start")).to.equal("url(#dimensionFrom)");
|
||||
expect(c.attributes.get("marker-end")).to.equal("url(#dimensionTo)");
|
||||
|
@ -38,7 +42,10 @@ describe("plugin-dimension", function() {
|
|||
expect(c.ops[0].to.y).to.equal(35);
|
||||
expect(c.ops[1].to.x).to.equal(200);
|
||||
expect(c.ops[1].to.y).to.equal(35);
|
||||
c = pattern.parts.test.paths["1_ls"];
|
||||
});
|
||||
|
||||
it("should draw the start marker", () => {
|
||||
let c = pattern.parts.test.paths["__paperless1_ls"];
|
||||
expect(c.attributes.get("class")).to.equal("mark dotted");
|
||||
expect(c.ops[0].type).to.equal("move");
|
||||
expect(c.ops[1].type).to.equal("line");
|
||||
|
@ -46,7 +53,10 @@ describe("plugin-dimension", function() {
|
|||
expect(c.ops[0].to.y).to.equal(20);
|
||||
expect(c.ops[1].to.x).to.equal(10);
|
||||
expect(c.ops[1].to.y).to.equal(35);
|
||||
c = pattern.parts.test.paths["1_le"];
|
||||
});
|
||||
|
||||
it("should draw the end marker", () => {
|
||||
let c = pattern.parts.test.paths["__paperless1_le"];
|
||||
expect(c.attributes.get("class")).to.equal("mark dotted");
|
||||
expect(c.ops[0].type).to.equal("move");
|
||||
expect(c.ops[1].type).to.equal("line");
|
||||
|
@ -55,8 +65,9 @@ describe("plugin-dimension", function() {
|
|||
expect(c.ops[1].to.x).to.equal(200);
|
||||
expect(c.ops[1].to.y).to.equal(35);
|
||||
});
|
||||
});
|
||||
|
||||
it("Should run the vd macro", () => {
|
||||
describe("Measures vertical dimensions", () => {
|
||||
let pattern = new freesewing.Pattern();
|
||||
pattern.draft = function() {};
|
||||
pattern.use(plugin);
|
||||
|
@ -69,7 +80,9 @@ describe("plugin-dimension", function() {
|
|||
to: pattern.parts.test.points.to,
|
||||
x: 25
|
||||
});
|
||||
let c = pattern.parts.test.paths[1];
|
||||
|
||||
it("Should draw a line and add text to indicate its length", () => {
|
||||
let c = pattern.parts.test.paths["__paperless1"];
|
||||
expect(c.attributes.get("class")).to.equal("mark");
|
||||
expect(c.attributes.get("marker-start")).to.equal("url(#dimensionFrom)");
|
||||
expect(c.attributes.get("marker-end")).to.equal("url(#dimensionTo)");
|
||||
|
@ -81,7 +94,10 @@ describe("plugin-dimension", function() {
|
|||
expect(c.ops[0].to.y).to.equal(20);
|
||||
expect(c.ops[1].to.x).to.equal(25);
|
||||
expect(c.ops[1].to.y).to.equal(200);
|
||||
c = pattern.parts.test.paths["1_ls"];
|
||||
});
|
||||
|
||||
it("Should draw the start marker", () => {
|
||||
let c = pattern.parts.test.paths["__paperless1_ls"];
|
||||
expect(c.attributes.get("class")).to.equal("mark dotted");
|
||||
expect(c.ops[0].type).to.equal("move");
|
||||
expect(c.ops[1].type).to.equal("line");
|
||||
|
@ -89,7 +105,10 @@ describe("plugin-dimension", function() {
|
|||
expect(c.ops[0].to.y).to.equal(20);
|
||||
expect(c.ops[1].to.x).to.equal(25);
|
||||
expect(c.ops[1].to.y).to.equal(20);
|
||||
c = pattern.parts.test.paths["1_le"];
|
||||
});
|
||||
|
||||
it("Should draw the end marker", () => {
|
||||
let c = pattern.parts.test.paths["__paperless1_le"];
|
||||
expect(c.attributes.get("class")).to.equal("mark dotted");
|
||||
expect(c.ops[0].type).to.equal("move");
|
||||
expect(c.ops[1].type).to.equal("line");
|
||||
|
@ -98,8 +117,9 @@ describe("plugin-dimension", function() {
|
|||
expect(c.ops[1].to.x).to.equal(25);
|
||||
expect(c.ops[1].to.y).to.equal(200);
|
||||
});
|
||||
});
|
||||
|
||||
it("Should run the ld macro", () => {
|
||||
describe("Measures the length of straight lines", () => {
|
||||
let pattern = new freesewing.Pattern();
|
||||
pattern.draft = function() {};
|
||||
pattern.use(plugin);
|
||||
|
@ -112,7 +132,9 @@ describe("plugin-dimension", function() {
|
|||
to: pattern.parts.test.points.to,
|
||||
d: 15
|
||||
});
|
||||
let c = pattern.parts.test.paths[1];
|
||||
|
||||
it("Should draw a line and add text to indicate its length", () => {
|
||||
let c = pattern.parts.test.paths["__paperless1"];
|
||||
expect(c.attributes.get("class")).to.equal("mark");
|
||||
expect(c.attributes.get("marker-start")).to.equal("url(#dimensionFrom)");
|
||||
expect(c.attributes.get("marker-end")).to.equal("url(#dimensionTo)");
|
||||
|
@ -120,29 +142,37 @@ describe("plugin-dimension", function() {
|
|||
expect(c.attributes.get("data-text-class")).to.equal("fill-mark center");
|
||||
expect(c.ops[0].type).to.equal("move");
|
||||
expect(c.ops[1].type).to.equal("line");
|
||||
expect(c.ops[0].to.x).to.equal(20.61);
|
||||
expect(c.ops[0].to.y).to.equal(-0.61);
|
||||
expect(c.ops[1].to.x).to.equal(110.61);
|
||||
expect(c.ops[1].to.y).to.equal(89.39);
|
||||
c = pattern.parts.test.paths["1_ls"];
|
||||
expect(c.attributes.get("class")).to.equal("mark dotted");
|
||||
expect(c.ops[0].type).to.equal("move");
|
||||
expect(c.ops[1].type).to.equal("line");
|
||||
expect(c.ops[0].to.x).to.equal(10);
|
||||
expect(c.ops[0].to.y).to.equal(10);
|
||||
expect(c.ops[1].to.x).to.equal(20.61);
|
||||
expect(c.ops[1].to.y).to.equal(-0.61);
|
||||
c = pattern.parts.test.paths["1_le"];
|
||||
expect(c.attributes.get("class")).to.equal("mark dotted");
|
||||
expect(c.ops[0].type).to.equal("move");
|
||||
expect(c.ops[1].type).to.equal("line");
|
||||
expect(c.ops[0].to.x).to.equal(100);
|
||||
expect(c.ops[0].to.y).to.equal(100);
|
||||
expect(c.ops[1].to.x).to.equal(110.61);
|
||||
expect(c.ops[1].to.y).to.equal(89.39);
|
||||
expect(round(c.ops[0].to.x)).to.equal(20.61);
|
||||
expect(round(c.ops[0].to.y)).to.equal(-0.61);
|
||||
expect(round(c.ops[1].to.x)).to.equal(110.61);
|
||||
expect(round(c.ops[1].to.y)).to.equal(89.39);
|
||||
});
|
||||
|
||||
it("Should run the pd macro", () => {
|
||||
it("Should draw the start marker", () => {
|
||||
let c = pattern.parts.test.paths["__paperless1_ls"];
|
||||
expect(c.attributes.get("class")).to.equal("mark dotted");
|
||||
expect(c.ops[0].type).to.equal("move");
|
||||
expect(c.ops[1].type).to.equal("line");
|
||||
expect(round(c.ops[0].to.x)).to.equal(10);
|
||||
expect(round(c.ops[0].to.y)).to.equal(10);
|
||||
expect(round(c.ops[1].to.x)).to.equal(20.61);
|
||||
expect(round(c.ops[1].to.y)).to.equal(-0.61);
|
||||
});
|
||||
|
||||
it("Should draw the end marker", () => {
|
||||
let c = pattern.parts.test.paths["__paperless1_le"];
|
||||
expect(c.attributes.get("class")).to.equal("mark dotted");
|
||||
expect(c.ops[0].type).to.equal("move");
|
||||
expect(c.ops[1].type).to.equal("line");
|
||||
expect(round(c.ops[0].to.x)).to.equal(100);
|
||||
expect(round(c.ops[0].to.y)).to.equal(100);
|
||||
expect(round(c.ops[1].to.x)).to.equal(110.61);
|
||||
expect(round(c.ops[1].to.y)).to.equal(89.39);
|
||||
});
|
||||
});
|
||||
|
||||
describe("Measures curved lines", () => {
|
||||
|
||||
let pattern = new freesewing.Pattern();
|
||||
pattern.draft = function() {};
|
||||
pattern.use(plugin);
|
||||
|
@ -156,7 +186,9 @@ describe("plugin-dimension", function() {
|
|||
path: new pattern.Path().move(from).curve(cp1, cp2, to),
|
||||
d: 15
|
||||
});
|
||||
let c = pattern.parts.test.paths[1];
|
||||
|
||||
it("Should draw a line and add text to indicate the length", () => {
|
||||
let c = pattern.parts.test.paths["__paperless1"];
|
||||
expect(c.attributes.get("class")).to.equal("mark");
|
||||
expect(c.attributes.get("marker-start")).to.equal("url(#dimensionFrom)");
|
||||
expect(c.attributes.get("marker-end")).to.equal("url(#dimensionTo)");
|
||||
|
@ -164,11 +196,14 @@ describe("plugin-dimension", function() {
|
|||
expect(c.attributes.get("data-text-class")).to.equal("fill-mark center");
|
||||
expect(c.ops[0].type).to.equal("move");
|
||||
expect(c.ops[1].type).to.equal("curve");
|
||||
expect(c.ops[0].to.x).to.equal(10);
|
||||
expect(c.ops[0].to.y).to.equal(25);
|
||||
expect(c.ops[1].to.x).to.equal(37.15);
|
||||
expect(c.ops[1].to.y).to.equal(32.79);
|
||||
c = pattern.parts.test.paths["1_ls"];
|
||||
expect(round(c.ops[0].to.x)).to.equal(10);
|
||||
expect(round(c.ops[0].to.y)).to.equal(25);
|
||||
expect(round(c.ops[1].to.x)).to.equal(37.15);
|
||||
expect(round(c.ops[1].to.y)).to.equal(32.79);
|
||||
});
|
||||
|
||||
it("Should draw the start marker", () => {
|
||||
let c = pattern.parts.test.paths["__paperless1_ls"];
|
||||
expect(c.attributes.get("class")).to.equal("mark dotted");
|
||||
expect(c.ops[0].type).to.equal("move");
|
||||
expect(c.ops[1].type).to.equal("line");
|
||||
|
@ -176,7 +211,10 @@ describe("plugin-dimension", function() {
|
|||
expect(c.ops[0].to.y).to.equal(10);
|
||||
expect(c.ops[1].to.x).to.equal(10);
|
||||
expect(c.ops[1].to.y).to.equal(25);
|
||||
c = pattern.parts.test.paths["1_le"];
|
||||
});
|
||||
|
||||
it("Should draw the end marker", () => {
|
||||
let c = pattern.parts.test.paths["__paperless1_le"];
|
||||
expect(c.attributes.get("class")).to.equal("mark dotted");
|
||||
expect(c.ops[0].type).to.equal("move");
|
||||
expect(c.ops[1].type).to.equal("line");
|
||||
|
@ -185,4 +223,5 @@ describe("plugin-dimension", function() {
|
|||
expect(c.ops[1].to.x).to.equal(100);
|
||||
expect(c.ops[1].to.y).to.equal(115);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -2,9 +2,6 @@
|
|||
"presets": [
|
||||
[
|
||||
"@babel/preset-env",
|
||||
{
|
||||
"useBuiltIns": "entry"
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
|
|
Binary file not shown.
|
@ -2,16 +2,20 @@ import freesewing from "@freesewing/core";
|
|||
import { version } from "../package.json";
|
||||
let expect = require("chai").expect;
|
||||
let plugin = require("../dist/index.js");
|
||||
let round = freesewing.utils.round;
|
||||
|
||||
it("Should set the plugin name:version attribute", () => {
|
||||
describe("The dimension plugin", function() {
|
||||
|
||||
it("Should set the plugin name:version attribute", () => {
|
||||
let pattern = new freesewing.Pattern().use(plugin);
|
||||
pattern.render();
|
||||
expect(pattern.svg.attributes.get("freesewing:plugin-dimension")).to.equal(
|
||||
version
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe("Measures horizontal dimensions", function() {
|
||||
|
||||
it("Should run the hd macro", () => {
|
||||
let pattern = new freesewing.Pattern();
|
||||
pattern.draft = function() {};
|
||||
pattern.use(plugin);
|
||||
|
@ -23,8 +27,10 @@ it("Should run the hd macro", () => {
|
|||
from: pattern.parts.test.points.from,
|
||||
to: pattern.parts.test.points.to,
|
||||
y: 35
|
||||
});
|
||||
let c = pattern.parts.test.paths[1];
|
||||
})
|
||||
|
||||
it("should draw a line and add text to indicate its length", () => {
|
||||
let c = pattern.parts.test.paths["__paperless1"];
|
||||
expect(c.attributes.get("class")).to.equal("mark");
|
||||
expect(c.attributes.get("marker-start")).to.equal("url(#dimensionFrom)");
|
||||
expect(c.attributes.get("marker-end")).to.equal("url(#dimensionTo)");
|
||||
|
@ -36,7 +42,10 @@ it("Should run the hd macro", () => {
|
|||
expect(c.ops[0].to.y).to.equal(35);
|
||||
expect(c.ops[1].to.x).to.equal(200);
|
||||
expect(c.ops[1].to.y).to.equal(35);
|
||||
c = pattern.parts.test.paths["1_ls"];
|
||||
});
|
||||
|
||||
it("should draw the start marker", () => {
|
||||
let c = pattern.parts.test.paths["__paperless1_ls"];
|
||||
expect(c.attributes.get("class")).to.equal("mark dotted");
|
||||
expect(c.ops[0].type).to.equal("move");
|
||||
expect(c.ops[1].type).to.equal("line");
|
||||
|
@ -44,7 +53,10 @@ it("Should run the hd macro", () => {
|
|||
expect(c.ops[0].to.y).to.equal(20);
|
||||
expect(c.ops[1].to.x).to.equal(10);
|
||||
expect(c.ops[1].to.y).to.equal(35);
|
||||
c = pattern.parts.test.paths["1_le"];
|
||||
});
|
||||
|
||||
it("should draw the end marker", () => {
|
||||
let c = pattern.parts.test.paths["__paperless1_le"];
|
||||
expect(c.attributes.get("class")).to.equal("mark dotted");
|
||||
expect(c.ops[0].type).to.equal("move");
|
||||
expect(c.ops[1].type).to.equal("line");
|
||||
|
@ -52,9 +64,10 @@ it("Should run the hd macro", () => {
|
|||
expect(c.ops[0].to.y).to.equal(20);
|
||||
expect(c.ops[1].to.x).to.equal(200);
|
||||
expect(c.ops[1].to.y).to.equal(35);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it("Should run the vd macro", () => {
|
||||
describe("Measures vertical dimensions", () => {
|
||||
let pattern = new freesewing.Pattern();
|
||||
pattern.draft = function() {};
|
||||
pattern.use(plugin);
|
||||
|
@ -67,7 +80,9 @@ it("Should run the vd macro", () => {
|
|||
to: pattern.parts.test.points.to,
|
||||
x: 25
|
||||
});
|
||||
let c = pattern.parts.test.paths[1];
|
||||
|
||||
it("Should draw a line and add text to indicate its length", () => {
|
||||
let c = pattern.parts.test.paths["__paperless1"];
|
||||
expect(c.attributes.get("class")).to.equal("mark");
|
||||
expect(c.attributes.get("marker-start")).to.equal("url(#dimensionFrom)");
|
||||
expect(c.attributes.get("marker-end")).to.equal("url(#dimensionTo)");
|
||||
|
@ -79,7 +94,10 @@ it("Should run the vd macro", () => {
|
|||
expect(c.ops[0].to.y).to.equal(20);
|
||||
expect(c.ops[1].to.x).to.equal(25);
|
||||
expect(c.ops[1].to.y).to.equal(200);
|
||||
c = pattern.parts.test.paths["1_ls"];
|
||||
});
|
||||
|
||||
it("Should draw the start marker", () => {
|
||||
let c = pattern.parts.test.paths["__paperless1_ls"];
|
||||
expect(c.attributes.get("class")).to.equal("mark dotted");
|
||||
expect(c.ops[0].type).to.equal("move");
|
||||
expect(c.ops[1].type).to.equal("line");
|
||||
|
@ -87,7 +105,10 @@ it("Should run the vd macro", () => {
|
|||
expect(c.ops[0].to.y).to.equal(20);
|
||||
expect(c.ops[1].to.x).to.equal(25);
|
||||
expect(c.ops[1].to.y).to.equal(20);
|
||||
c = pattern.parts.test.paths["1_le"];
|
||||
});
|
||||
|
||||
it("Should draw the end marker", () => {
|
||||
let c = pattern.parts.test.paths["__paperless1_le"];
|
||||
expect(c.attributes.get("class")).to.equal("mark dotted");
|
||||
expect(c.ops[0].type).to.equal("move");
|
||||
expect(c.ops[1].type).to.equal("line");
|
||||
|
@ -95,9 +116,10 @@ it("Should run the vd macro", () => {
|
|||
expect(c.ops[0].to.y).to.equal(200);
|
||||
expect(c.ops[1].to.x).to.equal(25);
|
||||
expect(c.ops[1].to.y).to.equal(200);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it("Should run the ld macro", () => {
|
||||
describe("Measures the length of straight lines", () => {
|
||||
let pattern = new freesewing.Pattern();
|
||||
pattern.draft = function() {};
|
||||
pattern.use(plugin);
|
||||
|
@ -110,7 +132,9 @@ it("Should run the ld macro", () => {
|
|||
to: pattern.parts.test.points.to,
|
||||
d: 15
|
||||
});
|
||||
let c = pattern.parts.test.paths[1];
|
||||
|
||||
it("Should draw a line and add text to indicate its length", () => {
|
||||
let c = pattern.parts.test.paths["__paperless1"];
|
||||
expect(c.attributes.get("class")).to.equal("mark");
|
||||
expect(c.attributes.get("marker-start")).to.equal("url(#dimensionFrom)");
|
||||
expect(c.attributes.get("marker-end")).to.equal("url(#dimensionTo)");
|
||||
|
@ -118,29 +142,37 @@ it("Should run the ld macro", () => {
|
|||
expect(c.attributes.get("data-text-class")).to.equal("fill-mark center");
|
||||
expect(c.ops[0].type).to.equal("move");
|
||||
expect(c.ops[1].type).to.equal("line");
|
||||
expect(c.ops[0].to.x).to.equal(20.61);
|
||||
expect(c.ops[0].to.y).to.equal(-0.61);
|
||||
expect(c.ops[1].to.x).to.equal(110.61);
|
||||
expect(c.ops[1].to.y).to.equal(89.39);
|
||||
c = pattern.parts.test.paths["1_ls"];
|
||||
expect(c.attributes.get("class")).to.equal("mark dotted");
|
||||
expect(c.ops[0].type).to.equal("move");
|
||||
expect(c.ops[1].type).to.equal("line");
|
||||
expect(c.ops[0].to.x).to.equal(10);
|
||||
expect(c.ops[0].to.y).to.equal(10);
|
||||
expect(c.ops[1].to.x).to.equal(20.61);
|
||||
expect(c.ops[1].to.y).to.equal(-0.61);
|
||||
c = pattern.parts.test.paths["1_le"];
|
||||
expect(c.attributes.get("class")).to.equal("mark dotted");
|
||||
expect(c.ops[0].type).to.equal("move");
|
||||
expect(c.ops[1].type).to.equal("line");
|
||||
expect(c.ops[0].to.x).to.equal(100);
|
||||
expect(c.ops[0].to.y).to.equal(100);
|
||||
expect(c.ops[1].to.x).to.equal(110.61);
|
||||
expect(c.ops[1].to.y).to.equal(89.39);
|
||||
});
|
||||
expect(round(c.ops[0].to.x)).to.equal(20.61);
|
||||
expect(round(c.ops[0].to.y)).to.equal(-0.61);
|
||||
expect(round(c.ops[1].to.x)).to.equal(110.61);
|
||||
expect(round(c.ops[1].to.y)).to.equal(89.39);
|
||||
});
|
||||
|
||||
it("Should draw the start marker", () => {
|
||||
let c = pattern.parts.test.paths["__paperless1_ls"];
|
||||
expect(c.attributes.get("class")).to.equal("mark dotted");
|
||||
expect(c.ops[0].type).to.equal("move");
|
||||
expect(c.ops[1].type).to.equal("line");
|
||||
expect(round(c.ops[0].to.x)).to.equal(10);
|
||||
expect(round(c.ops[0].to.y)).to.equal(10);
|
||||
expect(round(c.ops[1].to.x)).to.equal(20.61);
|
||||
expect(round(c.ops[1].to.y)).to.equal(-0.61);
|
||||
});
|
||||
|
||||
it("Should draw the end marker", () => {
|
||||
let c = pattern.parts.test.paths["__paperless1_le"];
|
||||
expect(c.attributes.get("class")).to.equal("mark dotted");
|
||||
expect(c.ops[0].type).to.equal("move");
|
||||
expect(c.ops[1].type).to.equal("line");
|
||||
expect(round(c.ops[0].to.x)).to.equal(100);
|
||||
expect(round(c.ops[0].to.y)).to.equal(100);
|
||||
expect(round(c.ops[1].to.x)).to.equal(110.61);
|
||||
expect(round(c.ops[1].to.y)).to.equal(89.39);
|
||||
});
|
||||
});
|
||||
|
||||
describe("Measures curved lines", () => {
|
||||
|
||||
it("Should run the pd macro", () => {
|
||||
let pattern = new freesewing.Pattern();
|
||||
pattern.draft = function() {};
|
||||
pattern.use(plugin);
|
||||
|
@ -154,7 +186,9 @@ it("Should run the pd macro", () => {
|
|||
path: new pattern.Path().move(from).curve(cp1, cp2, to),
|
||||
d: 15
|
||||
});
|
||||
let c = pattern.parts.test.paths[1];
|
||||
|
||||
it("Should draw a line and add text to indicate the length", () => {
|
||||
let c = pattern.parts.test.paths["__paperless1"];
|
||||
expect(c.attributes.get("class")).to.equal("mark");
|
||||
expect(c.attributes.get("marker-start")).to.equal("url(#dimensionFrom)");
|
||||
expect(c.attributes.get("marker-end")).to.equal("url(#dimensionTo)");
|
||||
|
@ -162,11 +196,14 @@ it("Should run the pd macro", () => {
|
|||
expect(c.attributes.get("data-text-class")).to.equal("fill-mark center");
|
||||
expect(c.ops[0].type).to.equal("move");
|
||||
expect(c.ops[1].type).to.equal("curve");
|
||||
expect(c.ops[0].to.x).to.equal(10);
|
||||
expect(c.ops[0].to.y).to.equal(25);
|
||||
expect(c.ops[1].to.x).to.equal(37.15);
|
||||
expect(c.ops[1].to.y).to.equal(32.79);
|
||||
c = pattern.parts.test.paths["1_ls"];
|
||||
expect(round(c.ops[0].to.x)).to.equal(10);
|
||||
expect(round(c.ops[0].to.y)).to.equal(25);
|
||||
expect(round(c.ops[1].to.x)).to.equal(37.15);
|
||||
expect(round(c.ops[1].to.y)).to.equal(32.79);
|
||||
});
|
||||
|
||||
it("Should draw the start marker", () => {
|
||||
let c = pattern.parts.test.paths["__paperless1_ls"];
|
||||
expect(c.attributes.get("class")).to.equal("mark dotted");
|
||||
expect(c.ops[0].type).to.equal("move");
|
||||
expect(c.ops[1].type).to.equal("line");
|
||||
|
@ -174,7 +211,10 @@ it("Should run the pd macro", () => {
|
|||
expect(c.ops[0].to.y).to.equal(10);
|
||||
expect(c.ops[1].to.x).to.equal(10);
|
||||
expect(c.ops[1].to.y).to.equal(25);
|
||||
c = pattern.parts.test.paths["1_le"];
|
||||
});
|
||||
|
||||
it("Should draw the end marker", () => {
|
||||
let c = pattern.parts.test.paths["__paperless1_le"];
|
||||
expect(c.attributes.get("class")).to.equal("mark dotted");
|
||||
expect(c.ops[0].type).to.equal("move");
|
||||
expect(c.ops[1].type).to.equal("line");
|
||||
|
@ -182,4 +222,6 @@ it("Should run the pd macro", () => {
|
|||
expect(c.ops[0].to.y).to.equal(100);
|
||||
expect(c.ops[1].to.x).to.equal(100);
|
||||
expect(c.ops[1].to.y).to.equal(115);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue