1
0
Fork 0

add plugin-bundle tests

This commit is contained in:
Chris Barrett 2021-11-17 22:18:52 +01:00
parent f45e1df1bf
commit 83c68f7dac
10 changed files with 590 additions and 572 deletions

View file

@ -0,0 +1,4 @@
{
"presets": ["@babel/preset-env"]
}

View file

@ -31,7 +31,7 @@
"clean": "rimraf dist",
"build": "rollup -c",
"lernabuild": "rollup -c",
"test": "echo \"plugin-bundle: No tests configured. Perhaps you'd like to do this?\" && exit 0",
"test": "BABEL_ENV=production ../../node_modules/.bin/mocha tests/*.test.js --require @babel/register",
"pubtest": "npm publish --registry http://localhost:6662",
"pubforce": "npm publish",
"symlink": "mkdir -p ./node_modules/@freesewing && cd ./node_modules/@freesewing && ln -s -f ../../../* . && cd -",

View file

@ -1,4 +1,4 @@
import freesewing from "freesewing";
import freesewing from "@freesewing/core";
let expect = require("chai").expect;
let plugin = require("../dist/index.js");
let bundle = [

View file

@ -1,17 +1,18 @@
import freesewing from "freesewing";
import { version } from "../node_modules/@freesewing/plugin-cutonfold/package.json";
import freesewing from "@freesewing/core";
import { version } from "../../plugin-cutonfold/package.json";
let expect = require("chai").expect;
let plugin = require("../dist/index.js");
it("Should set the plugin name:version attribute", () => {
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
);
});
});
it("Should run the default cutonfold macro", () => {
it("Should run the default cutonfold macro", () => {
let pattern = new freesewing.Pattern();
pattern.draft = function() {};
pattern.use(plugin);
@ -34,7 +35,7 @@ it("Should run the default cutonfold macro", () => {
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.x).to.equal(10); //needs to be rounded
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);
@ -42,9 +43,9 @@ it("Should run the default cutonfold macro", () => {
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", () => {
it("Should run the cutonfold/grainline macro", () => {
let pattern = new freesewing.Pattern();
pattern.draft = function() {};
pattern.use(plugin);
@ -59,4 +60,5 @@ it("Should run the cutonfold/grainline macro", () => {
});
let c = pattern.parts.test.paths.cutonfold;
expect(c.attributes.get("data-text")).to.equal("cutOnFoldAndGrainline");
});
});

View file

@ -1,17 +1,18 @@
import freesewing from "freesewing";
import { version } from "../node_modules/@freesewing/plugin-dimension/package.json";
import freesewing from "@freesewing/core";
import { version } from "../../plugin-dimension/package.json";
let expect = require("chai").expect;
let plugin = require("../dist/index.js");
it("Should set the plugin name:version attribute", () => {
describe("plugin-dimension", 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
);
});
});
it("Should run the hd macro", () => {
it("Should run the hd macro", () => {
let pattern = new freesewing.Pattern();
pattern.draft = function() {};
pattern.use(plugin);
@ -52,9 +53,9 @@ 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", () => {
it("Should run the vd macro", () => {
let pattern = new freesewing.Pattern();
pattern.draft = function() {};
pattern.use(plugin);
@ -95,9 +96,9 @@ 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", () => {
it("Should run the ld macro", () => {
let pattern = new freesewing.Pattern();
pattern.draft = function() {};
pattern.use(plugin);
@ -138,9 +139,9 @@ it("Should run the ld macro", () => {
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 run the pd macro", () => {
let pattern = new freesewing.Pattern();
pattern.draft = function() {};
pattern.use(plugin);
@ -182,4 +183,5 @@ 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);
});
});

View file

@ -1,17 +1,18 @@
import freesewing from "freesewing";
import { version } from "../node_modules/@freesewing/plugin-grainline/package.json";
import freesewing from "@freesewing/core";
import { version } from "../../plugin-grainline/package.json";
let expect = require("chai").expect;
let plugin = require("../dist/index.js");
it("Should set the plugin name:version attribute", () => {
describe("plugin-grainline", 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-grainline")).to.equal(
version
);
});
});
it("Should run the default grainline macro", () => {
it("Should run the default grainline macro", () => {
let pattern = new freesewing.Pattern();
pattern.draft = function() {};
pattern.use(plugin);
@ -35,4 +36,5 @@ it("Should run the default grainline macro", () => {
expect(c.ops[0].to.y).to.equal(30.5);
expect(c.ops[1].to.x).to.equal(10);
expect(c.ops[1].to.y).to.equal(219.5);
});
});

View file

@ -1,12 +1,14 @@
import freesewing from "freesewing";
import { version } from "../node_modules/@freesewing/plugin-round/package.json";
import freesewing from "@freesewing/core";
import { version } from "../../plugin-round/package.json";
let expect = require("chai").expect;
let plugin = require("../dist/index.js");
it("Should set the plugin name:version attribute", () => {
describe("plugin-round", 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-round")).to.equal(
version
);
});
});

View file

@ -1,17 +1,18 @@
import freesewing from "freesewing";
import { version } from "../node_modules/@freesewing/plugin-scalebox/package.json";
import freesewing from "@freesewing/core";
import { version } from "../../plugin-scalebox/package.json";
let expect = require("chai").expect;
let plugin = require("../dist/index.js");
it("Should set the plugin name:version attribute", () => {
describe("plugin-scalebox", 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-scalebox")).to.equal(
version
);
});
});
it("Should run the default scalebox macro", () => {
it("Should run the default scalebox macro", () => {
let pattern = new freesewing.Pattern();
pattern.draft = function() {};
pattern.use(plugin);
@ -80,9 +81,9 @@ it("Should run the default scalebox macro", () => {
expect(p.ops[2].to.y).to.equal(225.4);
expect(p.ops[3].to.x).to.equal(150.8);
expect(p.ops[3].to.y).to.equal(174.6);
});
});
it("Should run the scalebox macro with rotation", () => {
it("Should run the scalebox macro with rotation", () => {
let pattern = new freesewing.Pattern();
pattern.draft = function() {};
pattern.use(plugin);
@ -122,9 +123,9 @@ it("Should run the scalebox macro with rotation", () => {
expect(p.__scaleboxMetric.y).to.equal(200);
expect(p.__scaleboxImperial.x).to.equal(124);
expect(p.__scaleboxImperial.y).to.equal(200);
});
});
it("Should run the scalebox macro with default text", () => {
it("Should run the scalebox macro with default text", () => {
let pattern = new freesewing.Pattern({
name: "unitTest",
version: 99
@ -153,9 +154,9 @@ it("Should run the scalebox macro with default text", () => {
expect(p.list["data-text"][2]).to.equal(
"withTheFinancialSupportOfOurPatrons"
);
});
});
it("Should run the scalebox macro with custom text", () => {
it("Should run the scalebox macro with custom text", () => {
let pattern = new freesewing.Pattern({
name: "unitTest",
version: 99
@ -181,4 +182,5 @@ it("Should run the scalebox macro with custom text", () => {
expect(p.get("data-text")).to.equal("theText");
expect(p.get("data-text-class")).to.equal("text-xs");
expect(p.get("data-text-lineheight")).to.equal("4");
});
});

View file

@ -1,12 +1,14 @@
import freesewing from "freesewing";
import { version } from "../node_modules/@freesewing/plugin-sprinkle/package.json";
import freesewing from "@freesewing/core";
import { version } from "../../plugin-sprinkle/package.json";
let expect = require("chai").expect;
let plugin = require("../dist/index.js");
it("Should set the plugin name:version attribute", () => {
describe('plugin-sprinkle', 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-sprinkle")).to.equal(
version
);
});
});

View file

@ -1,18 +1,19 @@
import freesewing from "freesewing";
import { version } from "../node_modules/@freesewing/plugin-title/package.json";
import freesewing from "@freesewing/core";
import { version } from "../../plugin-title/package.json";
let expect = require("chai").expect;
let plugin = require("../dist/index.js");
it("Should set the plugin name:version attribute", () => {
describe('plugin-title', function () {
it("Should set the plugin name:version attribute", () => {
let pattern = new freesewing.Pattern();
pattern.use(plugin);
pattern.render();
expect(pattern.svg.attributes.get("freesewing:plugin-title")).to.equal(
version
);
});
});
it("Should run the title macro", () => {
it("Should run the title macro", () => {
let pattern = new freesewing.Pattern({ name: "testPattern", version: 99 });
pattern.draft = function() {};
pattern.use(plugin);
@ -46,9 +47,9 @@ it("Should run the title macro", () => {
);
expect(p.attributes.get("data-text-x")).to.equal("-12");
expect(p.attributes.get("data-text-y")).to.equal("-14");
});
});
it("Should run the title macro with append flag", () => {
it("Should run the title macro with append flag", () => {
let pattern = new freesewing.Pattern({ name: "testPattern", version: 99 });
pattern.use(plugin);
pattern.draft = function() {};
@ -74,9 +75,9 @@ it("Should run the title macro with append flag", () => {
);
expect(p.attributes.get("data-text-x")).to.equal("-12");
expect(p.attributes.get("data-text-y")).to.equal("-34");
});
});
it("Should run the title macro with point prefix", () => {
it("Should run the title macro with point prefix", () => {
let pattern = new freesewing.Pattern({ name: "testPattern", version: 99 });
pattern.draft = function() {};
pattern.use(plugin);
@ -114,4 +115,5 @@ it("Should run the title macro with point prefix", () => {
);
expect(p.attributes.get("data-text-x")).to.equal("-12");
expect(p.attributes.get("data-text-y")).to.equal("-14");
});
});