#49 : Add unit tests
This commit is contained in:
@@ -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
19
src/utils/math.test.js
Normal 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)
|
||||||
|
})
|
||||||
|
})
|
||||||
Reference in New Issue
Block a user