Farmbot-Web-App/frontend/farm_designer/map/drawn_point/__tests__/drawn_point_test.tsx

38 lines
1.1 KiB
TypeScript
Raw Normal View History

2018-02-20 17:13:14 -07:00
import * as React from "react";
import { DrawnPoint, DrawnPointProps } from "../drawn_point";
2018-10-25 18:02:54 -06:00
import {
2020-02-28 09:35:32 -07:00
fakeMapTransformProps,
2018-10-25 18:02:54 -06:00
} from "../../../../__test_support__/map_transform_props";
2019-06-05 14:48:18 -06:00
import { svgMount } from "../../../../__test_support__/svg_mount";
2018-02-20 17:13:14 -07:00
describe("<DrawnPoint/>", () => {
2019-06-05 14:48:18 -06:00
const fakeProps = (): DrawnPointProps => ({
mapTransformProps: fakeMapTransformProps(),
data: {
cx: 10,
cy: 20,
r: 30,
}
});
2018-02-20 17:13:14 -07:00
it("renders point", () => {
2019-06-05 14:48:18 -06:00
const wrapper = svgMount(<DrawnPoint {...fakeProps()} />);
expect(wrapper.find("g").props().stroke).toEqual("green");
2018-02-20 17:13:14 -07:00
expect(wrapper.find("circle").first().props()).toEqual({
id: "point-radius", strokeDasharray: "4 5",
cx: 10, cy: 20, r: 30,
});
expect(wrapper.find("circle").last().props()).toEqual({
id: "point-center",
cx: 10, cy: 20, r: 2,
});
});
it("renders point with chosen color", () => {
const p = fakeProps();
p.data = { cx: 0, cy: 0, r: 1, color: "red" };
const wrapper = svgMount(<DrawnPoint {...p} />);
expect(wrapper.find("g").props().stroke).toEqual("red");
});
2018-02-20 17:13:14 -07:00
});