chore(core): Linting and more tests
This commit is contained in:
parent
b3679ede55
commit
47a7a71b61
8 changed files with 159 additions and 520 deletions
|
@ -1,75 +0,0 @@
|
|||
import chai from 'chai'
|
||||
import { Design } from '../src/index.mjs'
|
||||
|
||||
const expect = chai.expect
|
||||
|
||||
describe('Multisets', () => {
|
||||
describe('FIXME', () => {
|
||||
const partA = {
|
||||
name: 'test.partA',
|
||||
measurements: ['head'],
|
||||
options: {
|
||||
size: { pct: 40, min: 20, max: 80 },
|
||||
},
|
||||
draft: ({ points, Point, paths, Path, part, store, measurements, options }) => {
|
||||
store.set('size', measurements.head * options.size)
|
||||
points.from = new Point(0, 0)
|
||||
points.to = new Point(0, store.get('size'))
|
||||
paths.line = new Path().move(points.from).line(points.to)
|
||||
return part
|
||||
},
|
||||
//stack: 'box',
|
||||
}
|
||||
const partB = {
|
||||
name: 'test.partB',
|
||||
measurements: ['head'],
|
||||
after: partA,
|
||||
draft: ({ points, Point, paths, Path, part, store }) => {
|
||||
points.from = new Point(0, store.get('size'))
|
||||
points.to = new Point(store.get('size'), store.get('size'))
|
||||
paths.line = new Path().move(points.from).line(points.to)
|
||||
return part
|
||||
},
|
||||
//stack: 'box',
|
||||
}
|
||||
const partC = {
|
||||
name: 'test.partC',
|
||||
after: partB,
|
||||
draft: ({ points, Point, paths, Path, part, store }) => {
|
||||
points.from = new Point(store.get('size'), store.get('size'))
|
||||
points.to = new Point(store.get('size'), 0)
|
||||
paths.line = new Path().move(points.from).line(points.to)
|
||||
return part
|
||||
},
|
||||
//stack: 'box',
|
||||
}
|
||||
const partD = {
|
||||
name: 'test.partD',
|
||||
after: partC,
|
||||
draft: ({ points, Point, paths, Path, part, store }) => {
|
||||
points.from = new Point(store.get('size'), 0)
|
||||
points.to = new Point(0, 0)
|
||||
paths.line = new Path().move(points.from).line(points.to)
|
||||
return part
|
||||
},
|
||||
// stack: 'box',
|
||||
}
|
||||
|
||||
const Pattern = new Design({
|
||||
data: {
|
||||
name: 'test',
|
||||
version: '1.2.3',
|
||||
},
|
||||
parts: [partD],
|
||||
})
|
||||
const pattern = new Pattern([
|
||||
{
|
||||
measurements: { head: 400 },
|
||||
},
|
||||
{
|
||||
measurements: { head: 400 },
|
||||
},
|
||||
])
|
||||
pattern.draft()
|
||||
})
|
||||
})
|
|
@ -45,7 +45,7 @@ describe('Part', () => {
|
|||
const part = {
|
||||
name: 'test',
|
||||
draft: ({ part, Point, points, macro }) => {
|
||||
points.example = new Point(12,34)
|
||||
points.example = new Point(12, 34)
|
||||
macro('test', { x: 123, y: 456 })
|
||||
return part
|
||||
},
|
||||
|
@ -176,7 +176,7 @@ describe('Part', () => {
|
|||
}
|
||||
const design = new Design({ parts: [part] })
|
||||
// Let's also cover the branch where complete is false
|
||||
const pattern = new design({ complete: false} )
|
||||
const pattern = new design({ complete: false })
|
||||
pattern.draft()
|
||||
expect(pattern.setStores[0].logs.warning.length).to.equal(1)
|
||||
expect(pattern.setStores[0].logs.warning[0]).to.equal(
|
||||
|
@ -208,7 +208,7 @@ describe('Part', () => {
|
|||
name: 'test',
|
||||
draft: ({ Point, snippets, Snippet, part }) => {
|
||||
method = Snippet
|
||||
snippets.test = new Snippet('notch', new Point(19,80))
|
||||
snippets.test = new Snippet('notch', new Point(19, 80))
|
||||
return part
|
||||
},
|
||||
}
|
||||
|
@ -268,12 +268,10 @@ describe('Part', () => {
|
|||
const part = {
|
||||
name: 'test',
|
||||
options: {
|
||||
test: { pct: 10, min: 5, max: 25, snap: 5, ...pctBasedOn('head') }
|
||||
test: { pct: 10, min: 5, max: 25, snap: 5, ...pctBasedOn('head') },
|
||||
},
|
||||
draft: ({ paths, Path, Point, absoluteOptions, part }) => {
|
||||
paths.test = new Path()
|
||||
.move(new Point(0,0))
|
||||
.line(new Point(absoluteOptions.test, 0))
|
||||
paths.test = new Path().move(new Point(0, 0)).line(new Point(absoluteOptions.test, 0))
|
||||
return part
|
||||
},
|
||||
}
|
||||
|
@ -287,40 +285,46 @@ describe('Part', () => {
|
|||
const part = {
|
||||
name: 'test',
|
||||
draft: ({ options, part }) => {
|
||||
if (options.test || true) return part
|
||||
if (options.test) return part
|
||||
else return part
|
||||
},
|
||||
}
|
||||
const design = new Design({ parts: [part] })
|
||||
const pattern = new design()
|
||||
pattern.draft()
|
||||
expect(pattern.setStores[0].logs.warning.length).to.equal(1)
|
||||
expect(pattern.setStores[0].logs.warning[0]).to.equal('Tried to access `options.test` but it is `undefined`')
|
||||
expect(pattern.setStores[0].logs.warning[0]).to.equal(
|
||||
'Tried to access `options.test` but it is `undefined`'
|
||||
)
|
||||
})
|
||||
|
||||
it('Accessing unknown absoluteOption should log a warning', () => {
|
||||
const part = {
|
||||
name: 'test',
|
||||
draft: ({ absoluteOptions, part }) => {
|
||||
if (absoluteOptions.test || true) return part
|
||||
if (absoluteOptions.test) return part
|
||||
else return part
|
||||
},
|
||||
}
|
||||
const design = new Design({ parts: [part] })
|
||||
const pattern = new design()
|
||||
pattern.draft()
|
||||
expect(pattern.setStores[0].logs.warning.length).to.equal(1)
|
||||
expect(pattern.setStores[0].logs.warning[0]).to.equal('Tried to access `absoluteOptions.test` but it is `undefined`')
|
||||
expect(pattern.setStores[0].logs.warning[0]).to.equal(
|
||||
'Tried to access `absoluteOptions.test` but it is `undefined`'
|
||||
)
|
||||
})
|
||||
|
||||
it('Injecting a part should contain all data', () => {
|
||||
const from = {
|
||||
name: 'from',
|
||||
draft: ({ points, Point, paths, Path, snippets, Snippet, part }) => {
|
||||
points.from = new Point(0,0)
|
||||
points.to = new Point(19,80)
|
||||
points.start = new Point(100,100)
|
||||
points.cp1 = new Point(100,200)
|
||||
points.cp2 = new Point(200,100)
|
||||
points.end = new Point(200,200)
|
||||
points.from = new Point(0, 0)
|
||||
points.to = new Point(19, 80)
|
||||
points.start = new Point(100, 100)
|
||||
points.cp1 = new Point(100, 200)
|
||||
points.cp2 = new Point(200, 100)
|
||||
points.end = new Point(200, 200)
|
||||
paths.line = new Path().move(points.from).line(points.to)
|
||||
paths.curve = new Path().move(points.start).curve(points.cp1, points.cp2, points.end)
|
||||
snippets.test = new Snippet('notch', points.end)
|
||||
|
@ -330,7 +334,7 @@ describe('Part', () => {
|
|||
const to = {
|
||||
from,
|
||||
name: 'to',
|
||||
draft: ({ part }) => part
|
||||
draft: ({ part }) => part,
|
||||
}
|
||||
const design = new Design({ parts: [from, to] })
|
||||
const pattern = new design()
|
||||
|
|
|
@ -78,13 +78,15 @@ describe('Path', () => {
|
|||
const pattern = new design()
|
||||
pattern.draft()
|
||||
expect(pattern.setStores[0].logs.warning.length).to.equal(2)
|
||||
expect(pattern.setStores[0].logs.warning[0]).to.equal('Called `Path.smurve(cp2, to)` but `to` is not a `Point` object')
|
||||
expect(pattern.setStores[0].logs.warning[0]).to.equal(
|
||||
'Called `Path.smurve(cp2, to)` but `to` is not a `Point` object'
|
||||
)
|
||||
})
|
||||
|
||||
it('Should log a warning when passing a non-Point to smurve_()', () => {
|
||||
const part = {
|
||||
name: 'test',
|
||||
draft: ({ Point, Path, paths, part }) => {
|
||||
draft: ({ Path, paths, part }) => {
|
||||
paths.test = new Path().smurve_('hi')
|
||||
|
||||
return part
|
||||
|
@ -94,7 +96,9 @@ describe('Path', () => {
|
|||
const pattern = new design()
|
||||
pattern.draft()
|
||||
expect(pattern.setStores[0].logs.warning.length).to.equal(1)
|
||||
expect(pattern.setStores[0].logs.warning[0]).to.equal('Called `Path.smurve_(to)` but `to` is not a `Point` object')
|
||||
expect(pattern.setStores[0].logs.warning[0]).to.equal(
|
||||
'Called `Path.smurve_(to)` but `to` is not a `Point` object'
|
||||
)
|
||||
})
|
||||
|
||||
it('Should log a warning when passing a non-Path to the paths proxy', () => {
|
||||
|
@ -110,8 +114,12 @@ describe('Path', () => {
|
|||
const pattern = new design()
|
||||
pattern.draft()
|
||||
expect(pattern.setStores[0].logs.warning.length).to.equal(2)
|
||||
expect(pattern.setStores[0].logs.warning[0]).to.equal('`paths.test` was set with a value that is not a `Path` object')
|
||||
expect(pattern.setStores[0].logs.warning[1]).to.equal('Could not set `name` property on `paths.test`')
|
||||
expect(pattern.setStores[0].logs.warning[0]).to.equal(
|
||||
'`paths.test` was set with a value that is not a `Path` object'
|
||||
)
|
||||
expect(pattern.setStores[0].logs.warning[1]).to.equal(
|
||||
'Could not set `name` property on `paths.test`'
|
||||
)
|
||||
})
|
||||
|
||||
it('Should offset a line', () => {
|
||||
|
@ -232,9 +240,7 @@ describe('Path', () => {
|
|||
const part = {
|
||||
name: 'test',
|
||||
draft: ({ paths, Path, Point, part }) => {
|
||||
paths.line = new Path()
|
||||
.move(new Point(0, 0))
|
||||
.line(new Point(0, 50))
|
||||
paths.line = new Path().move(new Point(0, 0)).line(new Point(0, 50))
|
||||
return part
|
||||
},
|
||||
}
|
||||
|
@ -706,7 +712,7 @@ describe('Path', () => {
|
|||
const a = new Point(45, 60)
|
||||
const b = new Point(10, 30)
|
||||
const c = new Point(90, 30)
|
||||
const test = new Path().move(a)._curve(b,b)._curve(c,c)
|
||||
const test = new Path().move(a)._curve(b, b)._curve(c, c)
|
||||
|
||||
let halves = test.split(b)
|
||||
expect(halves[0].ops[1].to.x).to.equal(10)
|
||||
|
@ -787,7 +793,7 @@ describe('Path', () => {
|
|||
it('Calling translate with non-numbers should generate a warning', () => {
|
||||
const log = []
|
||||
const p = new Path()
|
||||
p.log = { warning: msg => log.push(msg) }
|
||||
p.log = { warning: (msg) => log.push(msg) }
|
||||
p.translate('a', 'b')
|
||||
expect(log.length).to.equal(2)
|
||||
expect(log[0]).to.equal('Called `Path.translate(x, y)` but `x` is not a number')
|
||||
|
@ -1149,7 +1155,7 @@ describe('Path', () => {
|
|||
it('Should log a warning when splitting a path on a non-point', () => {
|
||||
const part = {
|
||||
name: 'test',
|
||||
draft: ({ Path, Point, points, part}) => {
|
||||
draft: ({ Path, Point, points, part }) => {
|
||||
points.a = new Path().move(new Point(0, 0)).line(new Point(0, 40)).split()
|
||||
return part
|
||||
},
|
||||
|
@ -1165,10 +1171,10 @@ describe('Path', () => {
|
|||
it('Should add a class', () => {
|
||||
const part = {
|
||||
name: 'test',
|
||||
draft: ({ Path, paths, Point, points, part }) => {
|
||||
draft: ({ Path, paths, Point, part }) => {
|
||||
paths.line = new Path()
|
||||
.move(new Point(0,0))
|
||||
.line(new Point(10,10))
|
||||
.move(new Point(0, 0))
|
||||
.line(new Point(10, 10))
|
||||
.addClass('fabric banana')
|
||||
return part
|
||||
},
|
||||
|
@ -1187,5 +1193,4 @@ describe('Path', () => {
|
|||
path.unhide()
|
||||
expect(path.hidden).to.equal(false)
|
||||
})
|
||||
|
||||
})
|
||||
|
|
|
@ -5,7 +5,6 @@ const expect = chai.expect
|
|||
|
||||
describe('Pattern', () => {
|
||||
describe('Pattern.constructor()', () => {
|
||||
|
||||
it('Pattern constructor should return pattern object', () => {
|
||||
const Pattern = new Design()
|
||||
const pattern = new Pattern()
|
||||
|
@ -521,7 +520,7 @@ describe('Pattern', () => {
|
|||
}
|
||||
const part = {
|
||||
name: 'test.part',
|
||||
plugins: [ plugin1, plugin2 ],
|
||||
plugins: [plugin1, plugin2],
|
||||
draft: (part) => part,
|
||||
}
|
||||
const design = new Design({ parts: [part] })
|
||||
|
@ -543,10 +542,10 @@ describe('Pattern', () => {
|
|||
const condition = () => true
|
||||
const part = {
|
||||
name: 'test.part',
|
||||
plugins: [ { plugin, condition } ],
|
||||
plugins: [{ plugin, condition }],
|
||||
draft: (part) => part,
|
||||
}
|
||||
const design = new Design({ parts: [ part ] })
|
||||
const design = new Design({ parts: [part] })
|
||||
const pattern = new design()
|
||||
pattern.draft()
|
||||
expect(pattern.hooks.preRender.length).to.equal(1)
|
||||
|
@ -565,10 +564,10 @@ describe('Pattern', () => {
|
|||
const condition = () => false
|
||||
const part = {
|
||||
name: 'test.part',
|
||||
plugins: [ { plugin, condition } ],
|
||||
plugins: [{ plugin, condition }],
|
||||
draft: (part) => part,
|
||||
}
|
||||
const design = new Design({ parts: [ part ] })
|
||||
const design = new Design({ parts: [part] })
|
||||
const pattern = new design()
|
||||
expect(pattern.hooks.preRender.length).to.equal(0)
|
||||
})
|
||||
|
@ -602,7 +601,7 @@ describe('Pattern', () => {
|
|||
],
|
||||
draft: (part) => part,
|
||||
}
|
||||
const design = new Design({ parts: [ part ] })
|
||||
const design = new Design({ parts: [part] })
|
||||
const pattern = new design()
|
||||
pattern.draft()
|
||||
expect(pattern.hooks.preRender.length).to.equal(1)
|
||||
|
@ -631,22 +630,16 @@ describe('Pattern', () => {
|
|||
const condition2 = () => false
|
||||
const part1 = {
|
||||
name: 'part1',
|
||||
plugins: [
|
||||
[plugin1, { some: 'data'} ],
|
||||
{ plugin: plugin2, condition: condition1 }
|
||||
],
|
||||
draft: ({ part }) => part
|
||||
plugins: [[plugin1, { some: 'data' }], { plugin: plugin2, condition: condition1 }],
|
||||
draft: ({ part }) => part,
|
||||
}
|
||||
const part2 = {
|
||||
name: 'part2',
|
||||
plugins: [
|
||||
plugin2,
|
||||
{ plugin: plugin2, condition: condition2 },
|
||||
],
|
||||
draft: ({ part }) => part
|
||||
plugins: [plugin2, { plugin: plugin2, condition: condition2 }],
|
||||
draft: ({ part }) => part,
|
||||
}
|
||||
const design = new Design({
|
||||
parts: [ part1, part2 ]
|
||||
parts: [part1, part2],
|
||||
})
|
||||
const pattern = new design()
|
||||
pattern.__init()
|
||||
|
@ -712,15 +705,13 @@ describe('Pattern', () => {
|
|||
const part = {
|
||||
name: 'test',
|
||||
draft: ({ Point, paths, Path, part, context }) => {
|
||||
paths.test = new Path()
|
||||
.move(new Point(0,0))
|
||||
.line(new Point(100,0))
|
||||
paths.test = new Path().move(new Point(0, 0)).line(new Point(100, 0))
|
||||
partContext = context
|
||||
|
||||
return part
|
||||
},
|
||||
}
|
||||
}
|
||||
const Pattern = new Design({ parts: [part], data: { name: 'test', version: '1' }})
|
||||
const Pattern = new Design({ parts: [part], data: { name: 'test', version: '1' } })
|
||||
const pattern = new Pattern()
|
||||
pattern.draft()
|
||||
expect(typeof partContext).to.equal('object')
|
||||
|
@ -806,12 +797,16 @@ describe('Pattern', () => {
|
|||
options: { unknown: { foo: 30 } },
|
||||
draft: () => {},
|
||||
}
|
||||
const Pattern = new Design({
|
||||
let error
|
||||
try {
|
||||
new Design({
|
||||
data: { name: 'test', version: '1.2.3' },
|
||||
parts: [part],
|
||||
})
|
||||
const pattern = new Pattern()
|
||||
expect(() => pattern.__init()).to.throw()
|
||||
} catch (err) {
|
||||
error = err
|
||||
}
|
||||
expect('' + error).to.contain('Unknown option type')
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
|
@ -4,7 +4,6 @@ import { Design } from '../src/index.mjs'
|
|||
const expect = chai.expect
|
||||
|
||||
describe('Pattern', () => {
|
||||
|
||||
it('Should log an error when a part does not have a name', () => {
|
||||
const part = { draft: ({ part }) => part }
|
||||
const design = new Design()
|
||||
|
@ -20,52 +19,56 @@ describe('Pattern', () => {
|
|||
noDraft: ({ points, part }) => {
|
||||
points.test = false
|
||||
return part
|
||||
}
|
||||
},
|
||||
}
|
||||
const to = {
|
||||
name: 'testTo',
|
||||
from,
|
||||
draft: ({ points, part }) => {
|
||||
return part
|
||||
draft: ({ part }) => part,
|
||||
}
|
||||
}
|
||||
const design = new Design({ parts: [ to ]})
|
||||
const design = new Design({ parts: [to] })
|
||||
const pattern = new design()
|
||||
pattern.draft()
|
||||
expect(pattern.setStores[0].logs.error.length).to.equal(1)
|
||||
expect(pattern.setStores[0].logs.error[0]).to.equal('Unable to draft pattern part __test__. Part.draft() is not callable')
|
||||
expect(pattern.setStores[0].logs.error[0]).to.equal(
|
||||
'Unable to draft pattern part __test__. Part.draft() is not callable'
|
||||
)
|
||||
})
|
||||
|
||||
it('Not returning the part from the draft method should log an error', () => {
|
||||
const test = {
|
||||
name: 'test',
|
||||
draft: ({ points, part }) => {}
|
||||
draft: () => {},
|
||||
}
|
||||
const design = new Design({ parts: [ test ]})
|
||||
const design = new Design({ parts: [test] })
|
||||
const pattern = new design()
|
||||
pattern.draft()
|
||||
expect(pattern.setStores[0].logs.error.length).to.equal(1)
|
||||
expect(pattern.setStores[0].logs.error[0]).to.equal('Result of drafting part test was undefined. Did you forget to return the part?')
|
||||
expect(pattern.setStores[0].logs.error[0]).to.equal(
|
||||
'Result of drafting part test was undefined. Did you forget to return the part?'
|
||||
)
|
||||
})
|
||||
|
||||
it('Should skip unneeded parts', () => {
|
||||
const test = {
|
||||
name: 'test',
|
||||
draft: ({ points, part }) => part
|
||||
draft: ({ part }) => part,
|
||||
}
|
||||
const design = new Design({ parts: [ test ]})
|
||||
const design = new Design({ parts: [test] })
|
||||
const pattern = new design({ only: ['you'] })
|
||||
pattern.draft()
|
||||
expect(pattern.setStores[0].logs.debug.length).to.equal(4)
|
||||
expect(pattern.setStores[0].logs.debug[3]).to.equal('Part `test` is not needed. Skipping draft and setting hidden to `true`')
|
||||
expect(pattern.setStores[0].logs.debug[3]).to.equal(
|
||||
'Part `test` is not needed. Skipping draft and setting hidden to `true`'
|
||||
)
|
||||
})
|
||||
|
||||
it('Should return the initialized config', () => {
|
||||
const test = {
|
||||
name: 'test',
|
||||
draft: ({ points, part }) => part
|
||||
draft: ({ part }) => part,
|
||||
}
|
||||
const design = new Design({ parts: [ test ]})
|
||||
const design = new Design({ parts: [test] })
|
||||
const pattern = new design({ only: ['you'] })
|
||||
const config = pattern.getConfig()
|
||||
expect(config.draftOrder.length).to.equal(1)
|
||||
|
@ -75,10 +78,10 @@ describe('Pattern', () => {
|
|||
it('Should skip a plugin that is loaded twice', () => {
|
||||
const test = {
|
||||
name: 'test',
|
||||
draft: ({ points, part }) => part
|
||||
draft: ({ part }) => part,
|
||||
}
|
||||
const plugin = { name: 'test' }
|
||||
const design = new Design({ parts: [ test ]})
|
||||
const design = new Design({ parts: [test] })
|
||||
const pattern = new design({ only: ['you'] })
|
||||
pattern.use(plugin)
|
||||
pattern.use(plugin)
|
||||
|
@ -100,10 +103,10 @@ describe('Pattern', () => {
|
|||
const test = {
|
||||
name: 'test',
|
||||
hidden: true,
|
||||
draft: ({ points, part }) => part
|
||||
draft: ({ part }) => part,
|
||||
}
|
||||
const design = new Design()
|
||||
const pattern = new design({ only: ['test']})
|
||||
const design = new Design({ parts: [test] })
|
||||
const pattern = new design({ only: ['test'] })
|
||||
pattern.__init()
|
||||
expect(pattern.__isPartHidden('test')).to.equal(false)
|
||||
})
|
||||
|
@ -111,14 +114,14 @@ describe('Pattern', () => {
|
|||
it('Stacks with parts in only are never hidden', () => {
|
||||
const part = {
|
||||
name: 'test',
|
||||
draft: ({ points, Point, paths, Path, part }) => {
|
||||
draft: ({ points, Point, part }) => {
|
||||
points.test = new Point(3, 3)
|
||||
|
||||
return part
|
||||
},
|
||||
}
|
||||
const design = new Design({ parts: [part] })
|
||||
const pattern = new design({ only: [ 'test' ] })
|
||||
const pattern = new design({ only: ['test'] })
|
||||
pattern.draft().render()
|
||||
expect(pattern.__isStackHidden('test')).to.equal(false)
|
||||
})
|
||||
|
@ -126,24 +129,24 @@ describe('Pattern', () => {
|
|||
it('Stacks with parts in only are never hidden', () => {
|
||||
const part = {
|
||||
name: 'test',
|
||||
draft: ({ points, Point, paths, Path, part }) => {
|
||||
draft: ({ points, Point, part }) => {
|
||||
points.test = new Point(3, 3)
|
||||
|
||||
return part
|
||||
},
|
||||
}
|
||||
const design = new Design({ parts: [part] })
|
||||
const pattern = new design({ only: [ 'test' ] })
|
||||
const pattern = new design({ only: ['test'] })
|
||||
pattern.draft().render()
|
||||
expect(pattern.__isStackHidden('test')).to.equal(false)
|
||||
})
|
||||
|
||||
it('Drafts with errors should not get packed', () => {
|
||||
const part= {
|
||||
const part = {
|
||||
name: 'test',
|
||||
draft: ({ points, Point, paths, Path, part }) => {
|
||||
draft: ({ points, Point, part }) => {
|
||||
points.test = new Point(3, 3)
|
||||
joints.foo = 'bar'
|
||||
joints.foo = 'bar' // eslint-disable-line no-undef
|
||||
|
||||
return part
|
||||
},
|
||||
|
@ -155,19 +158,23 @@ describe('Pattern', () => {
|
|||
expect(pattern.setStores[0].logs.error[0][0]).to.equal('Unable to draft part `test` (set 0)')
|
||||
})
|
||||
|
||||
// FIXME: Add assertions here
|
||||
it('Handle layout object', () => {
|
||||
const part = {
|
||||
name: 'test',
|
||||
draft: ({ points, Point, paths, Path, part }) => {
|
||||
draft: ({ points, Point, part }) => {
|
||||
points.test = new Point(3, 3)
|
||||
|
||||
return part
|
||||
},
|
||||
}
|
||||
const design = new Design({ parts: [part] })
|
||||
const pattern = new design({ layout: { stacks: { test: { flipX: true } } } })
|
||||
const pattern = new design({
|
||||
layout: { stacks: { test: { flipX: true } }, width: 300, height: 400 },
|
||||
})
|
||||
const props = pattern.draft().getRenderProps()
|
||||
// FIXME: Add assertions here
|
||||
//expect(pattern.__isStackHidden('test')).to.equal(false)
|
||||
expect(props.stacks.test.attributes.get('transform')).to.equal('scale(-1 1)')
|
||||
expect(props.width).to.equal(300)
|
||||
expect(props.height).to.equal(400)
|
||||
})
|
||||
})
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
import chai from 'chai'
|
||||
import { round, Pattern, Design, pctBasedOn } from '../src/index.mjs'
|
||||
import { round, Design } from '../src/index.mjs'
|
||||
|
||||
const expect = chai.expect
|
||||
|
||||
describe('Pattern', () => {
|
||||
describe('Pattern.sample()', () => {
|
||||
|
||||
it('Should sample an option', () => {
|
||||
const part = {
|
||||
name: 'test',
|
||||
|
@ -15,7 +14,7 @@ describe('Pattern', () => {
|
|||
},
|
||||
draft: ({ Point, paths, Path, measurements, options, part }) => {
|
||||
paths.test = new Path()
|
||||
.move(new Point(0,0))
|
||||
.move(new Point(0, 0))
|
||||
.line(new Point(0, measurements.head * options.size))
|
||||
|
||||
return part
|
||||
|
@ -26,8 +25,8 @@ describe('Pattern', () => {
|
|||
measurements: { head: 400 },
|
||||
sample: {
|
||||
type: 'option',
|
||||
option: 'size'
|
||||
}
|
||||
option: 'size',
|
||||
},
|
||||
})
|
||||
pattern.sample()
|
||||
expect(pattern.setStores.length).to.equal(10)
|
||||
|
@ -44,7 +43,7 @@ describe('Pattern', () => {
|
|||
},
|
||||
draft: ({ Point, paths, Path, measurements, options, part }) => {
|
||||
paths.test = new Path()
|
||||
.move(new Point(0,0))
|
||||
.move(new Point(0, 0))
|
||||
.line(new Point(0, measurements.head * options.size))
|
||||
|
||||
return part
|
||||
|
@ -55,8 +54,8 @@ describe('Pattern', () => {
|
|||
measurements: { head: 400 },
|
||||
sample: {
|
||||
type: 'option',
|
||||
option: 'size'
|
||||
}
|
||||
option: 'size',
|
||||
},
|
||||
})
|
||||
pattern.sample()
|
||||
expect(pattern.setStores.length).to.equal(10)
|
||||
|
@ -69,12 +68,12 @@ describe('Pattern', () => {
|
|||
name: 'test',
|
||||
measurements: ['head'],
|
||||
options: {
|
||||
size: { dflt: 5, list: [1, 2, 3, 4, 5 ,6 ,7, 8, 9, 10] },
|
||||
size: { dflt: 5, list: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] },
|
||||
},
|
||||
draft: ({ Point, paths, Path, measurements, options, part }) => {
|
||||
paths.test = new Path()
|
||||
.move(new Point(0,0))
|
||||
.line(new Point(0, measurements.head * options.size/10))
|
||||
.move(new Point(0, 0))
|
||||
.line(new Point(0, (measurements.head * options.size) / 10))
|
||||
|
||||
return part
|
||||
},
|
||||
|
@ -84,8 +83,8 @@ describe('Pattern', () => {
|
|||
measurements: { head: 400 },
|
||||
sample: {
|
||||
type: 'option',
|
||||
option: 'size'
|
||||
}
|
||||
option: 'size',
|
||||
},
|
||||
})
|
||||
pattern.sample()
|
||||
expect(pattern.setStores.length).to.equal(10)
|
||||
|
@ -102,7 +101,7 @@ describe('Pattern', () => {
|
|||
},
|
||||
draft: ({ Point, paths, Path, measurements, options, part }) => {
|
||||
paths.test = new Path()
|
||||
.move(new Point(0,0))
|
||||
.move(new Point(0, 0))
|
||||
.line(new Point(0, measurements.head * options.size))
|
||||
|
||||
return part
|
||||
|
@ -113,8 +112,8 @@ describe('Pattern', () => {
|
|||
measurements: { head: 400 },
|
||||
sample: {
|
||||
type: 'measurement',
|
||||
measurement: 'head'
|
||||
}
|
||||
measurement: 'head',
|
||||
},
|
||||
})
|
||||
pattern.sample()
|
||||
expect(pattern.setStores.length).to.equal(10)
|
||||
|
@ -131,7 +130,7 @@ describe('Pattern', () => {
|
|||
},
|
||||
draft: ({ Point, paths, Path, measurements, options, part }) => {
|
||||
paths.test = new Path()
|
||||
.move(new Point(0,0))
|
||||
.move(new Point(0, 0))
|
||||
.line(new Point(0, measurements.head * options.size))
|
||||
|
||||
return part
|
||||
|
@ -139,15 +138,17 @@ describe('Pattern', () => {
|
|||
}
|
||||
const Pattern = new Design({ parts: [part] })
|
||||
const pattern = new Pattern({
|
||||
measurements: { },
|
||||
measurements: {},
|
||||
sample: {
|
||||
type: 'measurement',
|
||||
measurement: 'head'
|
||||
}
|
||||
measurement: 'head',
|
||||
},
|
||||
})
|
||||
pattern.sample()
|
||||
expect(pattern.store.logs.error.length).to.equal(1)
|
||||
expect(pattern.store.logs.error[0]).to.equal("Cannot sample measurement `head` because it's `undefined`")
|
||||
expect(pattern.store.logs.error[0]).to.equal(
|
||||
"Cannot sample measurement `head` because it's `undefined`"
|
||||
)
|
||||
})
|
||||
|
||||
it('Should sample models', () => {
|
||||
|
@ -159,7 +160,7 @@ describe('Pattern', () => {
|
|||
},
|
||||
draft: ({ Point, paths, Path, measurements, options, part }) => {
|
||||
paths.test = new Path()
|
||||
.move(new Point(0,0))
|
||||
.move(new Point(0, 0))
|
||||
.line(new Point(0, measurements.head * options.size))
|
||||
|
||||
return part
|
||||
|
@ -176,314 +177,13 @@ describe('Pattern', () => {
|
|||
c: { head: 300 },
|
||||
d: { head: 400 },
|
||||
},
|
||||
focus: 'c'
|
||||
}
|
||||
focus: 'c',
|
||||
},
|
||||
})
|
||||
pattern.sample()
|
||||
expect(pattern.setStores.length).to.equal(4)
|
||||
expect(pattern.settings.length).to.equal(4)
|
||||
expect(pattern.parts[3].test.paths.test.ops[1].to.y).to.equal(200)
|
||||
})
|
||||
|
||||
/*
|
||||
it("Should sample a list option", () => {
|
||||
const front = {
|
||||
name: 'front',
|
||||
options: {
|
||||
len: {
|
||||
dflt: 1,
|
||||
list: [1,2,3]
|
||||
}
|
||||
},
|
||||
draft: function(part) {
|
||||
const { Point, points, Path, paths, options } = part.shorthand()
|
||||
points.from = new Point(0, 0);
|
||||
points.to = new Point( 100 * options.len, 0)
|
||||
paths.line = new Path()
|
||||
.move(points.from)
|
||||
.line(points.to)
|
||||
|
||||
return part
|
||||
}
|
||||
}
|
||||
const Test = new freesewing.Design({
|
||||
name: "test",
|
||||
parts: [front],
|
||||
})
|
||||
const pattern = new Test({
|
||||
sample: {
|
||||
type: 'option',
|
||||
option: 'len'
|
||||
}
|
||||
})
|
||||
pattern.sample();
|
||||
expect(pattern.parts.front.paths.line_1.ops[1].to.x).to.equal(100);
|
||||
expect(pattern.parts.front.paths.line_2.ops[1].to.x).to.equal(200);
|
||||
expect(pattern.parts.front.paths.line_3.ops[1].to.x).to.equal(300);
|
||||
});
|
||||
|
||||
it("Should sample a measurement", () => {
|
||||
const Test = new freesewing.Design({
|
||||
name: "test",
|
||||
parts: ['front'],
|
||||
measurements: ['head']
|
||||
})
|
||||
Test.prototype.draftFront = function(part) {
|
||||
const { Point, points, Path, paths, measurements } = part.shorthand()
|
||||
points.from = new Point(0, 0);
|
||||
points.to = new Point( measurements.head, 0)
|
||||
paths.line = new Path()
|
||||
.move(points.from)
|
||||
.line(points.to)
|
||||
|
||||
return part
|
||||
};
|
||||
const pattern = new Test({
|
||||
measurements: {
|
||||
head: 100
|
||||
},
|
||||
sample: {
|
||||
type: 'measurement',
|
||||
measurement: 'head'
|
||||
}
|
||||
})
|
||||
pattern.sample();
|
||||
expect(pattern.is).to.equal('sample')
|
||||
expect(pattern.events.debug[0]).to.equal('Sampling measurement `head`')
|
||||
for (let i=0;i<10;i++) {
|
||||
const j = i + 1
|
||||
expect(pattern.parts.front.paths[`line_${j}`].ops[1].to.x).to.equal(90 + 2*i);
|
||||
}
|
||||
pattern.sampleMeasurement('nope')
|
||||
expect(pattern.events.error.length).to.equal(1)
|
||||
expect(pattern.events.error[0]).to.equal("Cannot sample measurement `nope` because it's `undefined`")
|
||||
});
|
||||
|
||||
it("Should sample models", () => {
|
||||
const Test = new freesewing.Design({
|
||||
name: "test",
|
||||
parts: ['front'],
|
||||
measurements: ['head']
|
||||
})
|
||||
Test.prototype.draftFront = function(part) {
|
||||
const { Point, points, Path, paths, measurements } = part.shorthand()
|
||||
points.from = new Point(0, 0);
|
||||
points.to = new Point( measurements.head, 0)
|
||||
paths.line = new Path()
|
||||
.move(points.from)
|
||||
.line(points.to)
|
||||
|
||||
return part
|
||||
};
|
||||
let pattern = new Test({
|
||||
sample: {
|
||||
type: 'models',
|
||||
models : {
|
||||
a: { head: 100 },
|
||||
b: { head: 50 },
|
||||
}
|
||||
}
|
||||
})
|
||||
pattern.sample();
|
||||
expect(pattern.is).to.equal('sample')
|
||||
expect(pattern.events.debug[0]).to.equal('Sampling models')
|
||||
expect(pattern.parts.front.paths[`line_0`].ops[1].to.x).to.equal(100);
|
||||
expect(pattern.parts.front.paths[`line_1`].ops[1].to.x).to.equal(50);
|
||||
pattern = new Test({
|
||||
sample: {
|
||||
type: 'models',
|
||||
models : {
|
||||
a: { head: 100 },
|
||||
b: { head: 50 },
|
||||
},
|
||||
focus: 'b'
|
||||
}
|
||||
})
|
||||
pattern.sample();
|
||||
expect(pattern.is).to.equal('sample')
|
||||
expect(pattern.parts.front.paths[`line_-1`].ops[1].to.x).to.equal(50);
|
||||
expect(pattern.parts.front.paths[`line_0`].ops[1].to.x).to.equal(100);
|
||||
});
|
||||
|
||||
|
||||
it('Should return all render props', () => {
|
||||
const front = {
|
||||
name: 'front',
|
||||
draft: function (part) {
|
||||
return part
|
||||
},
|
||||
}
|
||||
const Test = new Design({
|
||||
name: 'test',
|
||||
parts: [front],
|
||||
})
|
||||
const pattern = new Test()
|
||||
pattern.draft()
|
||||
const rp = pattern.getRenderProps()
|
||||
expect(rp.svg.body).to.equal('')
|
||||
expect(rp.width).to.equal(4)
|
||||
expect(rp.height).to.equal(4)
|
||||
expect(rp.parts.front.height).to.equal(4)
|
||||
})
|
||||
|
||||
it('Should not pack a pattern with errors', () => {
|
||||
const pattern = new Pattern()
|
||||
pattern.events.error.push('error')
|
||||
pattern.pack()
|
||||
expect(pattern.events.warning.length).to.equal(1)
|
||||
expect(pattern.events.warning[0]).to.equal(
|
||||
'One or more errors occured. Not packing pattern parts'
|
||||
)
|
||||
})
|
||||
|
||||
it("Should generate an auto layout if there is no set layout", () => {
|
||||
const Test = new freesewing.Design({
|
||||
name: "test",
|
||||
parts: [
|
||||
{
|
||||
name: 'front',
|
||||
draft: function(part) {
|
||||
const {Path, paths, Point} = part.shorthand()
|
||||
paths.seam = new Path().move(new Point(0,0))
|
||||
.line(new Point(5,5))
|
||||
return part
|
||||
}
|
||||
}
|
||||
]
|
||||
})
|
||||
const pattern = new Test()
|
||||
pattern.parts.front = new pattern.Part('front')
|
||||
pattern.draftFront(pattern.parts.front);
|
||||
pattern.pack()
|
||||
expect(pattern.autoLayout.parts.front).to.exist
|
||||
expect(pattern.autoLayout.parts.front.move.y).to.equal(2)
|
||||
expect(pattern.autoLayout.parts.front.move.x).to.equal(2)
|
||||
})
|
||||
|
||||
it("Should handle custom layouts", () => {
|
||||
const Test = new Design({ name: "test", parts: ['front'] })
|
||||
Test.prototype.draftFront = function(part) { return part }
|
||||
const pattern = new Test({
|
||||
layout: {
|
||||
width: 400,
|
||||
height: 200,
|
||||
parts: { front: { move: { x: 14, y: -202 } } }
|
||||
}
|
||||
})
|
||||
pattern.pack()
|
||||
expect(pattern.width).to.equal(400)
|
||||
expect(pattern.height).to.equal(200)
|
||||
});
|
||||
|
||||
it("Should handle a simple snapped option", () => {
|
||||
const Test = new Design({
|
||||
name: "test",
|
||||
parts: ['front'],
|
||||
measurements: [ 'head' ],
|
||||
options: {
|
||||
len: { pct: 50, min: 22, max: 78, snap: 10, ...pctBasedOn('head') }
|
||||
}
|
||||
})
|
||||
Test.prototype.draftFront = function(part) {
|
||||
const { Point, points, Path, paths, absoluteOptions } = part.shorthand()
|
||||
points.from = new Point(0, 0);
|
||||
points.to = new Point( 2 * absoluteOptions.len, 0)
|
||||
paths.line = new Path()
|
||||
.move(points.from)
|
||||
.line(points.to)
|
||||
|
||||
return part
|
||||
};
|
||||
let pattern = new Test({
|
||||
sample: {
|
||||
type: 'option',
|
||||
option: 'len'
|
||||
},
|
||||
measurements: {
|
||||
head: 43.23
|
||||
}
|
||||
})
|
||||
pattern.sample();
|
||||
expect(pattern.is).to.equal('sample')
|
||||
expect(pattern.events.debug[0]).to.equal('Sampling option `len`')
|
||||
expect(pattern.parts.front.paths.line_1.ops[1].to.x).to.equal(20);
|
||||
expect(pattern.parts.front.paths.line_2.ops[1].to.x).to.equal(40);
|
||||
expect(pattern.parts.front.paths.line_3.ops[1].to.x).to.equal(40);
|
||||
expect(pattern.parts.front.paths.line_4.ops[1].to.x).to.equal(40);
|
||||
expect(pattern.parts.front.paths.line_5.ops[1].to.x).to.equal(60);
|
||||
expect(pattern.parts.front.paths.line_6.ops[1].to.x).to.equal(60);
|
||||
expect(pattern.parts.front.paths.line_7.ops[1].to.x).to.equal(60);
|
||||
expect(pattern.parts.front.paths.line_8.ops[1].to.x).to.equal(60);
|
||||
expect(pattern.parts.front.paths.line_9.ops[1].to.x).to.equal(80);
|
||||
expect(pattern.parts.front.paths.line_10.ops[1].to.x).to.equal(80);
|
||||
});
|
||||
|
||||
it("Should handle a list snapped option", () => {
|
||||
const Test = new Design({
|
||||
name: "test",
|
||||
parts: [
|
||||
{
|
||||
name: 'front',
|
||||
draft: function(part) {
|
||||
const { Point, points, Path, paths, absoluteOptions } = part.shorthand()
|
||||
points.from = new Point(0, 0);
|
||||
points.to = new Point( absoluteOptions.len, 0)
|
||||
paths.line = new Path()
|
||||
.move(points.from)
|
||||
.line(points.to)
|
||||
|
||||
return part
|
||||
}
|
||||
}
|
||||
],
|
||||
measurements: [ 'head' ],
|
||||
options: {
|
||||
len: { pct: 50, min: 22, max: 78, snap: [10,14,19,28], ...pctBasedOn('head') }
|
||||
}
|
||||
})
|
||||
let pattern = new Test({
|
||||
sample: {
|
||||
type: 'option',
|
||||
option: 'len'
|
||||
},
|
||||
measurements: {
|
||||
head: 43.23
|
||||
}
|
||||
})
|
||||
pattern.sample();
|
||||
expect(pattern.is).to.equal('sample')
|
||||
expect(pattern.events.debug[0]).to.equal('Sampling option `len`')
|
||||
expect(pattern.parts.front.paths.line_1.ops[1].to.x).to.equal(10);
|
||||
expect(pattern.parts.front.paths.line_2.ops[1].to.x).to.equal(14);
|
||||
expect(pattern.parts.front.paths.line_3.ops[1].to.x).to.equal(14);
|
||||
expect(pattern.parts.front.paths.line_4.ops[1].to.x).to.equal(19);
|
||||
expect(pattern.parts.front.paths.line_5.ops[1].to.x).to.equal(19);
|
||||
expect(pattern.parts.front.paths.line_6.ops[1].to.x).to.equal(19);
|
||||
expect(pattern.parts.front.paths.line_7.ops[1].to.x).to.equal(28);
|
||||
expect(pattern.parts.front.paths.line_8.ops[1].to.x).to.equal(28);
|
||||
expect(pattern.parts.front.paths.line_9.ops[1].to.x).to.equal(28);
|
||||
expect(round(pattern.parts.front.paths.line_10.ops[1].to.x)).to.equal(33.72);
|
||||
});
|
||||
|
||||
|
||||
it("Should retrieve the cutList", () => {
|
||||
const Test = new Design({
|
||||
name: "test",
|
||||
parts: [{
|
||||
name: 'front',
|
||||
draft: function(part) {
|
||||
const { addCut } = part.shorthand()
|
||||
addCut(4, 'lining', true)
|
||||
return part
|
||||
}
|
||||
}],
|
||||
})
|
||||
const pattern = new Test()
|
||||
expect(JSON.stringify(pattern.getCutList())).to.equal(JSON.stringify({}))
|
||||
pattern.draft()
|
||||
const list = `{"front":{"grain":90,"materials":{"lining":{"cut":4,"identical":true}}}}`
|
||||
expect(JSON.stringify(pattern.getCutList())).to.equal(list)
|
||||
});
|
||||
*/
|
||||
})
|
||||
})
|
||||
|
|
|
@ -4,7 +4,6 @@ import { Design } from '../src/index.mjs'
|
|||
const expect = chai.expect
|
||||
|
||||
describe('Stacks', () => {
|
||||
|
||||
describe('Pattern.__init()', () => {
|
||||
const partA = {
|
||||
name: 'test.partA',
|
||||
|
@ -177,7 +176,7 @@ describe('Stacks', () => {
|
|||
it('Should get the anchor for the stack', () => {
|
||||
const part = {
|
||||
name: 'test',
|
||||
draft: ({ points, Point, paths, Path, part }) => {
|
||||
draft: ({ points, Point, part }) => {
|
||||
points.anchor = new Point(2, 2)
|
||||
|
||||
return part
|
||||
|
@ -195,7 +194,7 @@ describe('Stacks', () => {
|
|||
it('Should get the gridAnchor for the stack', () => {
|
||||
const part = {
|
||||
name: 'test',
|
||||
draft: ({ points, Point, paths, Path, part }) => {
|
||||
draft: ({ points, Point, part }) => {
|
||||
points.gridAnchor = new Point(3, 3)
|
||||
|
||||
return part
|
||||
|
@ -213,7 +212,7 @@ describe('Stacks', () => {
|
|||
it('Should get the default aAnchor for the stack', () => {
|
||||
const part = {
|
||||
name: 'test',
|
||||
draft: ({ points, Point, paths, Path, part }) => {
|
||||
draft: ({ points, Point, part }) => {
|
||||
points.test = new Point(3, 3)
|
||||
|
||||
return part
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
import chai from 'chai'
|
||||
import chaiString from 'chai-string'
|
||||
import { Svg } from '../src/svg.mjs'
|
||||
import { Design, Pattern, Attributes } from '../src/index.mjs'
|
||||
import { Design, Attributes } from '../src/index.mjs'
|
||||
import { version } from '../data.mjs'
|
||||
import render from './fixtures/render.mjs'
|
||||
|
||||
chai.use(chaiString)
|
||||
const expect = chai.expect
|
||||
|
||||
const getPattern = (settings={}, draft=false) => {
|
||||
const getPattern = (settings = {}, draft = false) => {
|
||||
const part = {
|
||||
name: 'test',
|
||||
draft: draft
|
||||
|
@ -22,17 +22,20 @@ const getPattern = (settings={}, draft=false) => {
|
|||
.attr('id', 'something')
|
||||
.attr('class', 'freesewing')
|
||||
return part
|
||||
},
|
||||
}
|
||||
}
|
||||
const Pattern = new Design({ parts: [ part ] })
|
||||
const Pattern = new Design({ parts: [part] })
|
||||
|
||||
return new Pattern(settings)
|
||||
}
|
||||
|
||||
const trim = svg => svg.split("\n").map(line => line.trim()).join('')
|
||||
const trim = (svg) =>
|
||||
svg
|
||||
.split('\n')
|
||||
.map((line) => line.trim())
|
||||
.join('')
|
||||
|
||||
describe('Svg', () => {
|
||||
|
||||
it('Svg constructor should initialize object', () => {
|
||||
const svg = new Svg()
|
||||
expect(svg.attributes instanceof Attributes).to.equal(true)
|
||||
|
@ -56,7 +59,6 @@ describe('Svg', () => {
|
|||
expect(svg.pattern).to.eql(obj)
|
||||
})
|
||||
|
||||
|
||||
it('Should render a pattern as SVG', () => {
|
||||
const pattern = getPattern()
|
||||
const svg = pattern.draft().render()
|
||||
|
@ -137,7 +139,6 @@ describe('Svg', () => {
|
|||
expect(trim(svg)).to.equalIgnoreSpaces(render.multiTextDflt)
|
||||
})
|
||||
|
||||
|
||||
it('Should render Svg text on path', () => {
|
||||
const pattern = getPattern({}, ({ paths, Path, Point, part }) => {
|
||||
paths.test = new Path()
|
||||
|
@ -157,7 +158,7 @@ describe('Svg', () => {
|
|||
})
|
||||
|
||||
it('Should render Svg text on path, center aligned', () => {
|
||||
const pattern = getPattern({}, ({ paths, Path, Point, part }) => {
|
||||
const pattern = getPattern({}, ({ paths, Path, part }) => {
|
||||
paths.test = new Path()
|
||||
.attr('data-text', 'This is another test')
|
||||
.attr('data-text-class', 'center')
|
||||
|
@ -171,7 +172,7 @@ describe('Svg', () => {
|
|||
})
|
||||
|
||||
it('Should render Svg text on path, right aligned', () => {
|
||||
const pattern = getPattern({}, ({ paths, Path, Point, part }) => {
|
||||
const pattern = getPattern({}, ({ paths, Path, part }) => {
|
||||
paths.test = new Path()
|
||||
.attr('data-text', 'This is another test')
|
||||
.attr('data-text-class', 'right')
|
||||
|
@ -208,8 +209,10 @@ describe('Svg', () => {
|
|||
|
||||
it('Should render a rotated Svg snippet', () => {
|
||||
const pattern = getPattern({}, ({ snippets, Snippet, Point, part }) => {
|
||||
snippets.test = new Snippet('test', new Point(20, 20), 'This is a snippet')
|
||||
.attr( 'data-rotate', 90)
|
||||
snippets.test = new Snippet('test', new Point(20, 20), 'This is a snippet').attr(
|
||||
'data-rotate',
|
||||
90
|
||||
)
|
||||
|
||||
return part
|
||||
})
|
||||
|
@ -227,8 +230,10 @@ describe('Svg', () => {
|
|||
|
||||
it('Should scale an Svg snippet', () => {
|
||||
const pattern = getPattern({}, ({ snippets, Snippet, Point, part }) => {
|
||||
snippets.test = new Snippet('test', new Point(20, 20), 'This is a snippet')
|
||||
.attr( 'data-scale', 2)
|
||||
snippets.test = new Snippet('test', new Point(20, 20), 'This is a snippet').attr(
|
||||
'data-scale',
|
||||
2
|
||||
)
|
||||
|
||||
return part
|
||||
})
|
||||
|
@ -274,5 +279,4 @@ describe('Svg', () => {
|
|||
svg.tabs = 2
|
||||
expect(svg.__tab()).to.equal(' ')
|
||||
})
|
||||
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue