chore(core): Linting and more tests
This commit is contained in:
parent
b3679ede55
commit
47a7a71b61
8 changed files with 159 additions and 520 deletions
|
@ -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)
|
||||
})
|
||||
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue