-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
14689a5
commit ac935ef
Showing
4 changed files
with
116 additions
and
4 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
3 changes: 3 additions & 0 deletions
3
src/components/dropdown/__test__/__snapshots__/dropdown.test.tsx.snap
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,3 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`components/dropdown should render a dropdown 1`] = `[Function]`; |
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,93 @@ | ||
import { render, screen, fireEvent } from "@testing-library/react"; | ||
import React from "react"; | ||
import Dropdown from "../dropdown"; | ||
|
||
describe("components/dropdown", () => { | ||
it("should render a dropdown", () => { | ||
const { asFragment } = render( | ||
<Dropdown | ||
data={[ | ||
{ | ||
label: "💼 News and Media", | ||
value: "category-1", | ||
}, | ||
{ | ||
label: "🦊 NPM Packages", | ||
value: "category-2", | ||
}, | ||
{ | ||
label: "👛 Case Studies", | ||
value: "category-3", | ||
}, | ||
]} | ||
/>, | ||
); | ||
const primaryButton = screen.getByTestId("folio-dropdown"); | ||
|
||
expect(primaryButton).toHaveClass("folio-dropdown"); | ||
expect(asFragment).toMatchSnapshot(); | ||
}); | ||
|
||
it("dropdown should be closed by defult", () => { | ||
render( | ||
<Dropdown | ||
data={[ | ||
{ | ||
label: "💼 News and Media", | ||
value: "category-1", | ||
}, | ||
{ | ||
label: "🦊 NPM Packages", | ||
value: "category-2", | ||
}, | ||
{ | ||
label: "👛 Case Studies", | ||
value: "category-3", | ||
}, | ||
]} | ||
/>, | ||
); | ||
|
||
const dropdownTitle = screen.getByTestId("folio-dropdown--title"); | ||
|
||
expect(dropdownTitle).toHaveTextContent("Select Category"); | ||
}); | ||
|
||
it("dropdown should be opened when clicked", () => { | ||
render( | ||
<Dropdown | ||
data={[ | ||
{ | ||
label: "💼 News and Media", | ||
value: "category-1", | ||
}, | ||
{ | ||
label: "🦊 NPM Packages", | ||
value: "category-2", | ||
}, | ||
{ | ||
label: "👛 Case Studies", | ||
value: "category-3", | ||
}, | ||
]} | ||
/>, | ||
); | ||
|
||
const dropdownTitle = screen.getByTestId("folio-dropdown--title"); | ||
|
||
fireEvent.click(dropdownTitle); | ||
|
||
expect(dropdownTitle).toHaveTextContent("Select Category"); | ||
|
||
const dropdownItem = screen.getByTestId("folio-dropdown--item-1"); | ||
expect(dropdownItem).toHaveTextContent("💼 News and Media"); | ||
|
||
const dropdownItem2 = screen.getByTestId("folio-dropdown--item-2"); | ||
|
||
expect(dropdownItem2).toHaveTextContent("🦊 NPM Packages"); | ||
|
||
const dropdownItem3 = screen.getByTestId("folio-dropdown--item-3"); | ||
|
||
expect(dropdownItem3).toHaveTextContent("👛 Case Studies"); | ||
}); | ||
}); |
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