2024-02-04 12:14:42 +01:00
|
|
|
import { expect } 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:46:30 +01:00
|
|
|
|
|
|
|
describe('Theme Plugin Tests', () => {
|
2022-09-07 10:57:47 +02:00
|
|
|
const Pattern = new Design()
|
2022-09-12 15:38:05 +02:00
|
|
|
const pattern = new Pattern({ paperless: true }).use(plugin)
|
2021-11-27 16:46:30 +01:00
|
|
|
pattern.draft().render()
|
|
|
|
|
2022-09-12 15:38:05 +02:00
|
|
|
it('Should load base CSS', () => {
|
2021-11-27 16:46:30 +01:00
|
|
|
expect(pattern.svg.style).to.contain('svg.freesewing')
|
|
|
|
})
|
|
|
|
|
2022-09-25 10:53:54 +02:00
|
|
|
/*
|
|
|
|
* FIXME: Re-implement this for v3
|
2022-09-12 15:38:05 +02:00
|
|
|
it('Should load the metric grid for paperless', () => {
|
2022-09-25 10:53:54 +02:00
|
|
|
expect(pattern.svg.head).to.contain('gridline-xs')
|
|
|
|
expect(pattern.svg.head).to.contain('M 10 0 L 10 100 M 20 0 L 20')
|
2022-09-12 15:38:05 +02:00
|
|
|
})
|
2021-11-27 16:46:30 +01:00
|
|
|
|
2022-09-12 15:38:05 +02:00
|
|
|
it('Should load the imperial grid for paperless', () => {
|
|
|
|
const pattern = new Pattern({ paperless: true, units: 'imperial' }).use(plugin)
|
2021-11-27 16:46:30 +01:00
|
|
|
pattern.draft().render()
|
|
|
|
expect(pattern.svg.defs).to.contain('gridline-sm')
|
|
|
|
expect(pattern.svg.defs).to.contain('M 12.7 0 L 12.7')
|
2022-09-12 15:38:05 +02:00
|
|
|
})
|
2022-01-13 19:45:44 +01:00
|
|
|
|
2022-09-12 15:38:05 +02:00
|
|
|
it('Should apply scale.', () => {
|
2022-01-13 19:45:44 +01:00
|
|
|
expect(pattern.svg.style).to.contain('svg.freesewing .text-xxl {\n font-size: 12px')
|
|
|
|
|
|
|
|
pattern.settings.scale = 2
|
|
|
|
pattern.draft().render()
|
|
|
|
|
|
|
|
expect(pattern.svg.style).to.contain('svg.freesewing .text-xxl {\n font-size: 24px;')
|
|
|
|
})
|
2022-09-25 10:53:54 +02:00
|
|
|
*/
|
2022-01-13 19:45:44 +01:00
|
|
|
|
2022-09-12 15:38:05 +02:00
|
|
|
it('Should round after applying scale.', () => {
|
2023-06-02 22:34:48 +00:00
|
|
|
pattern.settings[0].scale = 1 / 3
|
2022-01-13 19:45:44 +01:00
|
|
|
pattern.draft().render()
|
|
|
|
|
|
|
|
expect(pattern.svg.style).to.contain('svg.freesewing .text-xxl {\n font-size: 4px')
|
|
|
|
})
|
2021-11-27 16:46:30 +01:00
|
|
|
})
|