-
Notifications
You must be signed in to change notification settings - Fork 4.5k
feat: Collapsible Bottom View #33441
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
c44f52e
feat: Collapsible Bottom View
hetunandu 780411c
add comments
hetunandu c689177
add classnames
hetunandu 51c1340
Merge branch 'refs/heads/release' into feat/collapsible-bottom-view
hetunandu e54befb
fix for JS editor
hetunandu 28fd251
fix selector
hetunandu bcafdd1
use tabs instead
hetunandu 30ecce4
Review comments
hetunandu 49fcdc8
min height
hetunandu 5c1add8
Merge branch 'refs/heads/release' into feat/collapsible-bottom-view
hetunandu 72a8ba7
init test
hetunandu c32cea1
add tests
hetunandu 46b8d48
Merge branch 'refs/heads/release' into feat/collapsible-bottom-view
hetunandu 8f3b96e
Fix classname change
hetunandu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,227 @@ | ||
| import React from "react"; | ||
| import { act, fireEvent, render } from "@testing-library/react"; | ||
| import BottomView from "./BottomView"; | ||
| import { ViewHideBehaviour } from "../Interfaces/View"; | ||
| import { noop } from "lodash"; | ||
| import "@testing-library/jest-dom"; | ||
| import "jest-styled-components"; | ||
|
|
||
| describe("BottomView", () => { | ||
| describe("ViewHideBehaviour.COLLAPSE", () => { | ||
| // HIDDEN = FALSE | ||
| it("it is visible when hidden = false", () => { | ||
| const { getByText } = render( | ||
| <BottomView | ||
| behaviour={ViewHideBehaviour.COLLAPSE} | ||
| height={300} | ||
| hidden={false} | ||
| onHideClick={noop} | ||
| setHeight={noop} | ||
| > | ||
| <div id="bottomview">Hey test</div> | ||
| </BottomView>, | ||
| ); | ||
|
|
||
| expect(getByText("Hey test")).toBeTruthy(); | ||
| }); | ||
| it("it can be toggled when hidden = false", () => { | ||
| const onViewHideToggle = jest.fn(); | ||
| const { getByRole } = render( | ||
| <BottomView | ||
| behaviour={ViewHideBehaviour.COLLAPSE} | ||
| height={300} | ||
| hidden={false} | ||
| onHideClick={onViewHideToggle} | ||
| setHeight={noop} | ||
| > | ||
| <div id="bottomview">Hey test</div> | ||
| </BottomView>, | ||
| ); | ||
|
|
||
| const viewHideToggle = getByRole("button"); | ||
| act(() => { | ||
| fireEvent.click(viewHideToggle); | ||
| }); | ||
| expect(onViewHideToggle).toBeCalled(); | ||
| }); | ||
|
|
||
| it("assert container height when hidden = false", () => { | ||
| const { container } = render( | ||
| <BottomView | ||
| behaviour={ViewHideBehaviour.COLLAPSE} | ||
| height={300} | ||
| hidden={false} | ||
| onHideClick={noop} | ||
| setHeight={noop} | ||
| > | ||
| <div id="bottomview">Hey test</div> | ||
| </BottomView>, | ||
| ); | ||
|
|
||
| expect(container.children[0]).toHaveAttribute("style", "height: 300px;"); | ||
| }); | ||
|
|
||
| // HIDDEN = TRUE | ||
| it("it is visible when hidden = true", () => { | ||
| const { getByText } = render( | ||
| <BottomView | ||
| behaviour={ViewHideBehaviour.COLLAPSE} | ||
| height={300} | ||
| hidden | ||
| onHideClick={noop} | ||
| setHeight={noop} | ||
| > | ||
| <div id="bottomview">Hey test</div> | ||
| </BottomView>, | ||
| ); | ||
|
|
||
| expect(getByText("Hey test")).toBeTruthy(); | ||
| }); | ||
|
|
||
| it("it can be toggled when hidden = true", () => { | ||
| const onViewHideToggle = jest.fn(); | ||
| const { getByRole } = render( | ||
| <BottomView | ||
| behaviour={ViewHideBehaviour.COLLAPSE} | ||
| height={300} | ||
| hidden | ||
| onHideClick={onViewHideToggle} | ||
| setHeight={noop} | ||
| > | ||
| <div id="bottomview">Hey test</div> | ||
| </BottomView>, | ||
| ); | ||
|
|
||
| const viewHideToggle = getByRole("button"); | ||
| act(() => { | ||
| fireEvent.click(viewHideToggle); | ||
| }); | ||
| expect(onViewHideToggle).toBeCalled(); | ||
| }); | ||
|
|
||
| it("assert container height when hidden = true", () => { | ||
| const { container } = render( | ||
| <BottomView | ||
| behaviour={ViewHideBehaviour.COLLAPSE} | ||
| height={300} | ||
| hidden | ||
| onHideClick={noop} | ||
| setHeight={noop} | ||
| > | ||
| <div id="bottomview">Hey test</div> | ||
| </BottomView>, | ||
| ); | ||
|
|
||
| expect(container.children[0]).toHaveAttribute("style", "height: 38px;"); | ||
| }); | ||
| }); | ||
|
|
||
| describe("ViewHideBehaviour.CLOSE", () => { | ||
| // HIDDEN = FALSE | ||
| it("it is visible when hidden = false", () => { | ||
| const { getByText } = render( | ||
| <BottomView | ||
| behaviour={ViewHideBehaviour.CLOSE} | ||
| height={300} | ||
| hidden={false} | ||
| onHideClick={noop} | ||
| setHeight={noop} | ||
| > | ||
| <div id="bottomview">Hey test</div> | ||
| </BottomView>, | ||
| ); | ||
|
|
||
| expect(getByText("Hey test")).toBeTruthy(); | ||
| }); | ||
| it("it can be toggled when hidden = false", () => { | ||
| const onViewHideToggle = jest.fn(); | ||
| const { getByRole } = render( | ||
| <BottomView | ||
| behaviour={ViewHideBehaviour.CLOSE} | ||
| height={300} | ||
| hidden={false} | ||
| onHideClick={onViewHideToggle} | ||
| setHeight={noop} | ||
| > | ||
| <div id="bottomview">Hey test</div> | ||
| </BottomView>, | ||
| ); | ||
|
|
||
| const viewHideToggle = getByRole("button"); | ||
| act(() => { | ||
| fireEvent.click(viewHideToggle); | ||
| }); | ||
| expect(onViewHideToggle).toBeCalled(); | ||
| }); | ||
|
|
||
| it("assert container height when hidden = false", () => { | ||
| const { container } = render( | ||
| <BottomView | ||
| behaviour={ViewHideBehaviour.CLOSE} | ||
| height={300} | ||
| hidden={false} | ||
| onHideClick={noop} | ||
| setHeight={noop} | ||
| > | ||
| <div id="bottomview">Hey test</div> | ||
| </BottomView>, | ||
| ); | ||
|
|
||
| expect(container.children[0]).toHaveAttribute("style", "height: 300px;"); | ||
| }); | ||
|
|
||
| // HIDDEN = TRUE | ||
| it("it is visible when hidden = true", () => { | ||
| const { getByText } = render( | ||
| <BottomView | ||
| behaviour={ViewHideBehaviour.CLOSE} | ||
| height={300} | ||
| hidden | ||
| onHideClick={noop} | ||
| setHeight={noop} | ||
| > | ||
| <div id="bottomview">Hey test</div> | ||
| </BottomView>, | ||
| ); | ||
|
|
||
| expect(getByText("Hey test")).toBeTruthy(); | ||
hetunandu marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| }); | ||
|
|
||
| it("it can be toggled when hidden = true", () => { | ||
| const onViewHideToggle = jest.fn(); | ||
| const { getByRole } = render( | ||
| <BottomView | ||
| behaviour={ViewHideBehaviour.CLOSE} | ||
| height={300} | ||
| hidden | ||
| onHideClick={onViewHideToggle} | ||
| setHeight={noop} | ||
| > | ||
| <div id="bottomview">Hey test</div> | ||
| </BottomView>, | ||
| ); | ||
|
|
||
| const viewHideToggle = getByRole("button"); | ||
| act(() => { | ||
| fireEvent.click(viewHideToggle); | ||
| }); | ||
| expect(onViewHideToggle).toBeCalled(); | ||
| }); | ||
|
|
||
| it("assert container height when hidden = true", () => { | ||
| const { container } = render( | ||
| <BottomView | ||
| behaviour={ViewHideBehaviour.CLOSE} | ||
| height={300} | ||
| hidden | ||
| onHideClick={noop} | ||
| setHeight={noop} | ||
| > | ||
| <div id="bottomview">Hey test</div> | ||
| </BottomView>, | ||
| ); | ||
|
|
||
| expect(container.children[0]).toHaveAttribute("style", "height: 0px;"); | ||
| }); | ||
| }); | ||
| }); | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.