diff --git a/src/utils/event.js b/src/utils/event.js index 354aeea..ac9119d 100644 --- a/src/utils/event.js +++ b/src/utils/event.js @@ -7,14 +7,13 @@ export function removeResizeEventListener(cb) { } export function createDispatcher(source) { - function dispatch(event, data) { + return function (event, data) { source.dispatchEvent( new CustomEvent(event, { detail: data, }) ) } - return dispatch } export function getIsTouchable() { diff --git a/src/utils/math.test.js b/src/utils/math.test.js new file mode 100644 index 0000000..1307b7c --- /dev/null +++ b/src/utils/math.test.js @@ -0,0 +1,19 @@ +import { + getDistance, +} from './math.js' + +describe('getDistance', () => { + it('returns correct distance between 2 points laying in one horizontal line', () => { + const p1 = { x: 0, y: 0 } + const p2 = { x: 5, y: 0 } + + expect(getDistance(p1, p2)).toBe(5) + }) + + it('returns correct distance between 2 points', () => { + const p1 = { x: 1, y: 1 } + const p2 = { x: 5, y: 4 } + + expect(getDistance(p1, p2)).toBe(5) + }) +})