chore(plugin-scalebox): Ported to v3
This commit is contained in:
parent
78cf1b94ff
commit
abab2a67e9
4 changed files with 258 additions and 219 deletions
|
@ -11,4 +11,3 @@ export const plugin = {
|
||||||
// More specifically named exports
|
// More specifically named exports
|
||||||
export const scaleboxPlugin = plugin
|
export const scaleboxPlugin = plugin
|
||||||
export const pluginScalebox = plugin
|
export const pluginScalebox = plugin
|
||||||
|
|
||||||
|
|
|
@ -157,8 +157,7 @@ export function scalebox(so) {
|
||||||
if (name.indexOf('@freesewing/') !== -1) name = name.replace('@freesewing/', '')
|
if (name.indexOf('@freesewing/') !== -1) name = name.replace('@freesewing/', '')
|
||||||
this.points.__scaleboxTitle = this.points.__scaleboxTitle
|
this.points.__scaleboxTitle = this.points.__scaleboxTitle
|
||||||
.attr('data-text', name)
|
.attr('data-text', name)
|
||||||
.attr('data-text', 'v' +
|
.attr('data-text', 'v' + this.context.config?.data?.version || 'No Version')
|
||||||
this.context.config?.data?.version || 'No Version')
|
|
||||||
}
|
}
|
||||||
this.points.__scaleboxTitle.attributes.add('data-text-class', 'text-lg')
|
this.points.__scaleboxTitle.attributes.add('data-text-class', 'text-lg')
|
||||||
// Text
|
// Text
|
||||||
|
@ -185,4 +184,3 @@ export function scalebox(so) {
|
||||||
.attr('data-text', `${imperialDisplayHeight}`)
|
.attr('data-text', `${imperialDisplayHeight}`)
|
||||||
.attr('data-text-class', 'text-xs center ')
|
.attr('data-text-class', 'text-xs center ')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,221 +5,264 @@ import { plugin } from '../dist/index.mjs'
|
||||||
const expect = chai.expect
|
const expect = chai.expect
|
||||||
|
|
||||||
describe('Scalebox Plugin Tests', () => {
|
describe('Scalebox Plugin Tests', () => {
|
||||||
it("Should run the default scalebox macro", () => {
|
it('Should run the default scalebox macro', () => {
|
||||||
const Pattern = new Design()
|
const part = {
|
||||||
const pattern = new Pattern().use(plugin)
|
name: 'test',
|
||||||
pattern.parts.test = new pattern.Part();
|
draft: ({ points, Point, macro }) => {
|
||||||
pattern.parts.test.points.anchor = new pattern.Point(100, 200);
|
points.anchor = new Point(100, 200)
|
||||||
const { macro } = pattern.parts.test.shorthand()
|
macro('scalebox', {
|
||||||
macro("scalebox", {
|
at: points.anchor,
|
||||||
at: pattern.parts.test.points.anchor
|
})
|
||||||
});
|
},
|
||||||
let p = pattern.parts.test.points;
|
}
|
||||||
expect(p.__scaleboxMetricTopLeft.x).to.equal(50);
|
const Pattern = new Design({ parts: [part], plugins: [plugin] })
|
||||||
expect(p.__scaleboxMetricTopLeft.y).to.equal(175);
|
const pattern = new Pattern()
|
||||||
expect(p.__scaleboxMetricTopRight.x).to.equal(150);
|
pattern.draft()
|
||||||
expect(p.__scaleboxMetricTopRight.y).to.equal(175);
|
let p = pattern.parts.test.points
|
||||||
expect(p.__scaleboxMetricBottomLeft.x).to.equal(50);
|
expect(p.__scaleboxMetricTopLeft.x).to.equal(50)
|
||||||
expect(p.__scaleboxMetricBottomLeft.y).to.equal(225);
|
expect(p.__scaleboxMetricTopLeft.y).to.equal(175)
|
||||||
expect(p.__scaleboxMetricBottomRight.x).to.equal(150);
|
expect(p.__scaleboxMetricTopRight.x).to.equal(150)
|
||||||
expect(p.__scaleboxMetricBottomRight.y).to.equal(225);
|
expect(p.__scaleboxMetricTopRight.y).to.equal(175)
|
||||||
expect(p.__scaleboxImperialTopLeft.x).to.equal(49.2);
|
expect(p.__scaleboxMetricBottomLeft.x).to.equal(50)
|
||||||
expect(p.__scaleboxImperialTopLeft.y).to.equal(174.6);
|
expect(p.__scaleboxMetricBottomLeft.y).to.equal(225)
|
||||||
expect(p.__scaleboxImperialTopRight.x).to.equal(150.8);
|
expect(p.__scaleboxMetricBottomRight.x).to.equal(150)
|
||||||
expect(p.__scaleboxImperialTopRight.y).to.equal(174.6);
|
expect(p.__scaleboxMetricBottomRight.y).to.equal(225)
|
||||||
expect(p.__scaleboxImperialBottomLeft.x).to.equal(49.2);
|
expect(p.__scaleboxImperialTopLeft.x).to.equal(49.2)
|
||||||
expect(p.__scaleboxImperialBottomLeft.y).to.equal(225.4);
|
expect(p.__scaleboxImperialTopLeft.y).to.equal(174.6)
|
||||||
expect(p.__scaleboxImperialBottomRight.x).to.equal(150.8);
|
expect(p.__scaleboxImperialTopRight.x).to.equal(150.8)
|
||||||
expect(p.__scaleboxImperialBottomRight.y).to.equal(225.4);
|
expect(p.__scaleboxImperialTopRight.y).to.equal(174.6)
|
||||||
expect(p.__scaleboxLead.x).to.equal(55);
|
expect(p.__scaleboxImperialBottomLeft.x).to.equal(49.2)
|
||||||
expect(p.__scaleboxLead.y).to.equal(185);
|
expect(p.__scaleboxImperialBottomLeft.y).to.equal(225.4)
|
||||||
expect(p.__scaleboxTitle.x).to.equal(55);
|
expect(p.__scaleboxImperialBottomRight.x).to.equal(150.8)
|
||||||
expect(p.__scaleboxTitle.y).to.equal(195);
|
expect(p.__scaleboxImperialBottomRight.y).to.equal(225.4)
|
||||||
expect(p.__scaleboxText.x).to.equal(55);
|
expect(p.__scaleboxLead.x).to.equal(55)
|
||||||
expect(p.__scaleboxText.y).to.equal(207);
|
expect(p.__scaleboxLead.y).to.equal(185)
|
||||||
expect(p.__scaleboxLink.x).to.equal(55);
|
expect(p.__scaleboxTitle.x).to.equal(55)
|
||||||
expect(p.__scaleboxLink.y).to.equal(212);
|
expect(p.__scaleboxTitle.y).to.equal(195)
|
||||||
expect(p.__scaleboxMetric.x).to.equal(100);
|
expect(p.__scaleboxText.x).to.equal(55)
|
||||||
expect(p.__scaleboxMetric.y).to.equal(220);
|
expect(p.__scaleboxText.y).to.equal(207)
|
||||||
expect(p.__scaleboxImperial.x).to.equal(100);
|
expect(p.__scaleboxLink.x).to.equal(55)
|
||||||
expect(p.__scaleboxImperial.y).to.equal(224);
|
expect(p.__scaleboxLink.y).to.equal(212)
|
||||||
p = pattern.parts.test.paths.__scaleboxMetric;
|
expect(p.__scaleboxMetric.x).to.equal(100)
|
||||||
expect(p.ops[0].type).to.equal("move");
|
expect(p.__scaleboxMetric.y).to.equal(220)
|
||||||
expect(p.ops[1].type).to.equal("line");
|
expect(p.__scaleboxImperial.x).to.equal(100)
|
||||||
expect(p.ops[2].type).to.equal("line");
|
expect(p.__scaleboxImperial.y).to.equal(224)
|
||||||
expect(p.ops[3].type).to.equal("line");
|
p = pattern.parts.test.paths.__scaleboxMetric
|
||||||
expect(p.ops[4].type).to.equal("close");
|
expect(p.ops[0].type).to.equal('move')
|
||||||
expect(p.ops[0].to.x).to.equal(50);
|
expect(p.ops[1].type).to.equal('line')
|
||||||
expect(p.ops[0].to.y).to.equal(175);
|
expect(p.ops[2].type).to.equal('line')
|
||||||
expect(p.ops[1].to.x).to.equal(50);
|
expect(p.ops[3].type).to.equal('line')
|
||||||
expect(p.ops[1].to.y).to.equal(225);
|
expect(p.ops[4].type).to.equal('close')
|
||||||
expect(p.ops[2].to.x).to.equal(150);
|
expect(p.ops[0].to.x).to.equal(50)
|
||||||
expect(p.ops[2].to.y).to.equal(225);
|
expect(p.ops[0].to.y).to.equal(175)
|
||||||
expect(p.ops[3].to.x).to.equal(150);
|
expect(p.ops[1].to.x).to.equal(50)
|
||||||
expect(p.ops[3].to.y).to.equal(175);
|
expect(p.ops[1].to.y).to.equal(225)
|
||||||
p = pattern.parts.test.paths.__scaleboxImperial;
|
expect(p.ops[2].to.x).to.equal(150)
|
||||||
expect(p.ops[0].type).to.equal("move");
|
expect(p.ops[2].to.y).to.equal(225)
|
||||||
expect(p.ops[1].type).to.equal("line");
|
expect(p.ops[3].to.x).to.equal(150)
|
||||||
expect(p.ops[2].type).to.equal("line");
|
expect(p.ops[3].to.y).to.equal(175)
|
||||||
expect(p.ops[3].type).to.equal("line");
|
p = pattern.parts.test.paths.__scaleboxImperial
|
||||||
expect(p.ops[4].type).to.equal("close");
|
expect(p.ops[0].type).to.equal('move')
|
||||||
expect(p.ops[0].to.x).to.equal(49.2);
|
expect(p.ops[1].type).to.equal('line')
|
||||||
expect(p.ops[0].to.y).to.equal(174.6);
|
expect(p.ops[2].type).to.equal('line')
|
||||||
expect(p.ops[1].to.x).to.equal(49.2);
|
expect(p.ops[3].type).to.equal('line')
|
||||||
expect(p.ops[1].to.y).to.equal(225.4);
|
expect(p.ops[4].type).to.equal('close')
|
||||||
expect(p.ops[2].to.x).to.equal(150.8);
|
expect(p.ops[0].to.x).to.equal(49.2)
|
||||||
expect(p.ops[2].to.y).to.equal(225.4);
|
expect(p.ops[0].to.y).to.equal(174.6)
|
||||||
expect(p.ops[3].to.x).to.equal(150.8);
|
expect(p.ops[1].to.x).to.equal(49.2)
|
||||||
expect(p.ops[3].to.y).to.equal(174.6);
|
expect(p.ops[1].to.y).to.equal(225.4)
|
||||||
});
|
expect(p.ops[2].to.x).to.equal(150.8)
|
||||||
|
expect(p.ops[2].to.y).to.equal(225.4)
|
||||||
it("Should run the scalebox macro with rotation", () => {
|
expect(p.ops[3].to.x).to.equal(150.8)
|
||||||
const Pattern = new Design()
|
expect(p.ops[3].to.y).to.equal(174.6)
|
||||||
const pattern = new Pattern().use(plugin)
|
|
||||||
pattern.parts.test = new pattern.Part();
|
|
||||||
pattern.parts.test.points.anchor = new pattern.Point(100, 200);
|
|
||||||
const { macro } = pattern.parts.test.shorthand()
|
|
||||||
macro("scalebox", {
|
|
||||||
at: pattern.parts.test.points.anchor,
|
|
||||||
rotate: 90
|
|
||||||
});
|
|
||||||
const p = pattern.parts.test.points;
|
|
||||||
expect(round(p.__scaleboxMetricTopLeft.x)).to.equal(75);
|
|
||||||
expect(round(p.__scaleboxMetricTopLeft.y)).to.equal(250);
|
|
||||||
expect(round(p.__scaleboxMetricTopRight.x)).to.equal(75);
|
|
||||||
expect(round(p.__scaleboxMetricTopRight.y)).to.equal(150);
|
|
||||||
expect(round(p.__scaleboxMetricBottomLeft.x)).to.equal(125);
|
|
||||||
expect(round(p.__scaleboxMetricBottomLeft.y)).to.equal(250);
|
|
||||||
expect(round(p.__scaleboxMetricBottomRight.x)).to.equal(125);
|
|
||||||
expect(round(p.__scaleboxMetricBottomRight.y)).to.equal(150);
|
|
||||||
expect(round(p.__scaleboxImperialTopLeft.x)).to.equal(74.6);
|
|
||||||
expect(round(p.__scaleboxImperialTopLeft.y)).to.equal(250.8);
|
|
||||||
expect(round(p.__scaleboxImperialTopRight.x)).to.equal(74.6);
|
|
||||||
expect(round(p.__scaleboxImperialTopRight.y)).to.equal(149.2);
|
|
||||||
expect(round(p.__scaleboxImperialBottomLeft.x)).to.equal(125.4);
|
|
||||||
expect(round(p.__scaleboxImperialBottomLeft.y)).to.equal(250.8);
|
|
||||||
expect(round(p.__scaleboxImperialBottomRight.x)).to.equal(125.4);
|
|
||||||
expect(round(p.__scaleboxImperialBottomRight.y)).to.equal(149.2);
|
|
||||||
expect(round(p.__scaleboxLead.x)).to.equal(85);
|
|
||||||
expect(round(p.__scaleboxLead.y)).to.equal(245);
|
|
||||||
expect(round(p.__scaleboxTitle.x)).to.equal(95);
|
|
||||||
expect(round(p.__scaleboxTitle.y)).to.equal(245);
|
|
||||||
expect(round(p.__scaleboxText.x)).to.equal(107);
|
|
||||||
expect(round(p.__scaleboxText.y)).to.equal(245);
|
|
||||||
expect(round(p.__scaleboxLink.x)).to.equal(112);
|
|
||||||
expect(round(p.__scaleboxLink.y)).to.equal(245);
|
|
||||||
expect(round(p.__scaleboxMetric.x)).to.equal(120);
|
|
||||||
expect(round(p.__scaleboxMetric.y)).to.equal(200);
|
|
||||||
expect(round(p.__scaleboxImperial.x)).to.equal(124);
|
|
||||||
expect(round(p.__scaleboxImperial.y)).to.equal(200);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("Should run the scalebox macro with default text", () => {
|
|
||||||
const Pattern = new Design({ data: { version: '1.2.3', name: 'test' }})
|
|
||||||
const pattern = new Pattern().use(plugin)
|
|
||||||
pattern.parts.test = new pattern.Part();
|
|
||||||
pattern.parts.test.points.anchor = new pattern.Point(100, 200);
|
|
||||||
const { macro } = pattern.parts.test.shorthand()
|
|
||||||
macro("scalebox", {
|
|
||||||
at: pattern.parts.test.points.anchor
|
|
||||||
});
|
|
||||||
let p = pattern.parts.test.points.__scaleboxLead.attributes;
|
|
||||||
expect(p.get("data-text")).to.equal("FreeSewing");
|
|
||||||
expect(p.get("data-text-class")).to.equal("text-sm");
|
|
||||||
p = pattern.parts.test.points.__scaleboxTitle.attributes;
|
|
||||||
expect(p.get("data-text")).to.equal("test v1.2.3");
|
|
||||||
expect(p.get("data-text-class")).to.equal("text-lg");
|
|
||||||
p = pattern.parts.test.points.__scaleboxText.attributes;
|
|
||||||
expect(p.get("data-text-class")).to.equal("text-xs");
|
|
||||||
expect(p.get("data-text-lineheight")).to.equal("4");
|
|
||||||
expect(p.list["data-text"][0]).to.equal("supportFreesewingBecomeAPatron")
|
|
||||||
});
|
|
||||||
|
|
||||||
it("Should run the scalebox macro with custom text", () => {
|
|
||||||
const Pattern = new Design()
|
|
||||||
const pattern = new Pattern().use(plugin)
|
|
||||||
pattern.parts.test = new pattern.Part();
|
|
||||||
pattern.parts.test.points.anchor = new pattern.Point(100, 200);
|
|
||||||
const { macro } = pattern.parts.test.shorthand()
|
|
||||||
macro("scalebox", {
|
|
||||||
at: pattern.parts.test.points.anchor,
|
|
||||||
lead: "theLead",
|
|
||||||
title: "theTitle",
|
|
||||||
text: "theText"
|
|
||||||
});
|
|
||||||
let p = pattern.parts.test.points.__scaleboxLead.attributes;
|
|
||||||
expect(p.get("data-text")).to.equal("theLead");
|
|
||||||
expect(p.get("data-text-class")).to.equal("text-sm");
|
|
||||||
p = pattern.parts.test.points.__scaleboxTitle.attributes;
|
|
||||||
expect(p.get("data-text")).to.equal("theTitle");
|
|
||||||
expect(p.get("data-text-class")).to.equal("text-lg");
|
|
||||||
p = pattern.parts.test.points.__scaleboxText.attributes;
|
|
||||||
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");
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it("Should apply scale to the scalebox macro", () => {
|
it('Should run the scalebox macro with rotation', () => {
|
||||||
const Pattern = new Design()
|
const part = {
|
||||||
const pattern = new Pattern().use(plugin)
|
name: 'test',
|
||||||
pattern.settings.scale = 0.5
|
draft: ({ points, Point, macro }) => {
|
||||||
pattern.parts.test = new pattern.Part();
|
points.anchor = new Point(100, 200)
|
||||||
pattern.parts.test.points.anchor = new pattern.Point(100, 200);
|
macro('scalebox', {
|
||||||
const { macro } = pattern.parts.test.shorthand()
|
at: points.anchor,
|
||||||
macro("scalebox", {
|
rotate: 90,
|
||||||
at: pattern.parts.test.points.anchor
|
})
|
||||||
});
|
},
|
||||||
let p = pattern.parts.test.points;
|
}
|
||||||
expect(p.__scaleboxMetricTopLeft.x).to.equal(75);
|
const Pattern = new Design({ parts: [part], plugins: [plugin] })
|
||||||
expect(p.__scaleboxMetricTopLeft.y).to.equal(187.5);
|
const pattern = new Pattern()
|
||||||
expect(p.__scaleboxMetricTopRight.x).to.equal(125);
|
pattern.draft()
|
||||||
expect(p.__scaleboxMetricTopRight.y).to.equal(187.5);
|
const p = pattern.parts.test.points
|
||||||
expect(p.__scaleboxMetricBottomLeft.x).to.equal(75);
|
expect(round(p.__scaleboxMetricTopLeft.x)).to.equal(75)
|
||||||
expect(p.__scaleboxMetricBottomLeft.y).to.equal(212.5);
|
expect(round(p.__scaleboxMetricTopLeft.y)).to.equal(250)
|
||||||
expect(p.__scaleboxMetricBottomRight.x).to.equal(125);
|
expect(round(p.__scaleboxMetricTopRight.x)).to.equal(75)
|
||||||
expect(p.__scaleboxMetricBottomRight.y).to.equal(212.5);
|
expect(round(p.__scaleboxMetricTopRight.y)).to.equal(150)
|
||||||
expect(p.__scaleboxImperialTopLeft.x).to.equal(74.6);
|
expect(round(p.__scaleboxMetricBottomLeft.x)).to.equal(125)
|
||||||
expect(p.__scaleboxImperialTopLeft.y).to.equal(187.3);
|
expect(round(p.__scaleboxMetricBottomLeft.y)).to.equal(250)
|
||||||
expect(p.__scaleboxImperialTopRight.x).to.equal(125.4);
|
expect(round(p.__scaleboxMetricBottomRight.x)).to.equal(125)
|
||||||
expect(p.__scaleboxImperialTopRight.y).to.equal(187.3);
|
expect(round(p.__scaleboxMetricBottomRight.y)).to.equal(150)
|
||||||
expect(p.__scaleboxImperialBottomLeft.x).to.equal(74.6);
|
expect(round(p.__scaleboxImperialTopLeft.x)).to.equal(74.6)
|
||||||
expect(p.__scaleboxImperialBottomLeft.y).to.equal(212.7);
|
expect(round(p.__scaleboxImperialTopLeft.y)).to.equal(250.8)
|
||||||
expect(p.__scaleboxImperialBottomRight.x).to.equal(125.4);
|
expect(round(p.__scaleboxImperialTopRight.x)).to.equal(74.6)
|
||||||
expect(p.__scaleboxImperialBottomRight.y).to.equal(212.7);
|
expect(round(p.__scaleboxImperialTopRight.y)).to.equal(149.2)
|
||||||
expect(p.__scaleboxMetric.attributes.get('data-text'))
|
expect(round(p.__scaleboxImperialBottomLeft.x)).to.equal(125.4)
|
||||||
.to.equal("theWhiteInsideOfThisBoxShouldMeasure 5cm x 2.5cm")
|
expect(round(p.__scaleboxImperialBottomLeft.y)).to.equal(250.8)
|
||||||
expect(p.__scaleboxImperial.attributes.get('data-text'))
|
expect(round(p.__scaleboxImperialBottomRight.x)).to.equal(125.4)
|
||||||
.to.equal("theBlackOutsideOfThisBoxShouldMeasure 2″ x 1″")
|
expect(round(p.__scaleboxImperialBottomRight.y)).to.equal(149.2)
|
||||||
});
|
expect(round(p.__scaleboxLead.x)).to.equal(85)
|
||||||
|
expect(round(p.__scaleboxLead.y)).to.equal(245)
|
||||||
it("Should apply scale to the miniscale macro", () => {
|
expect(round(p.__scaleboxTitle.x)).to.equal(95)
|
||||||
const Pattern = new Design()
|
expect(round(p.__scaleboxTitle.y)).to.equal(245)
|
||||||
const pattern = new Pattern().use(plugin)
|
expect(round(p.__scaleboxText.x)).to.equal(107)
|
||||||
pattern.settings.scale = 0.5
|
expect(round(p.__scaleboxText.y)).to.equal(245)
|
||||||
pattern.parts.test = new pattern.Part();
|
expect(round(p.__scaleboxLink.x)).to.equal(112)
|
||||||
pattern.parts.test.points.anchor = new pattern.Point(100, 200);
|
expect(round(p.__scaleboxLink.y)).to.equal(245)
|
||||||
const { macro } = pattern.parts.test.shorthand()
|
expect(round(p.__scaleboxMetric.x)).to.equal(120)
|
||||||
macro("miniscale", {
|
expect(round(p.__scaleboxMetric.y)).to.equal(200)
|
||||||
at: pattern.parts.test.points.anchor
|
expect(round(p.__scaleboxImperial.x)).to.equal(124)
|
||||||
});
|
expect(round(p.__scaleboxImperial.y)).to.equal(200)
|
||||||
let p = pattern.parts.test.points;
|
})
|
||||||
expect(p.__miniscaleMetricTopLeft.x).to.equal(92);
|
|
||||||
expect(p.__miniscaleMetricTopLeft.y).to.equal(192);
|
it('Should run the scalebox macro with default text', () => {
|
||||||
expect(p.__miniscaleMetricTopRight.x).to.equal(108);
|
const part = {
|
||||||
expect(p.__miniscaleMetricTopRight.y).to.equal(192);
|
name: 'test',
|
||||||
expect(p.__miniscaleMetricBottomLeft.x).to.equal(92);
|
draft: ({ points, Point, macro }) => {
|
||||||
expect(p.__miniscaleMetricBottomLeft.y).to.equal(208);
|
points.anchor = new Point(100, 200)
|
||||||
expect(p.__miniscaleMetricBottomRight.x).to.equal(108);
|
macro('scalebox', {
|
||||||
expect(p.__miniscaleMetricBottomRight.y).to.equal(208);
|
at: points.anchor,
|
||||||
expect(p.__miniscaleImperialTopLeft.x).to.equal(92.0625);
|
})
|
||||||
expect(p.__miniscaleImperialTopLeft.y).to.equal(192.0625);
|
},
|
||||||
expect(p.__miniscaleImperialTopRight.x).to.equal(107.9375);
|
}
|
||||||
expect(p.__miniscaleImperialTopRight.y).to.equal(192.0625);
|
const Pattern = new Design({
|
||||||
expect(p.__miniscaleImperialBottomLeft.x).to.equal(92.0625);
|
parts: [part],
|
||||||
expect(p.__miniscaleImperialBottomLeft.y).to.equal(207.9375);
|
plugins: [plugin],
|
||||||
expect(p.__miniscaleImperialBottomRight.x).to.equal(107.9375);
|
data: { name: 'test', version: '1.2.3' },
|
||||||
expect(p.__miniscaleImperialBottomRight.y).to.equal(207.9375);
|
})
|
||||||
expect(p.__miniscaleMetric.attributes.get('data-text')).to.equal("1.6cm x 1.6cm")
|
const pattern = new Pattern()
|
||||||
expect(p.__miniscaleImperial.attributes.get('data-text')).to.equal("⅝″ x ⅝″")
|
pattern.draft()
|
||||||
});
|
let p = pattern.parts.test.points.__scaleboxLead.attributes
|
||||||
|
expect(p.get('data-text')).to.equal('FreeSewing')
|
||||||
|
expect(p.get('data-text-class')).to.equal('text-sm')
|
||||||
|
p = pattern.parts.test.points.__scaleboxTitle.attributes
|
||||||
|
expect(p.get('data-text')).to.equal('test v1.2.3')
|
||||||
|
expect(p.get('data-text-class')).to.equal('text-lg')
|
||||||
|
p = pattern.parts.test.points.__scaleboxText.attributes
|
||||||
|
expect(p.get('data-text-class')).to.equal('text-xs')
|
||||||
|
expect(p.get('data-text-lineheight')).to.equal('4')
|
||||||
|
expect(p.list['data-text'][0]).to.equal('supportFreesewingBecomeAPatron')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('Should run the scalebox macro with custom text', () => {
|
||||||
|
const part = {
|
||||||
|
name: 'test',
|
||||||
|
draft: ({ points, Point, macro }) => {
|
||||||
|
points.anchor = new Point(100, 200)
|
||||||
|
macro('scalebox', {
|
||||||
|
at: points.anchor,
|
||||||
|
lead: 'theLead',
|
||||||
|
title: 'theTitle',
|
||||||
|
text: 'theText',
|
||||||
|
})
|
||||||
|
},
|
||||||
|
}
|
||||||
|
const Pattern = new Design({
|
||||||
|
parts: [part],
|
||||||
|
plugins: [plugin],
|
||||||
|
data: { name: 'test', version: '1.2.3' },
|
||||||
|
})
|
||||||
|
const pattern = new Pattern()
|
||||||
|
pattern.draft()
|
||||||
|
let p = pattern.parts.test.points.__scaleboxLead.attributes
|
||||||
|
expect(p.get('data-text')).to.equal('theLead')
|
||||||
|
expect(p.get('data-text-class')).to.equal('text-sm')
|
||||||
|
p = pattern.parts.test.points.__scaleboxTitle.attributes
|
||||||
|
expect(p.get('data-text')).to.equal('theTitle')
|
||||||
|
expect(p.get('data-text-class')).to.equal('text-lg')
|
||||||
|
p = pattern.parts.test.points.__scaleboxText.attributes
|
||||||
|
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')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('Should apply scale to the scalebox macro', () => {
|
||||||
|
const part = {
|
||||||
|
name: 'test',
|
||||||
|
draft: ({ points, Point, macro }) => {
|
||||||
|
points.anchor = new Point(100, 200)
|
||||||
|
macro('scalebox', {
|
||||||
|
at: points.anchor,
|
||||||
|
lead: 'theLead',
|
||||||
|
title: 'theTitle',
|
||||||
|
text: 'theText',
|
||||||
|
})
|
||||||
|
},
|
||||||
|
}
|
||||||
|
const Pattern = new Design({
|
||||||
|
parts: [part],
|
||||||
|
plugins: [plugin],
|
||||||
|
data: { name: 'test', version: '1.2.3' },
|
||||||
|
})
|
||||||
|
const pattern = new Pattern({ scale: 0.5 })
|
||||||
|
pattern.draft()
|
||||||
|
let p = pattern.parts.test.points
|
||||||
|
expect(p.__scaleboxMetricTopLeft.x).to.equal(75)
|
||||||
|
expect(p.__scaleboxMetricTopLeft.y).to.equal(187.5)
|
||||||
|
expect(p.__scaleboxMetricTopRight.x).to.equal(125)
|
||||||
|
expect(p.__scaleboxMetricTopRight.y).to.equal(187.5)
|
||||||
|
expect(p.__scaleboxMetricBottomLeft.x).to.equal(75)
|
||||||
|
expect(p.__scaleboxMetricBottomLeft.y).to.equal(212.5)
|
||||||
|
expect(p.__scaleboxMetricBottomRight.x).to.equal(125)
|
||||||
|
expect(p.__scaleboxMetricBottomRight.y).to.equal(212.5)
|
||||||
|
expect(p.__scaleboxImperialTopLeft.x).to.equal(74.6)
|
||||||
|
expect(p.__scaleboxImperialTopLeft.y).to.equal(187.3)
|
||||||
|
expect(p.__scaleboxImperialTopRight.x).to.equal(125.4)
|
||||||
|
expect(p.__scaleboxImperialTopRight.y).to.equal(187.3)
|
||||||
|
expect(p.__scaleboxImperialBottomLeft.x).to.equal(74.6)
|
||||||
|
expect(p.__scaleboxImperialBottomLeft.y).to.equal(212.7)
|
||||||
|
expect(p.__scaleboxImperialBottomRight.x).to.equal(125.4)
|
||||||
|
expect(p.__scaleboxImperialBottomRight.y).to.equal(212.7)
|
||||||
|
expect(p.__scaleboxMetric.attributes.get('data-text')).to.equal(
|
||||||
|
'theWhiteInsideOfThisBoxShouldMeasure 5cm x 2.5cm'
|
||||||
|
)
|
||||||
|
expect(p.__scaleboxImperial.attributes.get('data-text')).to.equal(
|
||||||
|
'theBlackOutsideOfThisBoxShouldMeasure 2″ x 1″'
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('Should apply scale to the miniscale macro', () => {
|
||||||
|
const part = {
|
||||||
|
name: 'test',
|
||||||
|
draft: ({ points, Point, macro }) => {
|
||||||
|
points.anchor = new Point(100, 200)
|
||||||
|
macro('miniscale', {
|
||||||
|
at: points.anchor,
|
||||||
|
})
|
||||||
|
},
|
||||||
|
}
|
||||||
|
const Pattern = new Design({
|
||||||
|
parts: [part],
|
||||||
|
plugins: [plugin],
|
||||||
|
data: { name: 'test', version: '1.2.3' },
|
||||||
|
})
|
||||||
|
const pattern = new Pattern({ scale: 0.5 })
|
||||||
|
pattern.draft()
|
||||||
|
let p = pattern.parts.test.points
|
||||||
|
expect(p.__miniscaleMetricTopLeft.x).to.equal(92)
|
||||||
|
expect(p.__miniscaleMetricTopLeft.y).to.equal(192)
|
||||||
|
expect(p.__miniscaleMetricTopRight.x).to.equal(108)
|
||||||
|
expect(p.__miniscaleMetricTopRight.y).to.equal(192)
|
||||||
|
expect(p.__miniscaleMetricBottomLeft.x).to.equal(92)
|
||||||
|
expect(p.__miniscaleMetricBottomLeft.y).to.equal(208)
|
||||||
|
expect(p.__miniscaleMetricBottomRight.x).to.equal(108)
|
||||||
|
expect(p.__miniscaleMetricBottomRight.y).to.equal(208)
|
||||||
|
expect(p.__miniscaleImperialTopLeft.x).to.equal(92.0625)
|
||||||
|
expect(p.__miniscaleImperialTopLeft.y).to.equal(192.0625)
|
||||||
|
expect(p.__miniscaleImperialTopRight.x).to.equal(107.9375)
|
||||||
|
expect(p.__miniscaleImperialTopRight.y).to.equal(192.0625)
|
||||||
|
expect(p.__miniscaleImperialBottomLeft.x).to.equal(92.0625)
|
||||||
|
expect(p.__miniscaleImperialBottomLeft.y).to.equal(207.9375)
|
||||||
|
expect(p.__miniscaleImperialBottomRight.x).to.equal(107.9375)
|
||||||
|
expect(p.__miniscaleImperialBottomRight.y).to.equal(207.9375)
|
||||||
|
expect(p.__miniscaleMetric.attributes.get('data-text')).to.equal('1.6cm x 1.6cm')
|
||||||
|
expect(p.__miniscaleImperial.attributes.get('data-text')).to.equal('⅝″ x ⅝″')
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
|
@ -4,4 +4,3 @@ import { sharedPluginTests } from '../../../tests/plugins/shared.mjs'
|
||||||
|
|
||||||
// Run shared tests
|
// Run shared tests
|
||||||
sharedPluginTests(plugin)
|
sharedPluginTests(plugin)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue