Skip to content

Commit 2c7a5cc

Browse files
committed
tests
1 parent 07056c0 commit 2c7a5cc

File tree

4 files changed

+49
-1
lines changed

4 files changed

+49
-1
lines changed

frontend/three_d_garden/__tests__/config_overlays_test.tsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,16 @@ describe("<PublicOverlay />", () => {
5353
text: "",
5454
});
5555
});
56+
57+
it("sets buy button url and text", () => {
58+
const p = fakeProps();
59+
p.config.sizePreset = "Genesis XL";
60+
p.config.kitVersion = "v1.8";
61+
const wrapper = mount(<PublicOverlay {...p} />);
62+
const buyButton = wrapper.find(".buy-button").first();
63+
expect(buyButton.props().href).toContain("genesis-xl-v1-8");
64+
expect(buyButton.text()).toContain("GenesisXLv1.8");
65+
});
5666
});
5767

5868
describe("<PrivateOverlay />", () => {

frontend/three_d_garden/__tests__/garden_test.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,4 +143,13 @@ describe("<GardenModel />", () => {
143143
});
144144
expect(console.log).toHaveBeenCalledWith(["1", "2"]);
145145
});
146+
147+
it("renders different ground", () => {
148+
const p = fakeProps();
149+
p.config.scene = "Greenhouse";
150+
const { container } = render(<GardenModel {...p} />);
151+
expect(container.innerHTML).toContain("ground Greenhouse");
152+
expect(container.innerHTML).not.toContain("ground Lab");
153+
expect(container.innerHTML).not.toContain("ground Outdoor");
154+
});
146155
});
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import React from "react";
2+
import { mount } from "enzyme";
3+
import { Greenhouse, GreenhouseProps } from "../greenhouse";
4+
import { INITIAL } from "../config";
5+
import { clone } from "lodash";
6+
7+
describe("<Greenhouse />", () => {
8+
const fakeProps = (): GreenhouseProps => ({
9+
config: clone(INITIAL),
10+
activeFocus: "",
11+
});
12+
13+
it("renders", () => {
14+
const p = fakeProps();
15+
p.config.people = false;
16+
p.activeFocus = "";
17+
const wrapper = mount(<Greenhouse {...p} />);
18+
expect(wrapper.html()).toContain("greenhouse-environment");
19+
expect(wrapper.find({ name: "people" }).first().props().visible).toBeFalsy();
20+
});
21+
22+
it("renders with people", () => {
23+
const p = fakeProps();
24+
p.config.people = true;
25+
p.activeFocus = "";
26+
const wrapper = mount(<Greenhouse {...p} />);
27+
expect(wrapper.find({ name: "people" }).first().props().visible).toBeTruthy();
28+
});
29+
});

frontend/three_d_garden/garden.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ export const GardenModel = (props: GardenModelProps) => {
9393
brickTexture.repeat.set(30, 30);
9494

9595
const Ground = ({ children }: { children: React.ReactElement }) =>
96-
<Circle name={"ground"}
96+
<Circle name={`ground ${config.scene}`}
9797
visible={config.ground}
9898
receiveShadow={true}
9999
args={[30000, 16]}

0 commit comments

Comments
 (0)