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

31 lines
915 B
JavaScript
Raw Normal View History

import chai from 'chai'
2022-08-28 13:35:57 +02:00
import { Pattern } from '@freesewing/core'
import { plugin } from '../dist/index.mjs'
const expect = chai.expect
2022-08-28 13:35:57 +02:00
const pattern = new Pattern().use(plugin)
pattern.draft().render()
describe('Notches Plugin Test', () => {
it(`Should add the snippets to defs`, () => {
expect(pattern.svg.defs).to.contain('<g id="notch">')
})
2022-01-27 20:52:55 +01:00
it(`Should add the notches snippet to defs`, () => {
expect(pattern.svg.defs.indexOf(`<g id="notch">`)).to.not.equal(-1)
})
it("Draws a notch on an anchor point", () => {
2022-08-28 13:35:57 +02:00
const pattern = new Pattern()
2022-01-27 20:52:55 +01:00
pattern.use(plugin)
pattern.parts.test = new pattern.Part()
2022-08-28 13:35:57 +02:00
const { Point, snippets, Snippet } = pattern.parts.test.shorthand()
2022-01-27 20:52:55 +01:00
snippets.button = new Snippet('notch', new Point(10,20))
pattern.render()
2022-08-28 13:35:57 +02:00
const c = pattern.svg
2022-01-27 20:52:55 +01:00
expect(c.layout.test.svg).to.contain('<use x="10" y="20" xlink:href="#notch"')
})
})