2018-12-08 15:41:43 +01:00
|
|
|
import freesewing from "freesewing";
|
|
|
|
import { version } from "../node_modules/@freesewing/plugin-cutonfold/package.json";
|
|
|
|
let expect = require("chai").expect;
|
|
|
|
let plugin = require("../dist/index.js");
|
|
|
|
|
|
|
|
it("Should set the plugin name:version attribute", () => {
|
2018-12-22 14:03:14 +01:00
|
|
|
let pattern = new freesewing.Pattern().use(plugin);
|
2018-12-08 15:41:43 +01:00
|
|
|
pattern.render();
|
|
|
|
expect(pattern.svg.attributes.get("freesewing:plugin-cutonfold")).to.equal(
|
|
|
|
version
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
it("Should run the default cutonfold macro", () => {
|
|
|
|
let pattern = new freesewing.Pattern();
|
|
|
|
pattern.draft = function() {};
|
2018-12-22 14:03:14 +01:00
|
|
|
pattern.use(plugin);
|
2018-12-08 15:41:43 +01:00
|
|
|
pattern.parts.test = new pattern.Part();
|
|
|
|
pattern.parts.test.points.from = new pattern.Point(10, 20);
|
|
|
|
pattern.parts.test.points.to = new pattern.Point(10, 230);
|
|
|
|
let { macro } = pattern.parts.test.shorthand();
|
|
|
|
macro("cutonfold", {
|
|
|
|
from: pattern.parts.test.points.from,
|
|
|
|
to: pattern.parts.test.points.to
|
|
|
|
});
|
|
|
|
let c = pattern.parts.test.paths.cutonfold;
|
2019-04-13 15:55:59 +02:00
|
|
|
console.log(c.ops);
|
2018-12-08 15:41:43 +01:00
|
|
|
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)");
|
|
|
|
expect(c.attributes.get("data-text")).to.equal("cutOnFold");
|
|
|
|
expect(c.attributes.get("data-text-class")).to.equal("center fill-note");
|
|
|
|
expect(c.ops[0].type).to.equal("move");
|
|
|
|
expect(c.ops[1].type).to.equal("line");
|
|
|
|
expect(c.ops[2].type).to.equal("line");
|
|
|
|
expect(c.ops[3].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(30);
|
|
|
|
expect(c.ops[1].to.y).to.equal(200);
|
|
|
|
expect(c.ops[2].to.x).to.equal(30);
|
|
|
|
expect(c.ops[2].to.y).to.equal(50);
|
|
|
|
expect(c.ops[3].to.x).to.equal(10);
|
|
|
|
expect(c.ops[3].to.y).to.equal(50);
|
|
|
|
});
|
|
|
|
|
|
|
|
it("Should run the cutonfold/grainline macro", () => {
|
|
|
|
let pattern = new freesewing.Pattern();
|
|
|
|
pattern.draft = function() {};
|
2018-12-22 14:03:14 +01:00
|
|
|
pattern.use(plugin);
|
2018-12-08 15:41:43 +01:00
|
|
|
pattern.parts.test = new pattern.Part();
|
|
|
|
pattern.parts.test.points.from = new pattern.Point(10, 20);
|
|
|
|
pattern.parts.test.points.to = new pattern.Point(10, 230);
|
|
|
|
let { macro } = pattern.parts.test.shorthand();
|
|
|
|
macro("cutonfold", {
|
|
|
|
from: pattern.parts.test.points.from,
|
|
|
|
to: pattern.parts.test.points.to,
|
|
|
|
grainline: true
|
|
|
|
});
|
|
|
|
let c = pattern.parts.test.paths.cutonfold;
|
|
|
|
expect(c.attributes.get("data-text")).to.equal("cutOnFoldAndGrainline");
|
|
|
|
});
|