1
0
Fork 0

chore(plugin-annotations): Fix banner tests after changes

This commit is contained in:
joostdecock 2023-09-08 09:05:44 +02:00
parent 5a99c1b5ef
commit 6a08a4f642
2 changed files with 43 additions and 30 deletions

View file

@ -22,12 +22,15 @@ describe('Banner Plugin Tests', () => {
}, },
plugins: [annotationsPlugin], 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() const pattern = new design()
pattern.draft() 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( 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-class').trim()).to.equal('center')
expect(c.attributes.get('data-text-dy')).to.equal('-1') expect(c.attributes.get('data-text-dy')).to.equal('-1')
@ -52,11 +55,12 @@ describe('Banner Plugin Tests', () => {
}, },
plugins: [annotationsPlugin], 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() const pattern = new design()
pattern.draft() pattern.draft()
const c = pattern.parts[0].test.paths.example2 const c = pattern.parts[0].test.paths.__macro_banner_banner_banner
expect(c.attributes.get('data-text')).to.equal('   foo    foo   ') expect(c.attributes.get('data-text')).to.equal('foo    foo    foo')
}) })
it('Number of repetitions should be configurable', () => { it('Number of repetitions should be configurable', () => {
@ -78,12 +82,13 @@ describe('Banner Plugin Tests', () => {
}, },
plugins: [annotationsPlugin], 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() const pattern = new design()
pattern.draft() 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( expect(c.attributes.get('data-text')).to.equal(
'  foo   foo   foo   foo  ' 'foo   foo   foo   foo   foo'
) )
}) })
}) })

View file

@ -18,11 +18,11 @@ describe('Bartack plugin Tests', () => {
}, },
plugins: [annotationsPlugin], 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() const pattern = new design()
pattern.draft() pattern.draft()
const c = pattern.parts[0].test.paths.__macro_bartack_bartack_stitches
const c = pattern.parts[0].test.paths.bartack
expect(c.attributes.get('class')).to.equal('stroke-sm stroke-mark') expect(c.attributes.get('class')).to.equal('stroke-sm stroke-mark')
expect(c.ops[0].type).to.equal('move') expect(c.ops[0].type).to.equal('move')
expect(c.ops[0].to.x).to.equal(10) expect(c.ops[0].to.x).to.equal(10)
@ -53,10 +53,11 @@ describe('Bartack plugin Tests', () => {
}, },
plugins: [annotationsPlugin], 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() const pattern = new design()
pattern.draft() 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.attributes.get('class')).to.equal('stroke-sm stroke-mark')
expect(c.ops[0].type).to.equal('move') expect(c.ops[0].type).to.equal('move')
expect(c.ops[0].to.x).to.equal(8.5) expect(c.ops[0].to.x).to.equal(8.5)
@ -89,10 +90,11 @@ describe('Bartack plugin Tests', () => {
}, },
plugins: [annotationsPlugin], 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() const pattern = new design()
pattern.draft() 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.attributes.get('class')).to.equal('stroke-sm stroke-mark')
expect(c.ops[0].type).to.equal('move') expect(c.ops[0].type).to.equal('move')
expect(round(c.ops[0].to.x)).to.equal(8.5) expect(round(c.ops[0].to.x)).to.equal(8.5)
@ -125,10 +127,11 @@ describe('Bartack plugin Tests', () => {
}, },
plugins: [annotationsPlugin], 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() const pattern = new design()
pattern.draft() 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.attributes.get('class')).to.equal('stroke-sm stroke-mark')
expect(c.ops[0].type).to.equal('move') expect(c.ops[0].type).to.equal('move')
expect(round(c.ops[0].to.x)).to.equal(8.5) expect(round(c.ops[0].to.x)).to.equal(8.5)
@ -159,10 +162,11 @@ describe('Bartack plugin Tests', () => {
}, },
plugins: [annotationsPlugin], 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() const pattern = new design()
pattern.draft() 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.attributes.get('class')).to.equal('stroke-sm stroke-mark')
expect(c.ops[0].type).to.equal('move') expect(c.ops[0].type).to.equal('move')
expect(c.ops[0].to.x).to.equal(10) expect(c.ops[0].to.x).to.equal(10)
@ -193,10 +197,11 @@ describe('Bartack plugin Tests', () => {
}, },
plugins: [annotationsPlugin], 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() const pattern = new design()
pattern.draft() 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.attributes.get('class')).to.equal('stroke-sm stroke-mark')
expect(c.ops[0].type).to.equal('move') expect(c.ops[0].type).to.equal('move')
expect(c.ops[0].to.x).to.equal(10) expect(c.ops[0].to.x).to.equal(10)
@ -227,10 +232,11 @@ describe('Bartack plugin Tests', () => {
}, },
plugins: [annotationsPlugin], 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() const pattern = new design()
pattern.draft() 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.attributes.get('class')).to.equal('stroke-sm stroke-mark')
expect(c.ops[0].type).to.equal('move') expect(c.ops[0].type).to.equal('move')
expect(round(c.ops[0].to.x)).to.equal(11.06) 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) points.from = new Point(10, 20)
macro('bartack', { macro('bartack', {
anchor: points.from, anchor: points.from,
suffix: 'foo', id: 'foo',
}) })
part part
}, },
plugins: [annotationsPlugin], 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() const pattern = new design()
pattern.draft() 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') 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) points.from = new Point(10, 20)
macro('bartack', { macro('bartack', {
anchor: points.from, anchor: points.from,
prefix: 'foo', id: 'foo',
}) })
return part return part
}, },
plugins: [annotationsPlugin], 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() const pattern = new design()
pattern.draft() 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') expect(c.attributes.get('class')).to.equal('stroke-sm stroke-mark')
}) })
}) })