1
0
Fork 0
freesewing/plugins/plugin-theme/tests/plugin.test.mjs

44 lines
1.4 KiB
JavaScript
Raw Normal View History

import chai from 'chai'
2022-09-07 10:57:47 +02:00
import { Design } from '@freesewing/core'
2022-08-28 14:03:14 +02:00
import { plugin } from '../dist/index.mjs'
const expect = chai.expect
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)
pattern.draft().render()
2022-09-12 15:38:05 +02:00
it('Should load base CSS', () => {
expect(pattern.svg.style).to.contain('svg.freesewing')
})
2022-09-12 15:38:05 +02:00
it('Should load the metric grid for paperless', () => {
expect(pattern.svg.defs).to.contain('gridline-xs')
expect(pattern.svg.defs).to.contain('M 10 0 L 10 100 M 20 0 L 20')
2022-09-12 15:38:05 +02: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)
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-09-12 15:38:05 +02:00
it('Should apply scale.', () => {
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-12 15:38:05 +02:00
it('Should round after applying scale.', () => {
pattern.settings.scale = 1 / 3
pattern.draft().render()
expect(pattern.svg.style).to.contain('svg.freesewing .text-xxl {\n font-size: 4px')
})
})