Skip to content

Commit

Permalink
tests
Browse files Browse the repository at this point in the history
  • Loading branch information
roryaronson committed Feb 5, 2025
1 parent 07056c0 commit 2c7a5cc
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 1 deletion.
10 changes: 10 additions & 0 deletions frontend/three_d_garden/__tests__/config_overlays_test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,16 @@ describe("<PublicOverlay />", () => {
text: "",
});
});

it("sets buy button url and text", () => {
const p = fakeProps();
p.config.sizePreset = "Genesis XL";
p.config.kitVersion = "v1.8";
const wrapper = mount(<PublicOverlay {...p} />);
const buyButton = wrapper.find(".buy-button").first();
expect(buyButton.props().href).toContain("genesis-xl-v1-8");
expect(buyButton.text()).toContain("GenesisXLv1.8");
});
});

describe("<PrivateOverlay />", () => {
Expand Down
9 changes: 9 additions & 0 deletions frontend/three_d_garden/__tests__/garden_test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -143,4 +143,13 @@ describe("<GardenModel />", () => {
});
expect(console.log).toHaveBeenCalledWith(["1", "2"]);
});

it("renders different ground", () => {
const p = fakeProps();
p.config.scene = "Greenhouse";
const { container } = render(<GardenModel {...p} />);
expect(container.innerHTML).toContain("ground Greenhouse");
expect(container.innerHTML).not.toContain("ground Lab");
expect(container.innerHTML).not.toContain("ground Outdoor");
});
});
29 changes: 29 additions & 0 deletions frontend/three_d_garden/__tests__/greenhouse_test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import React from "react";
import { mount } from "enzyme";
import { Greenhouse, GreenhouseProps } from "../greenhouse";
import { INITIAL } from "../config";
import { clone } from "lodash";

describe("<Greenhouse />", () => {
const fakeProps = (): GreenhouseProps => ({
config: clone(INITIAL),
activeFocus: "",
});

it("renders", () => {
const p = fakeProps();
p.config.people = false;
p.activeFocus = "";
const wrapper = mount(<Greenhouse {...p} />);
expect(wrapper.html()).toContain("greenhouse-environment");
expect(wrapper.find({ name: "people" }).first().props().visible).toBeFalsy();
});

it("renders with people", () => {
const p = fakeProps();
p.config.people = true;
p.activeFocus = "";
const wrapper = mount(<Greenhouse {...p} />);
expect(wrapper.find({ name: "people" }).first().props().visible).toBeTruthy();
});
});
2 changes: 1 addition & 1 deletion frontend/three_d_garden/garden.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export const GardenModel = (props: GardenModelProps) => {
brickTexture.repeat.set(30, 30);

const Ground = ({ children }: { children: React.ReactElement }) =>
<Circle name={"ground"}
<Circle name={`ground ${config.scene}`}
visible={config.ground}
receiveShadow={true}
args={[30000, 16]}
Expand Down

0 comments on commit 2c7a5cc

Please sign in to comment.