-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Flter map features by deployment and platform
- Loading branch information
1 parent
b709501
commit ad52cf2
Showing
7 changed files
with
244 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import React from "react" | ||
import renderer from "react-test-renderer" | ||
import { act } from "react-dom/test-utils" | ||
|
||
import { MapLegend } from "../map" | ||
import { LineIcon, CircleIcon } from "../../../icons" | ||
|
||
describe("MapLegend", () => { | ||
it("render options", () => { | ||
const fn = jest.fn() | ||
const element = renderer.create( | ||
<MapLegend | ||
platforms={[ | ||
{ name: "Falcon", type: "Jet" }, | ||
{ name: "Campaign FS", type: "static" }, | ||
]} | ||
selectedPlatform={""} | ||
setSelectedPlatform={fn} | ||
/> | ||
) | ||
const instance = element.root | ||
expect(instance.findAllByType("button").length).toBe(2) | ||
const b1 = instance.findAllByType("button")[0] | ||
expect( | ||
instance.findAllByType("button").every(i => !i.props.selected) | ||
).toBeTruthy() | ||
act(() => b1.props.onClick()) | ||
expect(fn).toHaveBeenCalledTimes(1) | ||
expect(instance.findByType(LineIcon).props.size).toBe("text") | ||
expect(instance.findByType(CircleIcon).props.size).toBe("extra-tiny") | ||
}) | ||
it("render option with one selected", () => { | ||
const fn = jest.fn() | ||
const element = renderer.create( | ||
<MapLegend | ||
platforms={[ | ||
{ name: "Falcon", type: "Jet" }, | ||
{ name: "Campaign FS", type: "static" }, | ||
]} | ||
selectedPlatform={"Falcon"} | ||
setSelectedPlatform={fn} | ||
/> | ||
) | ||
const instance = element.root | ||
expect(instance.findAllByType("button").length).toBe(2) | ||
const [b1, b2] = instance.findAllByType("button") | ||
expect(b1.children[0].props.selected).toBeTruthy() | ||
expect(b2.children[0].props.selected).toBeFalsy() | ||
act(() => b1.props.onClick()) | ||
expect(fn).toHaveBeenCalledTimes(1) | ||
act(() => b2.props.onClick()) | ||
expect(fn).toHaveBeenCalledTimes(2) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.