2021-11-21 18:06:26 +01:00
|
|
|
import freesewing from '@freesewing/core'
|
|
|
|
import { strings } from '@freesewing/i18n'
|
|
|
|
import { version } from '../package.json'
|
2018-12-17 15:59:54 +01:00
|
|
|
|
2021-11-21 18:06:26 +01:00
|
|
|
const chai = require('chai')
|
|
|
|
const expect = chai.expect
|
|
|
|
const plugin = require('../dist/index.js')
|
2018-12-17 15:59:54 +01:00
|
|
|
|
2021-11-21 18:06:26 +01:00
|
|
|
it('Should set the plugin name:version attribute', () => {
|
|
|
|
const pattern = new freesewing.Pattern().use(plugin, {})
|
|
|
|
pattern.draft().render()
|
|
|
|
expect(pattern.svg.attributes.get('freesewing:plugin-i18n')).to.equal(version)
|
|
|
|
})
|
|
|
|
|
|
|
|
it('Should translate text on insert', () => {
|
|
|
|
const pattern = new freesewing.Pattern().use(plugin, { strings })
|
|
|
|
pattern.parts.test = new pattern.Part()
|
2018-12-17 15:59:54 +01:00
|
|
|
pattern.parts.test.points.anchor = new pattern.Point(-12, -34).attr(
|
2021-11-21 18:06:26 +01:00
|
|
|
'data-text',
|
|
|
|
'plugin.cutTwoStripsToFinishTheArmholes'
|
|
|
|
)
|
|
|
|
const svg = pattern.draft().render()
|
|
|
|
expect(svg).to.contain('Cut two strips to finish the armholes')
|
|
|
|
})
|