#49 : Add unit tests

This commit is contained in:
Vadim
2021-08-08 14:30:12 +03:00
parent 2acca5014b
commit 93405d54d8
2 changed files with 20 additions and 2 deletions

View File

@@ -7,14 +7,13 @@ export function removeResizeEventListener(cb) {
} }
export function createDispatcher(source) { export function createDispatcher(source) {
function dispatch(event, data) { return function (event, data) {
source.dispatchEvent( source.dispatchEvent(
new CustomEvent(event, { new CustomEvent(event, {
detail: data, detail: data,
}) })
) )
} }
return dispatch
} }
export function getIsTouchable() { export function getIsTouchable() {

19
src/utils/math.test.js Normal file
View File

@@ -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)
})
})