Skip to content

Commit

Permalink
add Daf's comments
Browse files Browse the repository at this point in the history
  • Loading branch information
RODO94 committed Sep 17, 2024
1 parent 2670463 commit 9796153
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@ import { setup } from "testUtils";
import { vi } from "vitest";
import { axe } from "vitest-axe";

import { point1, point2, point3 } from "../test/mocks/geojson";
import {
mockFeaturePointObj,
point1,
point2,
point3,
} from "../test/mocks/geojson";
import { props } from "../test/mocks/Trees";
import {
addFeaturesToMap,
Expand Down Expand Up @@ -203,15 +208,18 @@ it("does not trigger handleSubmit when errors exist", async () => {
test.todo("an error displays if the maximum number of items is exceeded");

describe("basic interactions - happy path", () => {
it("adding an item to the map adds a feature tab", async () => {
it.only("adding an item to the map adds a feature tab", async () => {
const { getByTestId } = setup(<MapAndLabel {...props} />);
const map = getByTestId("map-and-label-map");

let map = getByTestId("map-and-label-map");
addFeaturesToMap(map, [point1]);

const firstTabPanel = getByTestId("vertical-tabpanel-0");

expect(firstTabPanel).toBeVisible();

map = getByTestId("map-and-label-map");
expect(map).toHaveAttribute("drawgeojsondata", mockFeaturePointObj);
});

it("a user can input details on a single feature and submit", async () => {
Expand Down Expand Up @@ -345,7 +353,6 @@ describe("copy feature select", () => {
it.todo("should not have any accessibility violations");
// axe checks
});

describe("remove feature button", () => {
it("removes a feature from the form - single feature", async () => {
const { getByTestId, getByRole, user } = setup(<MapAndLabel {...props} />);
Expand Down Expand Up @@ -385,20 +392,19 @@ describe("remove feature button", () => {
expect(tabOne).toBeInTheDocument();
expect(tabOnePanel).toBeInTheDocument();
});

it("removes a feature from the map", async () => {
const { getByTestId, getByRole, user } = setup(<MapAndLabel {...props} />);
const map = getByTestId("map-and-label-map");
let map = getByTestId("map-and-label-map");

addFeaturesToMap(map, [point1]);

const removeButton = getByRole("button", { name: "Remove" });

await user.click(removeButton);

const mapTwo = getByTestId("map-and-label-map");
map = getByTestId("map-and-label-map");

expect(mapTwo).toHaveAttribute(
expect(map).toHaveAttribute(
"drawgeojsondata",
`{"type":"FeatureCollection","features":[]}`
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,5 @@ export const point3: Feature<Point, { label: string }> = {
coordinates: [-3.68689607119201, 57.15310833687542],
},
};

export const mockFeaturePointObj = `{"type":"FeatureCollection","features":[{"type":"Feature","properties":{"label":"1"},"geometry":{"type":"Point","coordinates":[-3.685929607119201,57.15301433687542]}}]}`;

0 comments on commit 9796153

Please sign in to comment.