2021-11-27 16:45:20 +01:00
|
|
|
import chai from 'chai'
|
2022-09-07 10:57:47 +02:00
|
|
|
import { Design } from '@freesewing/core'
|
2022-09-15 13:49:55 +02:00
|
|
|
import { plugin } from '../src/index.mjs'
|
2021-11-27 16:45:20 +01:00
|
|
|
|
|
|
|
const expect = chai.expect
|
|
|
|
|
2022-09-12 15:22:54 +02:00
|
|
|
const part = {
|
|
|
|
name: 'test',
|
|
|
|
draft: ({ Point, snippets, Snippet }) => {
|
|
|
|
snippets.button = new Snippet('notch', new Point(10, 20))
|
|
|
|
},
|
|
|
|
}
|
|
|
|
const Pattern = new Design({ plugins: [plugin], parts: [part] })
|
|
|
|
const pattern = new Pattern()
|
2021-11-27 16:45:20 +01:00
|
|
|
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)
|
|
|
|
})
|
|
|
|
|
2022-09-12 15:22:54 +02:00
|
|
|
it('Draws a notch on an anchor point', () => {
|
|
|
|
const part = {
|
|
|
|
name: 'test',
|
|
|
|
draft: ({ Point, snippets, Snippet }) => {
|
|
|
|
snippets.button = new Snippet('notch', new Point(10, 20))
|
|
|
|
},
|
|
|
|
}
|
|
|
|
const Pattern = new Design({ plugins: [plugin], parts: [part] })
|
2022-08-28 13:35:57 +02:00
|
|
|
const pattern = new Pattern()
|
2022-09-12 15:22:54 +02:00
|
|
|
pattern.draft().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"')
|
|
|
|
})
|
2021-11-27 16:45:20 +01:00
|
|
|
})
|