From 6a08a4f6427762b830dd2d697f814501a4321471 Mon Sep 17 00:00:00 2001 From: joostdecock Date: Fri, 8 Sep 2023 09:05:44 +0200 Subject: [PATCH] chore(plugin-annotations): Fix banner tests after changes --- .../plugin-annotations/tests/banner.test.mjs | 23 +++++---- .../plugin-annotations/tests/bartack.test.mjs | 50 +++++++++++-------- 2 files changed, 43 insertions(+), 30 deletions(-) diff --git a/plugins/plugin-annotations/tests/banner.test.mjs b/plugins/plugin-annotations/tests/banner.test.mjs index 3b9dddd8d60..d3c70533cea 100644 --- a/plugins/plugin-annotations/tests/banner.test.mjs +++ b/plugins/plugin-annotations/tests/banner.test.mjs @@ -22,12 +22,15 @@ describe('Banner Plugin Tests', () => { }, plugins: [annotationsPlugin], } - const design = new Design({ parts: [part] }) + // Note that we're not loading core plugins but the local plugin + const design = new Design({ parts: [part] }, true) const pattern = new design() pattern.draft() - const c = pattern.parts[0].test.paths.example + // Note that this macro does not add text to the path, but clones + // the path and adds text to the clone which is then hidden + const c = pattern.parts[0].test.paths.__macro_banner_banner_banner expect(c.attributes.get('data-text')).to.equal( - '             foo              foo              foo              foo              foo              foo              foo              foo              foo              foo             ' + 'foo              foo              foo              foo              foo              foo              foo              foo              foo              foo              foo' ) expect(c.attributes.get('data-text-class').trim()).to.equal('center') expect(c.attributes.get('data-text-dy')).to.equal('-1') @@ -52,11 +55,12 @@ describe('Banner Plugin Tests', () => { }, plugins: [annotationsPlugin], } - const design = new Design({ parts: [part] }) + // Note that we're not loading core plugins but the local plugin + const design = new Design({ parts: [part] }, true) const pattern = new design() pattern.draft() - const c = pattern.parts[0].test.paths.example2 - expect(c.attributes.get('data-text')).to.equal('   foo    foo   ') + const c = pattern.parts[0].test.paths.__macro_banner_banner_banner + expect(c.attributes.get('data-text')).to.equal('foo    foo    foo') }) it('Number of repetitions should be configurable', () => { @@ -78,12 +82,13 @@ describe('Banner Plugin Tests', () => { }, plugins: [annotationsPlugin], } - const design = new Design({ parts: [part] }) + // Note that we're not loading core plugins but the local plugin + const design = new Design({ parts: [part] }, true) const pattern = new design() pattern.draft() - const c = pattern.parts[0].test.paths.example3 + const c = pattern.parts[0].test.paths.__macro_banner_banner_banner expect(c.attributes.get('data-text')).to.equal( - '  foo   foo   foo   foo  ' + 'foo   foo   foo   foo   foo' ) }) }) diff --git a/plugins/plugin-annotations/tests/bartack.test.mjs b/plugins/plugin-annotations/tests/bartack.test.mjs index 9b7a5e78e7e..f1afccf06ca 100644 --- a/plugins/plugin-annotations/tests/bartack.test.mjs +++ b/plugins/plugin-annotations/tests/bartack.test.mjs @@ -18,11 +18,11 @@ describe('Bartack plugin Tests', () => { }, plugins: [annotationsPlugin], } - const design = new Design({ parts: [part] }) + // Note that we're not loading core plugins but the local plugin + const design = new Design({ parts: [part] }, true) const pattern = new design() pattern.draft() - - const c = pattern.parts[0].test.paths.bartack + const c = pattern.parts[0].test.paths.__macro_bartack_bartack_stitches expect(c.attributes.get('class')).to.equal('stroke-sm stroke-mark') expect(c.ops[0].type).to.equal('move') expect(c.ops[0].to.x).to.equal(10) @@ -53,10 +53,11 @@ describe('Bartack plugin Tests', () => { }, plugins: [annotationsPlugin], } - const design = new Design({ parts: [part] }) + // Note that we're not loading core plugins but the local plugin + const design = new Design({ parts: [part] }, true) const pattern = new design() pattern.draft() - const c = pattern.parts[0].test.paths.bartack + const c = pattern.parts[0].test.paths.__macro_bartackalong_bartack_stitches expect(c.attributes.get('class')).to.equal('stroke-sm stroke-mark') expect(c.ops[0].type).to.equal('move') expect(c.ops[0].to.x).to.equal(8.5) @@ -89,10 +90,11 @@ describe('Bartack plugin Tests', () => { }, plugins: [annotationsPlugin], } - const design = new Design({ parts: [part] }) + // Note that we're not loading core plugins but the local plugin + const design = new Design({ parts: [part] }, true) const pattern = new design() pattern.draft() - const c = pattern.parts[0].test.paths.bartack + const c = pattern.parts[0].test.paths.__macro_bartackalong_bartack_stitches expect(c.attributes.get('class')).to.equal('stroke-sm stroke-mark') expect(c.ops[0].type).to.equal('move') expect(round(c.ops[0].to.x)).to.equal(8.5) @@ -125,10 +127,11 @@ describe('Bartack plugin Tests', () => { }, plugins: [annotationsPlugin], } - const design = new Design({ parts: [part] }) + // Note that we're not loading core plugins but the local plugin + const design = new Design({ parts: [part] }, true) const pattern = new design() pattern.draft() - const c = pattern.parts[0].test.paths.bartack + const c = pattern.parts[0].test.paths.__macro_bartackfractionalong_bartack_stitches expect(c.attributes.get('class')).to.equal('stroke-sm stroke-mark') expect(c.ops[0].type).to.equal('move') expect(round(c.ops[0].to.x)).to.equal(8.5) @@ -159,10 +162,11 @@ describe('Bartack plugin Tests', () => { }, plugins: [annotationsPlugin], } - const design = new Design({ parts: [part] }) + // Note that we're not loading core plugins but the local plugin + const design = new Design({ parts: [part] }, true) const pattern = new design() pattern.draft() - const c = pattern.parts[0].test.paths.bartack + const c = pattern.parts[0].test.paths.__macro_bartack_bartack_stitches expect(c.attributes.get('class')).to.equal('stroke-sm stroke-mark') expect(c.ops[0].type).to.equal('move') expect(c.ops[0].to.x).to.equal(10) @@ -193,10 +197,11 @@ describe('Bartack plugin Tests', () => { }, plugins: [annotationsPlugin], } - const design = new Design({ parts: [part] }) + // Note that we're not loading core plugins but the local plugin + const design = new Design({ parts: [part] }, true) const pattern = new design() pattern.draft() - const c = pattern.parts[0].test.paths.bartack + const c = pattern.parts[0].test.paths.__macro_bartack_bartack_stitches expect(c.attributes.get('class')).to.equal('stroke-sm stroke-mark') expect(c.ops[0].type).to.equal('move') expect(c.ops[0].to.x).to.equal(10) @@ -227,10 +232,11 @@ describe('Bartack plugin Tests', () => { }, plugins: [annotationsPlugin], } - const design = new Design({ parts: [part] }) + // Note that we're not loading core plugins but the local plugin + const design = new Design({ parts: [part] }, true) const pattern = new design() pattern.draft() - const c = pattern.parts[0].test.paths.bartack + const c = pattern.parts[0].test.paths.__macro_bartack_bartack_stitches expect(c.attributes.get('class')).to.equal('stroke-sm stroke-mark') expect(c.ops[0].type).to.equal('move') expect(round(c.ops[0].to.x)).to.equal(11.06) @@ -254,17 +260,18 @@ describe('Bartack plugin Tests', () => { points.from = new Point(10, 20) macro('bartack', { anchor: points.from, - suffix: 'foo', + id: 'foo', }) part }, plugins: [annotationsPlugin], } - const design = new Design({ parts: [part] }) + // Note that we're not loading core plugins but the local plugin + const design = new Design({ parts: [part] }, true) const pattern = new design() pattern.draft() - const c = pattern.parts[0].test.paths.bartackfoo + const c = pattern.parts[0].test.paths.__macro_bartack_foo_stitches expect(c.attributes.get('class')).to.equal('stroke-sm stroke-mark') }) @@ -275,17 +282,18 @@ describe('Bartack plugin Tests', () => { points.from = new Point(10, 20) macro('bartack', { anchor: points.from, - prefix: 'foo', + id: 'foo', }) return part }, plugins: [annotationsPlugin], } - const design = new Design({ parts: [part] }) + // Note that we're not loading core plugins but the local plugin + const design = new Design({ parts: [part] }, true) const pattern = new design() pattern.draft() - const c = pattern.parts[0].test.paths.foobartack + const c = pattern.parts[0].test.paths.__macro_bartack_foo_stitches expect(c.attributes.get('class')).to.equal('stroke-sm stroke-mark') }) })