Add tests for Vec.Average (#3071)
Adds tests for the Vec.Average. [My previous PR](https://github.com/tldraw/tldraw/pull/3065) added a check that prevented returning vectors with NaNs, this adds a test for that. ### Change Type - [ ] `patch` — Bug fix - [ ] `minor` — New feature - [ ] `major` — Breaking change - [ ] `dependencies` — Changes to package dependencies[^1] - [ ] `documentation` — Changes to the documentation only[^2] - [x] `tests` — Changes to any test code only[^2] - [ ] `internal` — Any other changes that don't affect the published package[^2] - [ ] I don't know [^1]: publishes a `patch` release, for devDependencies use `internal` [^2]: will not publish a new version
This commit is contained in:
parent
f033ff8508
commit
a07561e662
1 changed files with 11 additions and 0 deletions
|
@ -375,3 +375,14 @@ describe('Vec.snapToGrid', () => {
|
||||||
expect(Vec.SnapToGrid(new Vec(12, 49), 10)).toMatchObject(new Vec(10, 50))
|
expect(Vec.SnapToGrid(new Vec(12, 49), 10)).toMatchObject(new Vec(10, 50))
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
describe('Vec.Average', () => {
|
||||||
|
it('correctly calculates the average of an array of vectors', () => {
|
||||||
|
const vecs = [new Vec(2, 4), new Vec(8, 16)]
|
||||||
|
expect(Vec.Average(vecs)).toMatchObject(new Vec(5, 10))
|
||||||
|
})
|
||||||
|
|
||||||
|
it('returns a (0,0) vector when passing any empty array', () => {
|
||||||
|
expect(Vec.Average([])).toMatchObject(new Vec(0, 0))
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
Loading…
Reference in a new issue