1
0
Fork 0

chore(plugin-buttons): Changes for v3. See #2856

This commit is contained in:
joostdecock 2022-09-25 15:22:27 +02:00
parent 34cd9ae1aa
commit 70b04cc98f

View file

@ -18,12 +18,15 @@ describe('Buttons Plugin Test', () => {
it('Draws a button on an anchor point', () => { it('Draws a button on an anchor point', () => {
const part = { const part = {
name: 'test', name: 'test',
draft: ({ points, Point, snippets, Snippet }) => { draft: ({ points, Point, snippets, Snippet, part }) => {
points.anchor = new Point(10, 20) points.anchor = new Point(10, 20)
snippets.button = new Snippet('button', points.anchor) snippets.button = new Snippet('button', points.anchor)
return part
}, },
plugins: [plugin],
} }
const Pattern = new Design({ parts: [part], plugins: [plugin] }) const Pattern = new Design({ parts: [part] })
const svg = new Pattern().draft().render() const svg = new Pattern().draft().render()
expect(svg).to.contain('<use x="10" y="20" xlink:href="#button"') expect(svg).to.contain('<use x="10" y="20" xlink:href="#button"')
}) })
@ -31,12 +34,15 @@ describe('Buttons Plugin Test', () => {
it('Draws a buttonhole centred on an anchor point', () => { it('Draws a buttonhole centred on an anchor point', () => {
const part = { const part = {
name: 'test', name: 'test',
draft: ({ points, Point, snippets, Snippet }) => { draft: ({ points, Point, snippets, Snippet, part }) => {
points.anchor = new Point(10, 20) points.anchor = new Point(10, 20)
snippets.button = new Snippet('buttonhole', points.anchor) snippets.button = new Snippet('buttonhole', points.anchor)
return part
}, },
plugins: [plugin],
} }
const Pattern = new Design({ parts: [part], plugins: [plugin] }) const Pattern = new Design({ parts: [part] })
const svg = new Pattern().draft().render() const svg = new Pattern().draft().render()
expect(svg).to.contain('<use x="10" y="20" xlink:href="#buttonhole"') expect(svg).to.contain('<use x="10" y="20" xlink:href="#buttonhole"')
}) })
@ -44,12 +50,15 @@ describe('Buttons Plugin Test', () => {
it('Draws a buttonhole starting on an anchor point', () => { it('Draws a buttonhole starting on an anchor point', () => {
const part = { const part = {
name: 'test', name: 'test',
draft: ({ points, Point, snippets, Snippet }) => { draft: ({ points, Point, snippets, Snippet, part }) => {
points.anchor = new Point(10, 20) points.anchor = new Point(10, 20)
snippets.button = new Snippet('buttonhole-start', points.anchor) snippets.button = new Snippet('buttonhole-start', points.anchor)
return part
}, },
plugins: [plugin],
} }
const Pattern = new Design({ parts: [part], plugins: [plugin] }) const Pattern = new Design({ parts: [part] })
const svg = new Pattern().draft().render() const svg = new Pattern().draft().render()
expect(svg).to.contain('<use x="10" y="20" xlink:href="#buttonhole-start"') expect(svg).to.contain('<use x="10" y="20" xlink:href="#buttonhole-start"')
}) })
@ -57,12 +66,15 @@ describe('Buttons Plugin Test', () => {
it('Draws a buttonhole ending on an anchor point', () => { it('Draws a buttonhole ending on an anchor point', () => {
const part = { const part = {
name: 'test', name: 'test',
draft: ({ points, Point, snippets, Snippet }) => { draft: ({ points, Point, snippets, Snippet, part }) => {
points.anchor = new Point(10, 20) points.anchor = new Point(10, 20)
snippets.button = new Snippet('buttonhole-end', points.anchor) snippets.button = new Snippet('buttonhole-end', points.anchor)
return part
}, },
plugins: [plugin],
} }
const Pattern = new Design({ parts: [part], plugins: [plugin] }) const Pattern = new Design({ parts: [part] })
const svg = new Pattern().draft().render() const svg = new Pattern().draft().render()
expect(svg).to.contain('<use x="10" y="20" xlink:href="#buttonhole-end"') expect(svg).to.contain('<use x="10" y="20" xlink:href="#buttonhole-end"')
}) })
@ -70,12 +82,15 @@ describe('Buttons Plugin Test', () => {
it('Draws a snap-stud on an anchor point', () => { it('Draws a snap-stud on an anchor point', () => {
const part = { const part = {
name: 'test', name: 'test',
draft: ({ points, Point, snippets, Snippet }) => { draft: ({ points, Point, snippets, Snippet, part }) => {
points.anchor = new Point(10, 20) points.anchor = new Point(10, 20)
snippets.button = new Snippet('snap-stud', points.anchor) snippets.button = new Snippet('snap-stud', points.anchor)
return part
}, },
plugins: [plugin],
} }
const Pattern = new Design({ parts: [part], plugins: [plugin] }) const Pattern = new Design({ parts: [part] })
const svg = new Pattern().draft().render() const svg = new Pattern().draft().render()
expect(svg).to.contain('<use x="10" y="20" xlink:href="#snap-stud"') expect(svg).to.contain('<use x="10" y="20" xlink:href="#snap-stud"')
}) })
@ -83,12 +98,15 @@ describe('Buttons Plugin Test', () => {
it('Draws a snap-socket on an anchor point', () => { it('Draws a snap-socket on an anchor point', () => {
const part = { const part = {
name: 'test', name: 'test',
draft: ({ points, Point, snippets, Snippet }) => { draft: ({ points, Point, snippets, Snippet, part }) => {
points.anchor = new Point(10, 20) points.anchor = new Point(10, 20)
snippets.button = new Snippet('snap-socket', points.anchor) snippets.button = new Snippet('snap-socket', points.anchor)
return part
}, },
plugins: [plugin],
} }
const Pattern = new Design({ parts: [part], plugins: [plugin] }) const Pattern = new Design({ parts: [part] })
const svg = new Pattern().draft().render() const svg = new Pattern().draft().render()
expect(svg).to.contain('<use x="10" y="20" xlink:href="#snap-socket"') expect(svg).to.contain('<use x="10" y="20" xlink:href="#snap-socket"')
}) })