functional sketch working (#26)

* functional sketch working

With old sketch block still there

* get all version of lines working with add line and update line

* remove old ui state types

* some clean up

* rename some things

* add todo for multi cursor

* shorten useStore repitition

* small type improvement

* big overhaul to group sketch function and they ast modifying helpers together

* unneeded tweak

* ruthlessly rip out sketch logic

* clean up path keyword

* getting sketch on face working again with all the new sketch line types

* add a bunch of tests and re-arrage file structure
This commit is contained in:
Kurt Hutten
2023-02-12 10:56:45 +11:00
committed by GitHub
parent 3404529743
commit 594d55576a
28 changed files with 2592 additions and 1475 deletions

View File

@ -1,8 +1,8 @@
import { isOverlapping } from './utils'
import { isOverlap, roundOff } from './utils'
import { Range } from '../useStore'
describe('testing isOverlapping', () => {
testBothOrders([0, 5], [3, 10])
testBothOrders([0, 3], [3, 10])
testBothOrders([0, 5], [3, 4])
testBothOrders([0, 5], [5, 10])
testBothOrders([0, 5], [6, 10], false)
@ -13,7 +13,22 @@ describe('testing isOverlapping', () => {
function testBothOrders(a: Range, b: Range, result = true) {
it(`test is overlapping ${a} ${b}`, () => {
expect(isOverlapping(a, b)).toBe(result)
expect(isOverlapping(b, a)).toBe(result)
expect(isOverlap(a, b)).toBe(result)
expect(isOverlap(b, a)).toBe(result)
})
}
describe('testing roundOff', () => {
it('defaults to 2 decimal places', () => {
expect(roundOff(1.23456789)).toBe(1.23)
})
it('rounds off to 3 decimal places', () => {
expect(roundOff(1.23456789, 3)).toBe(1.235)
})
it('works with whole numbers', () => {
expect(roundOff(1.23456789, 0)).toBe(1)
})
it('rounds up ok', () => {
expect(roundOff(1.273456789, 1)).toBe(1.3)
})
})