Compare commits

...

1 Commits

Author SHA1 Message Date
5135badef7 fix: improve drag-number regex 2025-05-16 19:07:50 -07:00
2 changed files with 25 additions and 1 deletions

View File

@ -187,6 +187,12 @@ describe('testing simulateOnMouseDragMatch', () => {
expect(actual).toStrictEqual(expected) expect(actual).toStrictEqual(expected)
}) })
it('works with .5', () => {
const actual = simulateOnMouseDragMatch('.5')
const expected = ['.5']
expect(actual).toStrictEqual(expected)
})
it('works with 1.0', () => { it('works with 1.0', () => {
const actual = simulateOnMouseDragMatch('1.0') const actual = simulateOnMouseDragMatch('1.0')
const expected = ['1.0'] const expected = ['1.0']
@ -223,6 +229,12 @@ describe('testing simulateOnMouseDragMatch', () => {
expect(actual).toStrictEqual(expected) expect(actual).toStrictEqual(expected)
}) })
it('works with 1.50', () => {
const actual = simulateOnMouseDragMatch('1.50')
const expected = ['1.50']
expect(actual).toStrictEqual(expected)
})
it('works with 1', () => { it('works with 1', () => {
const actual = simulateOnMouseDragMatch('1') const actual = simulateOnMouseDragMatch('1')
const expected = ['1'] const expected = ['1']
@ -291,6 +303,18 @@ describe('testing simulateOnMouseDragMatch', () => {
expect(actual).toStrictEqual(expected) expect(actual).toStrictEqual(expected)
}) })
it('works with -.5', () => {
const actual = simulateOnMouseDragMatch('-.5')
const expected = ['-.5']
expect(actual).toStrictEqual(expected)
})
it('works with -0.50', () => {
const actual = simulateOnMouseDragMatch('-0.50')
const expected = ['-0.50']
expect(actual).toStrictEqual(expected)
})
it('works with -.0', () => { it('works with -.0', () => {
const actual = simulateOnMouseDragMatch('-.0') const actual = simulateOnMouseDragMatch('-.0')
const expected = ['-.0'] const expected = ['-.0']

View File

@ -307,7 +307,7 @@ export function getActorNextEvents(snapshot: AnyMachineSnapshot) {
return [...new Set([...snapshot._nodes.flatMap((sn) => sn.ownEvents)])] return [...new Set([...snapshot._nodes.flatMap((sn) => sn.ownEvents)])]
} }
export const onMouseDragRegex = /-?\.?\b\d+\.?\d*\b/g export const onMouseDragRegex = /-?(?:\d+(?:\.\d+)?|\.\d+)/g
export function simulateOnMouseDragMatch(text: string) { export function simulateOnMouseDragMatch(text: string) {
return text.match(onMouseDragRegex) return text.match(onMouseDragRegex)