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() {
|
describe("plugin-cutonfold", function() {
|
||||||
it("Should set the plugin name:version attribute", () => {
|
it("Should set the plugin name:version attribute", () => {
|
||||||
let pattern = new freesewing.Pattern().use(plugin);
|
let pattern = new freesewing.Pattern().use(plugin);
|
||||||
pattern.render();
|
|
||||||
expect(pattern.svg.attributes.get("freesewing:plugin-cutonfold")).to.equal(
|
expect(pattern.svg.attributes.get("freesewing:plugin-cutonfold")).to.equal(
|
||||||
version
|
version
|
||||||
);
|
);
|
||||||
|
@ -26,7 +25,6 @@ describe("plugin-cutonfold", function() {
|
||||||
to: pattern.parts.test.points.to
|
to: pattern.parts.test.points.to
|
||||||
});
|
});
|
||||||
let c = pattern.parts.test.paths.cutonfold;
|
let c = pattern.parts.test.paths.cutonfold;
|
||||||
console.log(c.ops);
|
|
||||||
expect(c.attributes.get("class")).to.equal("note");
|
expect(c.attributes.get("class")).to.equal("note");
|
||||||
expect(c.attributes.get("marker-start")).to.equal("url(#cutonfoldFrom)");
|
expect(c.attributes.get("marker-start")).to.equal("url(#cutonfoldFrom)");
|
||||||
expect(c.attributes.get("marker-end")).to.equal("url(#cutonfoldTo)");
|
expect(c.attributes.get("marker-end")).to.equal("url(#cutonfoldTo)");
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
import freesewing from "@freesewing/core";
|
import freesewing from "@freesewing/core";
|
||||||
import { version } from "../../plugin-dimension/package.json";
|
import { version } from "../package.json";
|
||||||
let expect = require("chai").expect;
|
let expect = require("chai").expect;
|
||||||
let plugin = require("../dist/index.js");
|
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", () => {
|
it("Should set the plugin name:version attribute", () => {
|
||||||
let pattern = new freesewing.Pattern().use(plugin);
|
let pattern = new freesewing.Pattern().use(plugin);
|
||||||
pattern.render();
|
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();
|
let pattern = new freesewing.Pattern();
|
||||||
pattern.draft = function() {};
|
pattern.draft = function() {};
|
||||||
pattern.use(plugin);
|
pattern.use(plugin);
|
||||||
|
@ -25,38 +27,47 @@ describe("plugin-dimension", function() {
|
||||||
from: pattern.parts.test.points.from,
|
from: pattern.parts.test.points.from,
|
||||||
to: pattern.parts.test.points.to,
|
to: pattern.parts.test.points.to,
|
||||||
y: 35
|
y: 35
|
||||||
|
})
|
||||||
|
|
||||||
|
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)");
|
||||||
|
expect(c.attributes.get("data-text")).to.equal("19cm");
|
||||||
|
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(10);
|
||||||
|
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);
|
||||||
|
});
|
||||||
|
|
||||||
|
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(c.ops[0].to.x).to.equal(10);
|
||||||
|
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);
|
||||||
|
});
|
||||||
|
|
||||||
|
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(c.ops[0].to.x).to.equal(200);
|
||||||
|
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);
|
||||||
});
|
});
|
||||||
let c = pattern.parts.test.paths[1];
|
|
||||||
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)");
|
|
||||||
expect(c.attributes.get("data-text")).to.equal("19cm");
|
|
||||||
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(10);
|
|
||||||
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"];
|
|
||||||
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(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"];
|
|
||||||
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(200);
|
|
||||||
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();
|
let pattern = new freesewing.Pattern();
|
||||||
pattern.draft = function() {};
|
pattern.draft = function() {};
|
||||||
pattern.use(plugin);
|
pattern.use(plugin);
|
||||||
|
@ -69,37 +80,46 @@ describe("plugin-dimension", function() {
|
||||||
to: pattern.parts.test.points.to,
|
to: pattern.parts.test.points.to,
|
||||||
x: 25
|
x: 25
|
||||||
});
|
});
|
||||||
let c = pattern.parts.test.paths[1];
|
|
||||||
expect(c.attributes.get("class")).to.equal("mark");
|
it("Should draw a line and add text to indicate its length", () => {
|
||||||
expect(c.attributes.get("marker-start")).to.equal("url(#dimensionFrom)");
|
let c = pattern.parts.test.paths["__paperless1"];
|
||||||
expect(c.attributes.get("marker-end")).to.equal("url(#dimensionTo)");
|
expect(c.attributes.get("class")).to.equal("mark");
|
||||||
expect(c.attributes.get("data-text")).to.equal("18cm");
|
expect(c.attributes.get("marker-start")).to.equal("url(#dimensionFrom)");
|
||||||
expect(c.attributes.get("data-text-class")).to.equal("fill-mark center");
|
expect(c.attributes.get("marker-end")).to.equal("url(#dimensionTo)");
|
||||||
expect(c.ops[0].type).to.equal("move");
|
expect(c.attributes.get("data-text")).to.equal("18cm");
|
||||||
expect(c.ops[1].type).to.equal("line");
|
expect(c.attributes.get("data-text-class")).to.equal("fill-mark center");
|
||||||
expect(c.ops[0].to.x).to.equal(25);
|
expect(c.ops[0].type).to.equal("move");
|
||||||
expect(c.ops[0].to.y).to.equal(20);
|
expect(c.ops[1].type).to.equal("line");
|
||||||
expect(c.ops[1].to.x).to.equal(25);
|
expect(c.ops[0].to.x).to.equal(25);
|
||||||
expect(c.ops[1].to.y).to.equal(200);
|
expect(c.ops[0].to.y).to.equal(20);
|
||||||
c = pattern.parts.test.paths["1_ls"];
|
expect(c.ops[1].to.x).to.equal(25);
|
||||||
expect(c.attributes.get("class")).to.equal("mark dotted");
|
expect(c.ops[1].to.y).to.equal(200);
|
||||||
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);
|
it("Should draw the start marker", () => {
|
||||||
expect(c.ops[0].to.y).to.equal(20);
|
let c = pattern.parts.test.paths["__paperless1_ls"];
|
||||||
expect(c.ops[1].to.x).to.equal(25);
|
expect(c.attributes.get("class")).to.equal("mark dotted");
|
||||||
expect(c.ops[1].to.y).to.equal(20);
|
expect(c.ops[0].type).to.equal("move");
|
||||||
c = pattern.parts.test.paths["1_le"];
|
expect(c.ops[1].type).to.equal("line");
|
||||||
expect(c.attributes.get("class")).to.equal("mark dotted");
|
expect(c.ops[0].to.x).to.equal(10);
|
||||||
expect(c.ops[0].type).to.equal("move");
|
expect(c.ops[0].to.y).to.equal(20);
|
||||||
expect(c.ops[1].type).to.equal("line");
|
expect(c.ops[1].to.x).to.equal(25);
|
||||||
expect(c.ops[0].to.x).to.equal(10);
|
expect(c.ops[1].to.y).to.equal(20);
|
||||||
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 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(c.ops[0].to.x).to.equal(10);
|
||||||
|
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();
|
let pattern = new freesewing.Pattern();
|
||||||
pattern.draft = function() {};
|
pattern.draft = function() {};
|
||||||
pattern.use(plugin);
|
pattern.use(plugin);
|
||||||
|
@ -112,7 +132,9 @@ describe("plugin-dimension", function() {
|
||||||
to: pattern.parts.test.points.to,
|
to: pattern.parts.test.points.to,
|
||||||
d: 15
|
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("class")).to.equal("mark");
|
||||||
expect(c.attributes.get("marker-start")).to.equal("url(#dimensionFrom)");
|
expect(c.attributes.get("marker-start")).to.equal("url(#dimensionFrom)");
|
||||||
expect(c.attributes.get("marker-end")).to.equal("url(#dimensionTo)");
|
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.attributes.get("data-text-class")).to.equal("fill-mark center");
|
||||||
expect(c.ops[0].type).to.equal("move");
|
expect(c.ops[0].type).to.equal("move");
|
||||||
expect(c.ops[1].type).to.equal("line");
|
expect(c.ops[1].type).to.equal("line");
|
||||||
expect(c.ops[0].to.x).to.equal(20.61);
|
expect(round(c.ops[0].to.x)).to.equal(20.61);
|
||||||
expect(c.ops[0].to.y).to.equal(-0.61);
|
expect(round(c.ops[0].to.y)).to.equal(-0.61);
|
||||||
expect(c.ops[1].to.x).to.equal(110.61);
|
expect(round(c.ops[1].to.x)).to.equal(110.61);
|
||||||
expect(c.ops[1].to.y).to.equal(89.39);
|
expect(round(c.ops[1].to.y)).to.equal(89.39);
|
||||||
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.attributes.get("class")).to.equal("mark dotted");
|
||||||
expect(c.ops[0].type).to.equal("move");
|
expect(c.ops[0].type).to.equal("move");
|
||||||
expect(c.ops[1].type).to.equal("line");
|
expect(c.ops[1].type).to.equal("line");
|
||||||
expect(c.ops[0].to.x).to.equal(10);
|
expect(round(c.ops[0].to.x)).to.equal(10);
|
||||||
expect(c.ops[0].to.y).to.equal(10);
|
expect(round(c.ops[0].to.y)).to.equal(10);
|
||||||
expect(c.ops[1].to.x).to.equal(20.61);
|
expect(round(c.ops[1].to.x)).to.equal(20.61);
|
||||||
expect(c.ops[1].to.y).to.equal(-0.61);
|
expect(round(c.ops[1].to.y)).to.equal(-0.61);
|
||||||
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.attributes.get("class")).to.equal("mark dotted");
|
||||||
expect(c.ops[0].type).to.equal("move");
|
expect(c.ops[0].type).to.equal("move");
|
||||||
expect(c.ops[1].type).to.equal("line");
|
expect(c.ops[1].type).to.equal("line");
|
||||||
expect(c.ops[0].to.x).to.equal(100);
|
expect(round(c.ops[0].to.x)).to.equal(100);
|
||||||
expect(c.ops[0].to.y).to.equal(100);
|
expect(round(c.ops[0].to.y)).to.equal(100);
|
||||||
expect(c.ops[1].to.x).to.equal(110.61);
|
expect(round(c.ops[1].to.x)).to.equal(110.61);
|
||||||
expect(c.ops[1].to.y).to.equal(89.39);
|
expect(round(c.ops[1].to.y)).to.equal(89.39);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("Should run the pd macro", () => {
|
describe("Measures curved lines", () => {
|
||||||
|
|
||||||
let pattern = new freesewing.Pattern();
|
let pattern = new freesewing.Pattern();
|
||||||
pattern.draft = function() {};
|
pattern.draft = function() {};
|
||||||
pattern.use(plugin);
|
pattern.use(plugin);
|
||||||
|
@ -156,33 +186,42 @@ describe("plugin-dimension", function() {
|
||||||
path: new pattern.Path().move(from).curve(cp1, cp2, to),
|
path: new pattern.Path().move(from).curve(cp1, cp2, to),
|
||||||
d: 15
|
d: 15
|
||||||
});
|
});
|
||||||
let c = pattern.parts.test.paths[1];
|
|
||||||
expect(c.attributes.get("class")).to.equal("mark");
|
it("Should draw a line and add text to indicate the length", () => {
|
||||||
expect(c.attributes.get("marker-start")).to.equal("url(#dimensionFrom)");
|
let c = pattern.parts.test.paths["__paperless1"];
|
||||||
expect(c.attributes.get("marker-end")).to.equal("url(#dimensionTo)");
|
expect(c.attributes.get("class")).to.equal("mark");
|
||||||
expect(c.attributes.get("data-text")).to.equal("15.09cm");
|
expect(c.attributes.get("marker-start")).to.equal("url(#dimensionFrom)");
|
||||||
expect(c.attributes.get("data-text-class")).to.equal("fill-mark center");
|
expect(c.attributes.get("marker-end")).to.equal("url(#dimensionTo)");
|
||||||
expect(c.ops[0].type).to.equal("move");
|
expect(c.attributes.get("data-text")).to.equal("15.09cm");
|
||||||
expect(c.ops[1].type).to.equal("curve");
|
expect(c.attributes.get("data-text-class")).to.equal("fill-mark center");
|
||||||
expect(c.ops[0].to.x).to.equal(10);
|
expect(c.ops[0].type).to.equal("move");
|
||||||
expect(c.ops[0].to.y).to.equal(25);
|
expect(c.ops[1].type).to.equal("curve");
|
||||||
expect(c.ops[1].to.x).to.equal(37.15);
|
expect(round(c.ops[0].to.x)).to.equal(10);
|
||||||
expect(c.ops[1].to.y).to.equal(32.79);
|
expect(round(c.ops[0].to.y)).to.equal(25);
|
||||||
c = pattern.parts.test.paths["1_ls"];
|
expect(round(c.ops[1].to.x)).to.equal(37.15);
|
||||||
expect(c.attributes.get("class")).to.equal("mark dotted");
|
expect(round(c.ops[1].to.y)).to.equal(32.79);
|
||||||
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);
|
it("Should draw the start marker", () => {
|
||||||
expect(c.ops[0].to.y).to.equal(10);
|
let c = pattern.parts.test.paths["__paperless1_ls"];
|
||||||
expect(c.ops[1].to.x).to.equal(10);
|
expect(c.attributes.get("class")).to.equal("mark dotted");
|
||||||
expect(c.ops[1].to.y).to.equal(25);
|
expect(c.ops[0].type).to.equal("move");
|
||||||
c = pattern.parts.test.paths["1_le"];
|
expect(c.ops[1].type).to.equal("line");
|
||||||
expect(c.attributes.get("class")).to.equal("mark dotted");
|
expect(c.ops[0].to.x).to.equal(10);
|
||||||
expect(c.ops[0].type).to.equal("move");
|
expect(c.ops[0].to.y).to.equal(10);
|
||||||
expect(c.ops[1].type).to.equal("line");
|
expect(c.ops[1].to.x).to.equal(10);
|
||||||
expect(c.ops[0].to.x).to.equal(100);
|
expect(c.ops[1].to.y).to.equal(25);
|
||||||
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);
|
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(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(100);
|
||||||
|
expect(c.ops[1].to.y).to.equal(115);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -2,9 +2,6 @@
|
||||||
"presets": [
|
"presets": [
|
||||||
[
|
[
|
||||||
"@babel/preset-env",
|
"@babel/preset-env",
|
||||||
{
|
|
||||||
"useBuiltIns": "entry"
|
|
||||||
}
|
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
Binary file not shown.
|
@ -2,184 +2,226 @@ import freesewing from "@freesewing/core";
|
||||||
import { version } from "../package.json";
|
import { version } from "../package.json";
|
||||||
let expect = require("chai").expect;
|
let expect = require("chai").expect;
|
||||||
let plugin = require("../dist/index.js");
|
let plugin = require("../dist/index.js");
|
||||||
|
let round = freesewing.utils.round;
|
||||||
|
|
||||||
it("Should set the plugin name:version attribute", () => {
|
describe("The dimension plugin", function() {
|
||||||
let pattern = new freesewing.Pattern().use(plugin);
|
|
||||||
pattern.render();
|
|
||||||
expect(pattern.svg.attributes.get("freesewing:plugin-dimension")).to.equal(
|
|
||||||
version
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("Should run the hd macro", () => {
|
it("Should set the plugin name:version attribute", () => {
|
||||||
let pattern = new freesewing.Pattern();
|
let pattern = new freesewing.Pattern().use(plugin);
|
||||||
pattern.draft = function() {};
|
pattern.render();
|
||||||
pattern.use(plugin);
|
expect(pattern.svg.attributes.get("freesewing:plugin-dimension")).to.equal(
|
||||||
pattern.parts.test = new pattern.Part();
|
version
|
||||||
pattern.parts.test.points.from = new pattern.Point(10, 20);
|
);
|
||||||
pattern.parts.test.points.to = new pattern.Point(200, 20);
|
|
||||||
let { macro } = pattern.parts.test.shorthand();
|
|
||||||
macro("hd", {
|
|
||||||
from: pattern.parts.test.points.from,
|
|
||||||
to: pattern.parts.test.points.to,
|
|
||||||
y: 35
|
|
||||||
});
|
});
|
||||||
let c = pattern.parts.test.paths[1];
|
|
||||||
expect(c.attributes.get("class")).to.equal("mark");
|
describe("Measures horizontal dimensions", function() {
|
||||||
expect(c.attributes.get("marker-start")).to.equal("url(#dimensionFrom)");
|
|
||||||
expect(c.attributes.get("marker-end")).to.equal("url(#dimensionTo)");
|
let pattern = new freesewing.Pattern();
|
||||||
expect(c.attributes.get("data-text")).to.equal("19cm");
|
pattern.draft = function() {};
|
||||||
expect(c.attributes.get("data-text-class")).to.equal("fill-mark center");
|
pattern.use(plugin);
|
||||||
expect(c.ops[0].type).to.equal("move");
|
pattern.parts.test = new pattern.Part();
|
||||||
expect(c.ops[1].type).to.equal("line");
|
pattern.parts.test.points.from = new pattern.Point(10, 20);
|
||||||
expect(c.ops[0].to.x).to.equal(10);
|
pattern.parts.test.points.to = new pattern.Point(200, 20);
|
||||||
expect(c.ops[0].to.y).to.equal(35);
|
let { macro } = pattern.parts.test.shorthand();
|
||||||
expect(c.ops[1].to.x).to.equal(200);
|
macro("hd", {
|
||||||
expect(c.ops[1].to.y).to.equal(35);
|
from: pattern.parts.test.points.from,
|
||||||
c = pattern.parts.test.paths["1_ls"];
|
to: pattern.parts.test.points.to,
|
||||||
expect(c.attributes.get("class")).to.equal("mark dotted");
|
y: 35
|
||||||
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);
|
it("should draw a line and add text to indicate its length", () => {
|
||||||
expect(c.ops[0].to.y).to.equal(20);
|
let c = pattern.parts.test.paths["__paperless1"];
|
||||||
expect(c.ops[1].to.x).to.equal(10);
|
expect(c.attributes.get("class")).to.equal("mark");
|
||||||
expect(c.ops[1].to.y).to.equal(35);
|
expect(c.attributes.get("marker-start")).to.equal("url(#dimensionFrom)");
|
||||||
c = pattern.parts.test.paths["1_le"];
|
expect(c.attributes.get("marker-end")).to.equal("url(#dimensionTo)");
|
||||||
expect(c.attributes.get("class")).to.equal("mark dotted");
|
expect(c.attributes.get("data-text")).to.equal("19cm");
|
||||||
expect(c.ops[0].type).to.equal("move");
|
expect(c.attributes.get("data-text-class")).to.equal("fill-mark center");
|
||||||
expect(c.ops[1].type).to.equal("line");
|
expect(c.ops[0].type).to.equal("move");
|
||||||
expect(c.ops[0].to.x).to.equal(200);
|
expect(c.ops[1].type).to.equal("line");
|
||||||
expect(c.ops[0].to.y).to.equal(20);
|
expect(c.ops[0].to.x).to.equal(10);
|
||||||
expect(c.ops[1].to.x).to.equal(200);
|
expect(c.ops[0].to.y).to.equal(35);
|
||||||
expect(c.ops[1].to.y).to.equal(35);
|
expect(c.ops[1].to.x).to.equal(200);
|
||||||
});
|
expect(c.ops[1].to.y).to.equal(35);
|
||||||
|
});
|
||||||
it("Should run the vd macro", () => {
|
|
||||||
let pattern = new freesewing.Pattern();
|
it("should draw the start marker", () => {
|
||||||
pattern.draft = function() {};
|
let c = pattern.parts.test.paths["__paperless1_ls"];
|
||||||
pattern.use(plugin);
|
expect(c.attributes.get("class")).to.equal("mark dotted");
|
||||||
pattern.parts.test = new pattern.Part();
|
expect(c.ops[0].type).to.equal("move");
|
||||||
pattern.parts.test.points.from = new pattern.Point(10, 20);
|
expect(c.ops[1].type).to.equal("line");
|
||||||
pattern.parts.test.points.to = new pattern.Point(10, 200);
|
expect(c.ops[0].to.x).to.equal(10);
|
||||||
let { macro } = pattern.parts.test.shorthand();
|
expect(c.ops[0].to.y).to.equal(20);
|
||||||
macro("vd", {
|
expect(c.ops[1].to.x).to.equal(10);
|
||||||
from: pattern.parts.test.points.from,
|
expect(c.ops[1].to.y).to.equal(35);
|
||||||
to: pattern.parts.test.points.to,
|
});
|
||||||
x: 25
|
|
||||||
|
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(c.ops[0].to.x).to.equal(200);
|
||||||
|
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);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
let c = pattern.parts.test.paths[1];
|
|
||||||
expect(c.attributes.get("class")).to.equal("mark");
|
describe("Measures vertical dimensions", () => {
|
||||||
expect(c.attributes.get("marker-start")).to.equal("url(#dimensionFrom)");
|
let pattern = new freesewing.Pattern();
|
||||||
expect(c.attributes.get("marker-end")).to.equal("url(#dimensionTo)");
|
pattern.draft = function() {};
|
||||||
expect(c.attributes.get("data-text")).to.equal("18cm");
|
pattern.use(plugin);
|
||||||
expect(c.attributes.get("data-text-class")).to.equal("fill-mark center");
|
pattern.parts.test = new pattern.Part();
|
||||||
expect(c.ops[0].type).to.equal("move");
|
pattern.parts.test.points.from = new pattern.Point(10, 20);
|
||||||
expect(c.ops[1].type).to.equal("line");
|
pattern.parts.test.points.to = new pattern.Point(10, 200);
|
||||||
expect(c.ops[0].to.x).to.equal(25);
|
let { macro } = pattern.parts.test.shorthand();
|
||||||
expect(c.ops[0].to.y).to.equal(20);
|
macro("vd", {
|
||||||
expect(c.ops[1].to.x).to.equal(25);
|
from: pattern.parts.test.points.from,
|
||||||
expect(c.ops[1].to.y).to.equal(200);
|
to: pattern.parts.test.points.to,
|
||||||
c = pattern.parts.test.paths["1_ls"];
|
x: 25
|
||||||
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(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"];
|
|
||||||
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(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", () => {
|
it("Should draw a line and add text to indicate its length", () => {
|
||||||
let pattern = new freesewing.Pattern();
|
let c = pattern.parts.test.paths["__paperless1"];
|
||||||
pattern.draft = function() {};
|
expect(c.attributes.get("class")).to.equal("mark");
|
||||||
pattern.use(plugin);
|
expect(c.attributes.get("marker-start")).to.equal("url(#dimensionFrom)");
|
||||||
pattern.parts.test = new pattern.Part();
|
expect(c.attributes.get("marker-end")).to.equal("url(#dimensionTo)");
|
||||||
pattern.parts.test.points.from = new pattern.Point(10, 10);
|
expect(c.attributes.get("data-text")).to.equal("18cm");
|
||||||
pattern.parts.test.points.to = new pattern.Point(100, 100);
|
expect(c.attributes.get("data-text-class")).to.equal("fill-mark center");
|
||||||
let { macro } = pattern.parts.test.shorthand();
|
expect(c.ops[0].type).to.equal("move");
|
||||||
macro("ld", {
|
expect(c.ops[1].type).to.equal("line");
|
||||||
from: pattern.parts.test.points.from,
|
expect(c.ops[0].to.x).to.equal(25);
|
||||||
to: pattern.parts.test.points.to,
|
expect(c.ops[0].to.y).to.equal(20);
|
||||||
d: 15
|
expect(c.ops[1].to.x).to.equal(25);
|
||||||
});
|
expect(c.ops[1].to.y).to.equal(200);
|
||||||
let c = pattern.parts.test.paths[1];
|
});
|
||||||
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)");
|
|
||||||
expect(c.attributes.get("data-text")).to.equal("12.73cm");
|
|
||||||
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);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("Should run the pd macro", () => {
|
it("Should draw the start marker", () => {
|
||||||
let pattern = new freesewing.Pattern();
|
let c = pattern.parts.test.paths["__paperless1_ls"];
|
||||||
pattern.draft = function() {};
|
expect(c.attributes.get("class")).to.equal("mark dotted");
|
||||||
pattern.use(plugin);
|
expect(c.ops[0].type).to.equal("move");
|
||||||
pattern.parts.test = new pattern.Part();
|
expect(c.ops[1].type).to.equal("line");
|
||||||
let from = new pattern.Point(10, 10);
|
expect(c.ops[0].to.x).to.equal(10);
|
||||||
let cp1 = new pattern.Point(100, 10);
|
expect(c.ops[0].to.y).to.equal(20);
|
||||||
let cp2 = new pattern.Point(10, 100);
|
expect(c.ops[1].to.x).to.equal(25);
|
||||||
let to = new pattern.Point(100, 100);
|
expect(c.ops[1].to.y).to.equal(20);
|
||||||
let { macro } = pattern.parts.test.shorthand();
|
});
|
||||||
macro("pd", {
|
|
||||||
path: new pattern.Path().move(from).curve(cp1, cp2, to),
|
it("Should draw the end marker", () => {
|
||||||
d: 15
|
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(c.ops[0].to.x).to.equal(10);
|
||||||
|
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);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("Measures the length of straight lines", () => {
|
||||||
|
let pattern = new freesewing.Pattern();
|
||||||
|
pattern.draft = function() {};
|
||||||
|
pattern.use(plugin);
|
||||||
|
pattern.parts.test = new pattern.Part();
|
||||||
|
pattern.parts.test.points.from = new pattern.Point(10, 10);
|
||||||
|
pattern.parts.test.points.to = new pattern.Point(100, 100);
|
||||||
|
let { macro } = pattern.parts.test.shorthand();
|
||||||
|
macro("ld", {
|
||||||
|
from: pattern.parts.test.points.from,
|
||||||
|
to: pattern.parts.test.points.to,
|
||||||
|
d: 15
|
||||||
|
});
|
||||||
|
|
||||||
|
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)");
|
||||||
|
expect(c.attributes.get("data-text")).to.equal("12.73cm");
|
||||||
|
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(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", () => {
|
||||||
|
|
||||||
|
let pattern = new freesewing.Pattern();
|
||||||
|
pattern.draft = function() {};
|
||||||
|
pattern.use(plugin);
|
||||||
|
pattern.parts.test = new pattern.Part();
|
||||||
|
let from = new pattern.Point(10, 10);
|
||||||
|
let cp1 = new pattern.Point(100, 10);
|
||||||
|
let cp2 = new pattern.Point(10, 100);
|
||||||
|
let to = new pattern.Point(100, 100);
|
||||||
|
let { macro } = pattern.parts.test.shorthand();
|
||||||
|
macro("pd", {
|
||||||
|
path: new pattern.Path().move(from).curve(cp1, cp2, to),
|
||||||
|
d: 15
|
||||||
|
});
|
||||||
|
|
||||||
|
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)");
|
||||||
|
expect(c.attributes.get("data-text")).to.equal("15.09cm");
|
||||||
|
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(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");
|
||||||
|
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(10);
|
||||||
|
expect(c.ops[1].to.y).to.equal(25);
|
||||||
|
});
|
||||||
|
|
||||||
|
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(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(100);
|
||||||
|
expect(c.ops[1].to.y).to.equal(115);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
let c = pattern.parts.test.paths[1];
|
|
||||||
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)");
|
|
||||||
expect(c.attributes.get("data-text")).to.equal("15.09cm");
|
|
||||||
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(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(10);
|
|
||||||
expect(c.ops[1].to.y).to.equal(25);
|
|
||||||
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(100);
|
|
||||||
expect(c.ops[1].to.y).to.equal(115);
|
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue