1
0
Fork 0
freesewing/plugins/plugin-annotations/tests/notches.test.mjs

40 lines
1.2 KiB
JavaScript
Raw Normal View History

import { expect } from 'chai'
2023-03-09 05:20:51 +00:00
import { Design } from '@freesewing/core'
import { annotationsPlugin } from '../src/index.mjs'
2023-03-09 05:20:51 +00:00
const part = {
name: 'test',
draft: ({ Point, snippets, Snippet }) => {
snippets.button = new Snippet('notch', new Point(10, 20))
},
plugins: [annotationsPlugin],
2023-03-09 05:20:51 +00:00
}
const Pattern = new Design({ parts: [part], noCorePlugins: true })
2023-03-09 05:20:51 +00:00
const pattern = new Pattern()
pattern.draft().render()
describe('Notches Plugin Test', () => {
2023-04-21 03:48:37 +00:00
it(`Should add the bnotch to defs`, () => {
expect(pattern.svg.defs.get('bnotch')).to.not.equal(false)
2023-03-09 05:20:51 +00:00
})
2023-04-21 03:48:37 +00:00
it(`Should add the notch to defs`, () => {
expect(pattern.svg.defs.get('notch')).to.not.equal(false)
2023-03-09 05:20:51 +00:00
})
it('Draws a notch on an anchor point', () => {
const part = {
name: 'test',
draft: ({ Point, snippets, Snippet, part }) => {
snippets.button = new Snippet('notch', new Point(10, 20))
return part
},
plugins: [annotationsPlugin],
2023-03-09 05:20:51 +00:00
}
const Pattern = new Design({ parts: [part], noCorePlugins: true })
2023-03-09 05:20:51 +00:00
const pattern = new Pattern()
pattern.draft().render()
const c = pattern.svg
expect(c.layout.test.svg).to.contain('<use x="10" y="20" xlink:href="#notch"')
})
})