2021-11-27 16:44:13 +01:00
|
|
|
import chai from 'chai'
|
2022-09-07 10:57:47 +02:00
|
|
|
import { Design } from '@freesewing/core'
|
2022-09-12 17:52:55 +02:00
|
|
|
import { plugin } from '../src/index.mjs'
|
2021-11-27 16:44:13 +01:00
|
|
|
|
|
|
|
const expect = chai.expect
|
|
|
|
|
2022-08-28 12:44:22 +02:00
|
|
|
const content = {
|
2023-07-04 20:28:09 +02:00
|
|
|
en: {
|
|
|
|
testString: 'This is a test string for the i18n plugin',
|
2022-09-12 17:52:55 +02:00
|
|
|
},
|
2022-08-28 12:44:22 +02:00
|
|
|
}
|
|
|
|
|
2021-11-27 16:44:13 +01:00
|
|
|
describe('I18n Plugin Tests', () => {
|
|
|
|
it('Should translate text on insert', () => {
|
2022-09-12 17:52:55 +02:00
|
|
|
const part = {
|
|
|
|
name: 'test',
|
|
|
|
draft: ({ points, Point, macro, part }) => {
|
|
|
|
points.anchor = new pattern.Point(-12, -34).attr('data-text', 'testString')
|
|
|
|
points.from = new Point(10, 20)
|
|
|
|
points.to = new Point(10, 230)
|
|
|
|
macro('grainline', {
|
|
|
|
from: points.from,
|
|
|
|
to: points.to,
|
|
|
|
})
|
|
|
|
return part
|
|
|
|
},
|
|
|
|
plugins: [[plugin, content]],
|
|
|
|
}
|
|
|
|
const Pattern = new Design({ parts: [part] })
|
|
|
|
const pattern = new Pattern()
|
2021-11-27 16:44:13 +01:00
|
|
|
const svg = pattern.draft().render()
|
2023-07-04 20:28:09 +02:00
|
|
|
expect(svg).to.contain(content.en.testString)
|
2021-11-27 16:44:13 +01:00
|
|
|
})
|
|
|
|
})
|