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-08-28 12:44:22 +02:00
|
|
|
import { plugin } from '../dist/index.mjs'
|
2021-11-27 16:44:13 +01:00
|
|
|
|
|
|
|
const expect = chai.expect
|
|
|
|
|
2022-08-28 12:44:22 +02:00
|
|
|
const content = {
|
|
|
|
strings: {
|
|
|
|
en: {
|
|
|
|
testString: 'This is a test string for the i18n plugin'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-11-27 16:44:13 +01:00
|
|
|
describe('I18n Plugin Tests', () => {
|
|
|
|
it('Should translate text on insert', () => {
|
2022-09-07 10:57:47 +02:00
|
|
|
const Pattern = new Design()
|
2022-08-28 12:44:22 +02:00
|
|
|
const pattern = new Pattern().use(plugin, content)
|
2021-11-27 16:44:13 +01:00
|
|
|
pattern.parts.test = new pattern.Part()
|
|
|
|
pattern.parts.test.points.anchor = new pattern.Point(-12, -34).attr(
|
|
|
|
'data-text',
|
2022-08-28 12:44:22 +02:00
|
|
|
'testString'
|
2021-11-27 16:44:13 +01:00
|
|
|
)
|
|
|
|
const svg = pattern.draft().render()
|
2022-08-28 12:44:22 +02:00
|
|
|
expect(svg).to.contain(content.strings.en.testString)
|
2021-11-27 16:44:13 +01:00
|
|
|
})
|
|
|
|
})
|