|
@@ -60,6 +60,44 @@ describe("SummaryMap", () => {
|
|
);
|
|
);
|
|
});
|
|
});
|
|
|
|
|
|
|
|
+ it("handles having the round changed", () => {
|
|
|
|
+ const panTo = jest.fn();
|
|
|
|
+ useMap.mockReturnValue({ current: { panTo } });
|
|
|
|
+ useGameConfig.mockReturnValue({ countryLock: "lock" });
|
|
|
|
+ const rendered = shallow(
|
|
|
|
+ <SummaryMap
|
|
|
|
+ players="players"
|
|
|
|
+ coords={{
|
|
|
|
+ 1: { lat: 1, lng: 2 },
|
|
|
|
+ 2: { lat: 3, lng: 4 },
|
|
|
|
+ 3: { lat: 5, lng: 6 },
|
|
|
|
+ }}
|
|
|
|
+ />
|
|
|
|
+ );
|
|
|
|
+ rendered.find("RoundSelect").prop("onSelect")(2);
|
|
|
|
+ expect(panTo).toMatchSnapshot();
|
|
|
|
+ expect(rendered).toMatchSnapshot();
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ it("handles invalid round change", () => {
|
|
|
|
+ const panTo = jest.fn();
|
|
|
|
+ useMap.mockReturnValue({ current: { panTo } });
|
|
|
|
+ useGameConfig.mockReturnValue({ countryLock: "lock" });
|
|
|
|
+ const rendered = shallow(
|
|
|
|
+ <SummaryMap
|
|
|
|
+ players="players"
|
|
|
|
+ coords={{
|
|
|
|
+ 1: { lat: 1, lng: 2 },
|
|
|
|
+ 2: { lat: 3, lng: 4 },
|
|
|
|
+ 3: { lat: 5, lng: 6 },
|
|
|
|
+ }}
|
|
|
|
+ />
|
|
|
|
+ );
|
|
|
|
+ rendered.find("RoundSelect").prop("onSelect")(5);
|
|
|
|
+ expect(panTo).toMatchSnapshot();
|
|
|
|
+ expect(rendered).toMatchSnapshot();
|
|
|
|
+ });
|
|
|
|
+
|
|
describe("RoundSelect", () => {
|
|
describe("RoundSelect", () => {
|
|
it("renders", () => {
|
|
it("renders", () => {
|
|
const onSelect = jest.fn();
|
|
const onSelect = jest.fn();
|
|
@@ -87,7 +125,7 @@ describe("SummaryMap", () => {
|
|
2: { country: "country2" },
|
|
2: { country: "country2" },
|
|
3: { country: "country3" },
|
|
3: { country: "country3" },
|
|
}}
|
|
}}
|
|
- selected
|
|
|
|
|
|
+ selected="2"
|
|
onSelect={onSelect}
|
|
onSelect={onSelect}
|
|
/>
|
|
/>
|
|
);
|
|
);
|
|
@@ -128,6 +166,23 @@ describe("SummaryMap", () => {
|
|
expect(onSelect).toHaveBeenCalledWith("1");
|
|
expect(onSelect).toHaveBeenCalledWith("1");
|
|
});
|
|
});
|
|
|
|
|
|
|
|
+ it("does not call onSelect when other keys pressed", () => {
|
|
|
|
+ const onSelect = jest.fn();
|
|
|
|
+ const rendered = shallow(
|
|
|
|
+ <RoundSelect
|
|
|
|
+ rounds={3}
|
|
|
|
+ coords={{
|
|
|
|
+ 1: { country: "country1" },
|
|
|
|
+ 2: { country: "country2" },
|
|
|
|
+ 3: { country: "country3" },
|
|
|
|
+ }}
|
|
|
|
+ onSelect={onSelect}
|
|
|
|
+ />
|
|
|
|
+ );
|
|
|
|
+ rendered.find("div.tab").first().simulate("keydown", { key: "Escape" });
|
|
|
|
+ expect(onSelect).not.toHaveBeenCalledWith("1");
|
|
|
|
+ });
|
|
|
|
+
|
|
it("calls onSelect with 0 when X clicked", () => {
|
|
it("calls onSelect with 0 when X clicked", () => {
|
|
const onSelect = jest.fn();
|
|
const onSelect = jest.fn();
|
|
const rendered = shallow(
|
|
const rendered = shallow(
|
|
@@ -167,5 +222,25 @@ describe("SummaryMap", () => {
|
|
.simulate("keydown", { key: "Enter" });
|
|
.simulate("keydown", { key: "Enter" });
|
|
expect(onSelect).toHaveBeenCalledWith("0");
|
|
expect(onSelect).toHaveBeenCalledWith("0");
|
|
});
|
|
});
|
|
|
|
+
|
|
|
|
+ it("does not call onSelect with 0 when other keys pressed on X", () => {
|
|
|
|
+ const onSelect = jest.fn();
|
|
|
|
+ const rendered = shallow(
|
|
|
|
+ <RoundSelect
|
|
|
|
+ rounds={3}
|
|
|
|
+ coords={{
|
|
|
|
+ 1: { country: "country1" },
|
|
|
|
+ 2: { country: "country2" },
|
|
|
|
+ 3: { country: "country3" },
|
|
|
|
+ }}
|
|
|
|
+ onSelect={onSelect}
|
|
|
|
+ />
|
|
|
|
+ );
|
|
|
|
+ rendered
|
|
|
|
+ .findWhere(x => x.text() === "X")
|
|
|
|
+ .first()
|
|
|
|
+ .simulate("keydown", { key: "Escape" });
|
|
|
|
+ expect(onSelect).not.toHaveBeenCalledWith("0");
|
|
|
|
+ });
|
|
});
|
|
});
|
|
});
|
|
});
|