Skip to content
Snippets Groups Projects
Commit 64da1e59 authored by Yuriy Maksymets's avatar Yuriy Maksymets
Browse files

Add basic tests

parent c11f93ed
No related branches found
No related tags found
No related merge requests found
import recognizeFromPoints, { Shapes } from "../src/shapes"
describe("shape recognition", () => {
test("should return a shape description object", () => {
const points = [[0, 0]]
const result = recognizeFromPoints(points)
expect(result).not.toBeNull()
})
test("should recognize simple rectangle", () => {
const points = [[0, 0], [10, 0], [10, 10], [0, 10]]
const result = recognizeFromPoints(points)
expect(result.shape).toBe(Shapes.rectangle)
})
test("should recognize rectangle with many points", () => {
const points = [
[0, 0],
[5, 1],
[10, 0],
[10, 6],
[10, 10],
[6, 10],
[0, 10],
]
const result = recognizeFromPoints(points)
expect(result.shape).toBe(Shapes.rectangle)
})
})
function recognizeFromPoints(points) {
return {
shape: Shapes.rectangle,
points,
}
}
export const Shapes = {
rectangle: "rect",
}
export default recognizeFromPoints
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment