chore(plugin-annotations): Fix title tests after changes
This commit is contained in:
parent
b43145ac89
commit
6a7cc334ba
1 changed files with 73 additions and 59 deletions
|
@ -20,31 +20,35 @@ describe('Title Plugin Tests', () => {
|
||||||
},
|
},
|
||||||
plugins: [annotationsPlugin],
|
plugins: [annotationsPlugin],
|
||||||
}
|
}
|
||||||
const Pattern = new Design({
|
// Note that we're not loading core plugins but the local plugin
|
||||||
data: { name: 'testPattern', version: 99 },
|
const Pattern = new Design(
|
||||||
parts: [part],
|
{
|
||||||
})
|
data: { name: 'testPattern', version: 99 },
|
||||||
|
parts: [part],
|
||||||
|
},
|
||||||
|
true
|
||||||
|
)
|
||||||
const pattern = new Pattern()
|
const pattern = new Pattern()
|
||||||
pattern.draft().render()
|
pattern.draft().render()
|
||||||
let p = pattern.parts[0].test.points.__titleNr
|
let p = pattern.parts[0].test.points.__macro_title_title_nr
|
||||||
expect(p.x).to.equal(-12)
|
expect(p.x).to.equal(-12)
|
||||||
expect(p.y).to.equal(-34)
|
expect(p.y).to.equal(-34)
|
||||||
expect(p.attributes.get('data-text')).to.equal('3')
|
expect(p.attributes.get('data-text')).to.equal('3')
|
||||||
expect(p.attributes.get('data-text-class')).to.equal('text-4xl fill-note font-bold left')
|
expect(p.attributes.get('data-text-class')).to.equal('text-4xl fill-note font-bold left')
|
||||||
expect(p.attributes.get('data-text-x')).to.equal('-12')
|
expect(p.attributes.get('data-text-x')).to.equal('-12')
|
||||||
expect(p.attributes.get('data-text-y')).to.equal('-34')
|
expect(p.attributes.get('data-text-y')).to.equal('-34')
|
||||||
p = pattern.parts[0].test.points.__titleName
|
p = pattern.parts[0].test.points.__macro_title_title_title
|
||||||
expect(p.attributes.get('data-text')).to.equal('unitTest')
|
expect(p.attributes.get('data-text')).to.equal('unitTest')
|
||||||
expect(p.attributes.get('data-text-class')).to.equal('text-lg fill-current font-bold left')
|
expect(p.attributes.get('data-text-class')).to.equal('text-lg fill-current font-bold left')
|
||||||
expect(p.attributes.get('data-text-x')).to.equal('-12')
|
expect(p.attributes.get('data-text-x')).to.equal('-12')
|
||||||
expect(p.attributes.get('data-text-y')).to.equal('-26')
|
expect(p.attributes.get('data-text-y')).to.equal('-26')
|
||||||
p = pattern.parts[0].test.points.__titlePattern
|
p = pattern.parts[0].test.points.__macro_title_title_name
|
||||||
expect(p.attributes.get('data-text')).to.equal('testPattern v99')
|
expect(p.attributes.get('data-text')).to.equal('testPattern v99')
|
||||||
expect(p.attributes.get('data-text-class')).to.equal('fill-note left')
|
expect(p.attributes.get('data-text-class')).to.equal('fill-note left')
|
||||||
expect(p.attributes.get('data-text-x')).to.equal('-12')
|
expect(p.attributes.get('data-text-x')).to.equal('-12')
|
||||||
expect(p.attributes.get('data-text-y')).to.equal('-18')
|
expect(p.attributes.get('data-text-y')).to.equal('-18')
|
||||||
p = pattern.parts[0].test.points.__exportDate
|
p = pattern.parts[0].test.points.__macro_title_title_date
|
||||||
expect(p.attributes.get('data-text')).to.match(/^.+, .+ \d{1,2}, \d{4}@ \d\d:\d\d$/)
|
expect(p.attributes.get('data-text')).to.include(', 202')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should run the title macro with append flag', () => {
|
it('Should run the title macro with append flag', () => {
|
||||||
|
@ -63,13 +67,17 @@ describe('Title Plugin Tests', () => {
|
||||||
},
|
},
|
||||||
plugins: [annotationsPlugin],
|
plugins: [annotationsPlugin],
|
||||||
}
|
}
|
||||||
const Pattern = new Design({
|
// Note that we're not loading core plugins but the local plugin
|
||||||
data: { name: 'testPattern', version: 99 },
|
const Pattern = new Design(
|
||||||
parts: [part],
|
{
|
||||||
})
|
data: { name: 'testPattern', version: 99 },
|
||||||
|
parts: [part],
|
||||||
|
},
|
||||||
|
true
|
||||||
|
)
|
||||||
const pattern = new Pattern()
|
const pattern = new Pattern()
|
||||||
pattern.draft().render()
|
pattern.draft().render()
|
||||||
let p = pattern.parts[0].test.points.__titleNr
|
let p = pattern.parts[0].test.points.__macro_title_title_nr
|
||||||
expect(p.x).to.equal(-12)
|
expect(p.x).to.equal(-12)
|
||||||
expect(p.y).to.equal(-34)
|
expect(p.y).to.equal(-34)
|
||||||
expect(p.attributes.get('data-text')).to.equal('# 3')
|
expect(p.attributes.get('data-text')).to.equal('# 3')
|
||||||
|
@ -78,7 +86,7 @@ describe('Title Plugin Tests', () => {
|
||||||
expect(p.attributes.get('data-text-y')).to.equal('-34')
|
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 a custom ID', () => {
|
||||||
const part = {
|
const part = {
|
||||||
name: 'test',
|
name: 'test',
|
||||||
draft: ({ points, Point, macro, part }) => {
|
draft: ({ points, Point, macro, part }) => {
|
||||||
|
@ -87,39 +95,43 @@ describe('Title Plugin Tests', () => {
|
||||||
at: points.anchor,
|
at: points.anchor,
|
||||||
nr: 3,
|
nr: 3,
|
||||||
title: 'unitTest',
|
title: 'unitTest',
|
||||||
prefix: 'foo',
|
id: 'foo',
|
||||||
})
|
})
|
||||||
|
|
||||||
return part
|
return part
|
||||||
},
|
},
|
||||||
plugins: [annotationsPlugin],
|
plugins: [annotationsPlugin],
|
||||||
}
|
}
|
||||||
const Pattern = new Design({
|
// Note that we're not loading core plugins but the local plugin
|
||||||
data: { name: 'testPattern', version: 99 },
|
const Pattern = new Design(
|
||||||
parts: [part],
|
{
|
||||||
})
|
data: { name: 'testPattern', version: 99 },
|
||||||
|
parts: [part],
|
||||||
|
},
|
||||||
|
true
|
||||||
|
)
|
||||||
const pattern = new Pattern()
|
const pattern = new Pattern()
|
||||||
pattern.draft().render()
|
pattern.draft().render()
|
||||||
let p = pattern.parts[0].test.points._foo_titleNr
|
let p = pattern.parts[0].test.points.__macro_title_foo_nr
|
||||||
expect(p.x).to.equal(-12)
|
expect(p.x).to.equal(-12)
|
||||||
expect(p.y).to.equal(-34)
|
expect(p.y).to.equal(-34)
|
||||||
expect(p.attributes.get('data-text')).to.equal('3')
|
expect(p.attributes.get('data-text')).to.equal('3')
|
||||||
expect(p.attributes.get('data-text-class')).to.equal('text-4xl fill-note font-bold left')
|
expect(p.attributes.get('data-text-class')).to.equal('text-4xl fill-note font-bold left')
|
||||||
expect(p.attributes.get('data-text-x')).to.equal('-12')
|
expect(p.attributes.get('data-text-x')).to.equal('-12')
|
||||||
expect(p.attributes.get('data-text-y')).to.equal('-34')
|
expect(p.attributes.get('data-text-y')).to.equal('-34')
|
||||||
p = pattern.parts[0].test.points._foo_titleName
|
p = pattern.parts[0].test.points.__macro_title_foo_title
|
||||||
expect(p.attributes.get('data-text')).to.equal('unitTest')
|
expect(p.attributes.get('data-text')).to.equal('unitTest')
|
||||||
expect(p.attributes.get('data-text-class')).to.equal('text-lg fill-current font-bold left')
|
expect(p.attributes.get('data-text-class')).to.equal('text-lg fill-current font-bold left')
|
||||||
expect(p.attributes.get('data-text-x')).to.equal('-12')
|
expect(p.attributes.get('data-text-x')).to.equal('-12')
|
||||||
expect(p.attributes.get('data-text-y')).to.equal('-26')
|
expect(p.attributes.get('data-text-y')).to.equal('-26')
|
||||||
p = pattern.parts[0].test.points._foo_titlePattern
|
p = pattern.parts[0].test.points.__macro_title_foo_name
|
||||||
expect(p.attributes.get('data-text')).to.equal('testPattern v99')
|
expect(p.attributes.get('data-text')).to.equal('testPattern v99')
|
||||||
expect(p.attributes.get('data-text-class')).to.equal('fill-note left')
|
expect(p.attributes.get('data-text-class')).to.equal('fill-note left')
|
||||||
expect(p.attributes.get('data-text-x')).to.equal('-12')
|
expect(p.attributes.get('data-text-x')).to.equal('-12')
|
||||||
expect(p.attributes.get('data-text-y')).to.equal('-18')
|
expect(p.attributes.get('data-text-y')).to.equal('-18')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should run the title macro with valid align prefixes', () => {
|
it('Should run the title macro with custom alignment', () => {
|
||||||
const part = {
|
const part = {
|
||||||
name: 'test',
|
name: 'test',
|
||||||
draft: ({ points, Point, macro, part }) => {
|
draft: ({ points, Point, macro, part }) => {
|
||||||
|
@ -129,51 +141,47 @@ describe('Title Plugin Tests', () => {
|
||||||
nr: 3,
|
nr: 3,
|
||||||
title: 'unitTest',
|
title: 'unitTest',
|
||||||
align: 'left',
|
align: 'left',
|
||||||
prefix: 'left',
|
id: 'left',
|
||||||
})
|
})
|
||||||
macro('title', {
|
macro('title', {
|
||||||
at: points.anchor,
|
at: points.anchor,
|
||||||
nr: 3,
|
nr: 3,
|
||||||
title: 'unitTest',
|
title: 'unitTest',
|
||||||
align: 'right',
|
align: 'right',
|
||||||
prefix: 'right',
|
id: 'right',
|
||||||
})
|
})
|
||||||
macro('title', {
|
macro('title', {
|
||||||
at: points.anchor,
|
at: points.anchor,
|
||||||
nr: 3,
|
nr: 3,
|
||||||
title: 'unitTest',
|
title: 'unitTest',
|
||||||
align: 'center',
|
align: 'center',
|
||||||
prefix: 'center',
|
id: 'center',
|
||||||
})
|
})
|
||||||
|
|
||||||
return part
|
return part
|
||||||
},
|
},
|
||||||
plugins: [annotationsPlugin],
|
plugins: [annotationsPlugin],
|
||||||
}
|
}
|
||||||
const Pattern = new Design({
|
// Note that we're not loading core plugins but the local plugin
|
||||||
data: { name: 'testPattern', version: 99 },
|
const Pattern = new Design(
|
||||||
parts: [part],
|
{
|
||||||
})
|
data: { name: 'testPattern', version: 99 },
|
||||||
|
parts: [part],
|
||||||
|
},
|
||||||
|
true
|
||||||
|
)
|
||||||
const pattern = new Pattern()
|
const pattern = new Pattern()
|
||||||
pattern.draft().render()
|
pattern.draft().render()
|
||||||
let p = pattern.parts[0].test.points._left_titleNr
|
for (const align of ['left', 'center', 'right']) {
|
||||||
expect(p.attributes.get('data-text-class')).to.equal('text-4xl fill-note font-bold left')
|
let p = pattern.parts[0].test.points[`__macro_title_${align}_nr`]
|
||||||
p = pattern.parts[0].test.points._left_titleName
|
expect(p.attributes.get('data-text-class')).to.equal(`text-4xl fill-note font-bold ${align}`)
|
||||||
expect(p.attributes.get('data-text-class')).to.equal('text-lg fill-current font-bold left')
|
p = pattern.parts[0].test.points[`__macro_title_${align}_name`]
|
||||||
p = pattern.parts[0].test.points._left_titlePattern
|
expect(p.attributes.get('data-text-class')).to.equal(`fill-note ${align}`)
|
||||||
expect(p.attributes.get('data-text-class')).to.equal('fill-note left')
|
p = pattern.parts[0].test.points[`__macro_title_${align}_title`]
|
||||||
p = pattern.parts[0].test.points._center_titleNr
|
expect(p.attributes.get('data-text-class')).to.equal(
|
||||||
expect(p.attributes.get('data-text-class')).to.equal('text-4xl fill-note font-bold center')
|
`text-lg fill-current font-bold ${align}`
|
||||||
p = pattern.parts[0].test.points._center_titleName
|
)
|
||||||
expect(p.attributes.get('data-text-class')).to.equal('text-lg fill-current font-bold center')
|
}
|
||||||
p = pattern.parts[0].test.points._center_titlePattern
|
|
||||||
expect(p.attributes.get('data-text-class')).to.equal('fill-note center')
|
|
||||||
p = pattern.parts[0].test.points._right_titleNr
|
|
||||||
expect(p.attributes.get('data-text-class')).to.equal('text-4xl fill-note font-bold right')
|
|
||||||
p = pattern.parts[0].test.points._right_titleName
|
|
||||||
expect(p.attributes.get('data-text-class')).to.equal('text-lg fill-current font-bold right')
|
|
||||||
p = pattern.parts[0].test.points._right_titlePattern
|
|
||||||
expect(p.attributes.get('data-text-class')).to.equal('fill-note right')
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should run the title macro with an invalid align prefix', () => {
|
it('Should run the title macro with an invalid align prefix', () => {
|
||||||
|
@ -192,17 +200,23 @@ describe('Title Plugin Tests', () => {
|
||||||
},
|
},
|
||||||
plugins: [annotationsPlugin],
|
plugins: [annotationsPlugin],
|
||||||
}
|
}
|
||||||
const Pattern = new Design({
|
// Note that we're not loading core plugins but the local plugin
|
||||||
data: { name: 'testPattern', version: 99 },
|
const Pattern = new Design(
|
||||||
parts: [part],
|
{
|
||||||
})
|
data: { name: 'testPattern', version: 99 },
|
||||||
|
parts: [part],
|
||||||
|
},
|
||||||
|
true
|
||||||
|
)
|
||||||
const pattern = new Pattern()
|
const pattern = new Pattern()
|
||||||
pattern.draft().render()
|
pattern.draft().render()
|
||||||
let p = pattern.parts[0].test.points.__titleNr
|
let p = pattern.parts[0].test.points
|
||||||
expect(p.attributes.get('data-text-class')).to.equal('text-4xl fill-note font-bold left')
|
expect(p.__macro_title_title_nr.attributes.get('data-text-class')).to.equal(
|
||||||
p = pattern.parts[0].test.points.__titleName
|
'text-4xl fill-note font-bold left'
|
||||||
expect(p.attributes.get('data-text-class')).to.equal('text-lg fill-current font-bold left')
|
)
|
||||||
p = pattern.parts[0].test.points.__titlePattern
|
expect(p.__macro_title_title_title.attributes.get('data-text-class')).to.equal(
|
||||||
expect(p.attributes.get('data-text-class')).to.equal('fill-note left')
|
'text-lg fill-current font-bold left'
|
||||||
|
)
|
||||||
|
expect(p.__macro_title_title_name.attributes.get('data-text-class')).to.equal('fill-note left')
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue