chore(plugin-title): Changes for v3. See #2856
This commit is contained in:
parent
3e445a8401
commit
f56e67d007
2 changed files with 32 additions and 26 deletions
|
@ -8,35 +8,37 @@ describe('Title Plugin Tests', () => {
|
|||
it('Should run the title macro', () => {
|
||||
const part = {
|
||||
name: 'test',
|
||||
draft: ({ points, Point, macro }) => {
|
||||
draft: ({ points, Point, macro, part }) => {
|
||||
points.anchor = new Point(-12, -34)
|
||||
macro('title', {
|
||||
at: points.anchor,
|
||||
nr: 3,
|
||||
title: 'unitTest',
|
||||
})
|
||||
|
||||
return part
|
||||
},
|
||||
plugins: [plugin],
|
||||
}
|
||||
const Pattern = new Design({
|
||||
data: { name: 'testPattern', version: 99 },
|
||||
parts: [part],
|
||||
plugins: [plugin],
|
||||
})
|
||||
const pattern = new Pattern()
|
||||
pattern.draft().render()
|
||||
let p = pattern.parts.test.points.__titleNr
|
||||
let p = pattern.parts[0].test.points.__titleNr
|
||||
expect(p.x).to.equal(-12)
|
||||
expect(p.y).to.equal(-34)
|
||||
expect(p.attributes.get('data-text')).to.equal('3')
|
||||
expect(p.attributes.get('data-text-class')).to.equal('text-4xl fill-note font-bold')
|
||||
expect(p.attributes.get('data-text-x')).to.equal('-12')
|
||||
expect(p.attributes.get('data-text-y')).to.equal('-34')
|
||||
p = pattern.parts.test.points.__titleName
|
||||
p = pattern.parts[0].test.points.__titleName
|
||||
expect(p.attributes.get('data-text')).to.equal('unitTest')
|
||||
expect(p.attributes.get('data-text-class')).to.equal('text-lg fill-current font-bold')
|
||||
expect(p.attributes.get('data-text-x')).to.equal('-12')
|
||||
expect(p.attributes.get('data-text-y')).to.equal('-26')
|
||||
p = pattern.parts.test.points.__titlePattern
|
||||
p = pattern.parts[0].test.points.__titlePattern
|
||||
expect(p.attributes.get('data-text')).to.equal('testPattern v99')
|
||||
expect(p.attributes.get('data-text-class')).to.equal('fill-note')
|
||||
expect(p.attributes.get('data-text-x')).to.equal('-12')
|
||||
|
@ -46,7 +48,7 @@ describe('Title Plugin Tests', () => {
|
|||
it('Should run the title macro with append flag', () => {
|
||||
const part = {
|
||||
name: 'test',
|
||||
draft: ({ points, Point, macro }) => {
|
||||
draft: ({ points, Point, macro, part }) => {
|
||||
points.anchor = new Point(-12, -34).attr('data-text', '#')
|
||||
macro('title', {
|
||||
at: points.anchor,
|
||||
|
@ -54,16 +56,18 @@ describe('Title Plugin Tests', () => {
|
|||
title: 'unitTest',
|
||||
append: true,
|
||||
})
|
||||
|
||||
return part
|
||||
},
|
||||
plugins: [plugin],
|
||||
}
|
||||
const Pattern = new Design({
|
||||
data: { name: 'testPattern', version: 99 },
|
||||
parts: [part],
|
||||
plugins: [plugin],
|
||||
})
|
||||
const pattern = new Pattern()
|
||||
pattern.draft().render()
|
||||
let p = pattern.parts.test.points.__titleNr
|
||||
let p = pattern.parts[0].test.points.__titleNr
|
||||
expect(p.x).to.equal(-12)
|
||||
expect(p.y).to.equal(-34)
|
||||
expect(p.attributes.get('data-text')).to.equal('# 3')
|
||||
|
@ -75,7 +79,7 @@ describe('Title Plugin Tests', () => {
|
|||
it('Should run the title macro with point prefix', () => {
|
||||
const part = {
|
||||
name: 'test',
|
||||
draft: ({ points, Point, macro }) => {
|
||||
draft: ({ points, Point, macro, part }) => {
|
||||
points.anchor = new Point(-12, -34).attr('data-text', '#')
|
||||
macro('title', {
|
||||
at: points.anchor,
|
||||
|
@ -83,28 +87,30 @@ describe('Title Plugin Tests', () => {
|
|||
title: 'unitTest',
|
||||
prefix: 'foo',
|
||||
})
|
||||
|
||||
return part
|
||||
},
|
||||
plugins: [plugin],
|
||||
}
|
||||
const Pattern = new Design({
|
||||
data: { name: 'testPattern', version: 99 },
|
||||
parts: [part],
|
||||
plugins: [plugin],
|
||||
})
|
||||
const pattern = new Pattern()
|
||||
pattern.draft().render()
|
||||
let p = pattern.parts.test.points._foo_titleNr
|
||||
let p = pattern.parts[0].test.points._foo_titleNr
|
||||
expect(p.x).to.equal(-12)
|
||||
expect(p.y).to.equal(-34)
|
||||
expect(p.attributes.get('data-text')).to.equal('3')
|
||||
expect(p.attributes.get('data-text-class')).to.equal('text-4xl fill-note font-bold')
|
||||
expect(p.attributes.get('data-text-x')).to.equal('-12')
|
||||
expect(p.attributes.get('data-text-y')).to.equal('-34')
|
||||
p = pattern.parts.test.points._foo_titleName
|
||||
p = pattern.parts[0].test.points._foo_titleName
|
||||
expect(p.attributes.get('data-text')).to.equal('unitTest')
|
||||
expect(p.attributes.get('data-text-class')).to.equal('text-lg fill-current font-bold')
|
||||
expect(p.attributes.get('data-text-x')).to.equal('-12')
|
||||
expect(p.attributes.get('data-text-y')).to.equal('-26')
|
||||
p = pattern.parts.test.points._foo_titlePattern
|
||||
p = pattern.parts[0].test.points._foo_titlePattern
|
||||
expect(p.attributes.get('data-text')).to.equal('testPattern v99')
|
||||
expect(p.attributes.get('data-text-class')).to.equal('fill-note')
|
||||
expect(p.attributes.get('data-text-x')).to.equal('-12')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue