diff --git a/plugins/plugin-dimension/src/index.mjs b/plugins/plugin-dimension/src/index.mjs index 236ad786829..07a51f765e4 100644 --- a/plugins/plugin-dimension/src/index.mjs +++ b/plugins/plugin-dimension/src/index.mjs @@ -151,4 +151,3 @@ export const plugin = { // More specifically named exports export const dimensionPlugin = plugin export const pluginDimension = plugin - diff --git a/plugins/plugin-dimension/tests/plugin.test.mjs b/plugins/plugin-dimension/tests/plugin.test.mjs index 68573ef12d7..50e1b65fa7a 100644 --- a/plugins/plugin-dimension/tests/plugin.test.mjs +++ b/plugins/plugin-dimension/tests/plugin.test.mjs @@ -1,22 +1,26 @@ import chai from 'chai' -import { Pattern, round } from '@freesewing/core' +import { Design, Pattern, round } from '@freesewing/core' import { plugin } from './dist/index.mjs' const expect = chai.expect describe('Dimension Plugin Tests', () => { - describe('Measures horizontal dimensions', function () { - const pattern = new Pattern().use(plugin) - pattern.parts.test = new pattern.Part() - pattern.parts.test.points.from = new pattern.Point(10, 20) - pattern.parts.test.points.to = new pattern.Point(200, 20) - const { macro } = pattern.parts.test.shorthand() - macro('hd', { - from: pattern.parts.test.points.from, - to: pattern.parts.test.points.to, - y: 35, - }) + const part = { + name: 'test', + draft: ({ Point, points, macro }) => { + points.from = new Point(10, 20) + points.to = new Point(200, 20) + macro('hd', { + from: points.from, + to: points.to, + y: 35, + }) + }, + } + const Test = new Design({ plugins: [plugin], parts: [part] }) + const pattern = new Test() + pattern.draft() it('should draw a line and add text to indicate its length', () => { const c = pattern.parts.test.paths['__paperless1'] @@ -57,16 +61,21 @@ describe('Dimension Plugin Tests', () => { }) describe('Measures vertical dimensions', () => { - const pattern = new Pattern().use(plugin) - pattern.parts.test = new pattern.Part() - pattern.parts.test.points.from = new pattern.Point(10, 20) - pattern.parts.test.points.to = new pattern.Point(10, 200) - const { macro } = pattern.parts.test.shorthand() - macro('vd', { - from: pattern.parts.test.points.from, - to: pattern.parts.test.points.to, - x: 25, - }) + const part = { + name: 'test', + draft: ({ Point, points, macro }) => { + points.from = new Point(10, 20) + points.to = new Point(10, 200) + macro('vd', { + from: points.from, + to: points.to, + x: 25, + }) + }, + } + const Test = new Design({ plugins: [plugin], parts: [part] }) + const pattern = new Test() + pattern.draft() it('Should draw a line and add text to indicate its length', () => { const c = pattern.parts.test.paths['__paperless1'] @@ -107,16 +116,21 @@ describe('Dimension Plugin Tests', () => { }) describe('Measures the length of straight lines', () => { - const pattern = new Pattern().use(plugin) - pattern.parts.test = new pattern.Part() - pattern.parts.test.points.from = new pattern.Point(10, 10) - pattern.parts.test.points.to = new pattern.Point(100, 100) - const { macro } = pattern.parts.test.shorthand() - macro('ld', { - from: pattern.parts.test.points.from, - to: pattern.parts.test.points.to, - d: 15, - }) + const part = { + name: 'test', + draft: ({ Point, points, macro }) => { + points.from = new Point(10, 10) + points.to = new Point(100, 100) + macro('ld', { + from: points.from, + to: points.to, + d: 15, + }) + }, + } + const Test = new Design({ plugins: [plugin], parts: [part] }) + const pattern = new Test() + pattern.draft() it('Should draw a line and add text to indicate its length', () => { const c = pattern.parts.test.paths['__paperless1'] @@ -157,19 +171,22 @@ describe('Dimension Plugin Tests', () => { }) describe('Measures curved lines', () => { - const pattern = new Pattern() - pattern.draft = function () {} - pattern.use(plugin) - pattern.parts.test = new pattern.Part() - const from = new pattern.Point(10, 10) - const cp1 = new pattern.Point(100, 10) - const cp2 = new pattern.Point(10, 100) - const to = new pattern.Point(100, 100) - const { macro } = pattern.parts.test.shorthand() - macro('pd', { - path: new pattern.Path().move(from).curve(cp1, cp2, to), - d: 15, - }) + const part = { + name: 'test', + draft: ({ Point, points, macro, Path }) => { + points.from = new Point(10, 10) + points.cp1 = new Point(100, 10) + points.cp2 = new Point(10, 100) + points.to = new Point(100, 100) + macro('pd', { + path: new Path().move(points.from).curve(points.cp1, points.cp2, points.to), + d: 15, + }) + }, + } + const Test = new Design({ plugins: [plugin], parts: [part] }) + const pattern = new Test() + pattern.draft() it('Should draw a line and add text to indicate the length', () => { const c = pattern.parts.test.paths['__paperless1'] diff --git a/plugins/plugin-dimension/tests/shared.test.mjs b/plugins/plugin-dimension/tests/shared.test.mjs index fdf846844b0..ea9a6b5c890 100644 --- a/plugins/plugin-dimension/tests/shared.test.mjs +++ b/plugins/plugin-dimension/tests/shared.test.mjs @@ -4,4 +4,3 @@ import { sharedPluginTests } from '../../../tests/plugins/shared.mjs' // Run shared tests sharedPluginTests(plugin) -