import { expect } from 'chai' import { Design } from '@freesewing/core' import { annotationsPlugin } from '../src/index.mjs' const Pattern = new Design() const pattern = new Pattern().use(annotationsPlugin) pattern.draft().render() describe('Buttons Plugin Test', () => { for (const snippet of ['button', 'buttonhole', 'snap-stud', 'snap-socket']) { it(`Should add the ${snippet} snippet to defs`, () => { expect(pattern.svg.defs.get(snippet)).to.not.equal(false) }) } it('Draws a button on an anchor point', () => { const part = { name: 'test', draft: ({ points, Point, snippets, Snippet, part }) => { points.anchor = new Point(10, 20) snippets.button = new Snippet('button', points.anchor) return part }, plugins: [annotationsPlugin], } const Pattern = new Design({ parts: [part], noCorePlugins: true }) const svg = new Pattern().draft().render() expect(svg).to.contain(' { const part = { name: 'test', draft: ({ points, Point, snippets, Snippet, part }) => { points.anchor = new Point(10, 20) snippets.button = new Snippet('buttonhole', points.anchor) return part }, plugins: [annotationsPlugin], } const Pattern = new Design({ parts: [part], noCorePlugins: true }) const svg = new Pattern().draft().render() expect(svg).to.contain(' { const part = { name: 'test', draft: ({ points, Point, snippets, Snippet, part }) => { points.anchor = new Point(10, 20) snippets.button = new Snippet('buttonhole-start', points.anchor) return part }, plugins: [annotationsPlugin], } const Pattern = new Design({ parts: [part], noCorePlugins: true }) const svg = new Pattern().draft().render() expect(svg).to.contain(' { const part = { name: 'test', draft: ({ points, Point, snippets, Snippet, part }) => { points.anchor = new Point(10, 20) snippets.button = new Snippet('buttonhole-end', points.anchor) return part }, plugins: [annotationsPlugin], } const Pattern = new Design({ parts: [part], noCorePlugins: true }) const svg = new Pattern().draft().render() expect(svg).to.contain(' { const part = { name: 'test', draft: ({ points, Point, snippets, Snippet, part }) => { points.anchor = new Point(10, 20) snippets.button = new Snippet('snap-stud', points.anchor) return part }, plugins: [annotationsPlugin], } const Pattern = new Design({ parts: [part], noCorePlugins: true }) const svg = new Pattern().draft().render() expect(svg).to.contain(' { const part = { name: 'test', draft: ({ points, Point, snippets, Snippet, part }) => { points.anchor = new Point(10, 20) snippets.button = new Snippet('snap-socket', points.anchor) return part }, plugins: [annotationsPlugin], } const Pattern = new Design({ parts: [part], noCorePlugins: true }) const svg = new Pattern().draft().render() expect(svg).to.contain('