Skip to content

Commit

Permalink
Added test, updated docs and more
Browse files Browse the repository at this point in the history
Reverted .babelrc changes
Added disabled as false to test snapshots
Added simple test for the new disabled prop - we could probably add more tests around it, such as confirming that it closes the popup when disabled is changed to true
Added disabled to componentApi.md
  • Loading branch information
raRaRa committed Oct 20, 2018
1 parent a1f665d commit df93c99
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 3 deletions.
4 changes: 2 additions & 2 deletions .babelrc
@@ -1,7 +1,7 @@
{
"presets": [
"@babel/env",
"@babel/react"
"env",
"react"
],
"plugins": [
"transform-class-properties"
Expand Down
21 changes: 21 additions & 0 deletions __test__/__snapshots__/index.test.js.snap
Expand Up @@ -13,6 +13,7 @@ exports[`it should close on click outside popup (closeOnDocumentClick = true ) 1
closeOnEscape={true}
contentStyle={Object {}}
defaultOpen={false}
disabled={false}
keepTooltipInside={false}
lockScroll={false}
modal={false}
Expand Down Expand Up @@ -116,6 +117,7 @@ exports[`it should close on click outside popup (closeOnDocumentClick = true ) 2
closeOnEscape={true}
contentStyle={Object {}}
defaultOpen={false}
disabled={false}
keepTooltipInside={false}
lockScroll={false}
modal={false}
Expand Down Expand Up @@ -159,6 +161,7 @@ exports[`it should render correctly 1`] = `
closeOnEscape={true}
contentStyle={Object {}}
defaultOpen={false}
disabled={false}
keepTooltipInside={false}
lockScroll={false}
modal={false}
Expand Down Expand Up @@ -192,6 +195,7 @@ exports[`it should render correctly on click and will update the the popup conte
closeOnEscape={true}
contentStyle={Object {}}
defaultOpen={false}
disabled={false}
keepTooltipInside={false}
lockScroll={false}
modal={false}
Expand Down Expand Up @@ -300,6 +304,7 @@ exports[`it should render correctly on click and will update the the popup conte
closeOnEscape={true}
contentStyle={Object {}}
defaultOpen={false}
disabled={false}
keepTooltipInside={false}
lockScroll={false}
modal={false}
Expand Down Expand Up @@ -348,6 +353,7 @@ exports[`it should render correctly on click and will update the trigger text
closeOnEscape={true}
contentStyle={Object {}}
defaultOpen={false}
disabled={false}
keepTooltipInside={false}
lockScroll={false}
modal={false}
Expand Down Expand Up @@ -449,6 +455,7 @@ exports[`it should render correctly on click and will update the trigger text
closeOnEscape={true}
contentStyle={Object {}}
defaultOpen={false}
disabled={false}
keepTooltipInside={false}
lockScroll={false}
modal={false}
Expand Down Expand Up @@ -497,6 +504,7 @@ exports[`it should rendered in the bottom center position 1`] = `
closeOnEscape={true}
contentStyle={Object {}}
defaultOpen={false}
disabled={false}
keepTooltipInside={false}
lockScroll={false}
modal={false}
Expand Down Expand Up @@ -600,6 +608,7 @@ exports[`it should rendered in the bottom left position 1`] = `
closeOnEscape={true}
contentStyle={Object {}}
defaultOpen={false}
disabled={false}
keepTooltipInside={false}
lockScroll={false}
modal={false}
Expand Down Expand Up @@ -703,6 +712,7 @@ exports[`it should rendered in the bottom right position 1`] = `
closeOnEscape={true}
contentStyle={Object {}}
defaultOpen={false}
disabled={false}
keepTooltipInside={false}
lockScroll={false}
modal={false}
Expand Down Expand Up @@ -806,6 +816,7 @@ exports[`it should rendered in the left bottom position 1`] = `
closeOnEscape={true}
contentStyle={Object {}}
defaultOpen={false}
disabled={false}
keepTooltipInside={false}
lockScroll={false}
modal={false}
Expand Down Expand Up @@ -909,6 +920,7 @@ exports[`it should rendered in the left center position 1`] = `
closeOnEscape={true}
contentStyle={Object {}}
defaultOpen={false}
disabled={false}
keepTooltipInside={false}
lockScroll={false}
modal={false}
Expand Down Expand Up @@ -1012,6 +1024,7 @@ exports[`it should rendered in the left top position 1`] = `
closeOnEscape={true}
contentStyle={Object {}}
defaultOpen={false}
disabled={false}
keepTooltipInside={false}
lockScroll={false}
modal={false}
Expand Down Expand Up @@ -1115,6 +1128,7 @@ exports[`it should rendered in the right bottom position 1`] = `
closeOnEscape={true}
contentStyle={Object {}}
defaultOpen={false}
disabled={false}
keepTooltipInside={false}
lockScroll={false}
modal={false}
Expand Down Expand Up @@ -1218,6 +1232,7 @@ exports[`it should rendered in the right center position 1`] = `
closeOnEscape={true}
contentStyle={Object {}}
defaultOpen={false}
disabled={false}
keepTooltipInside={false}
lockScroll={false}
modal={false}
Expand Down Expand Up @@ -1321,6 +1336,7 @@ exports[`it should rendered in the right top position 1`] = `
closeOnEscape={true}
contentStyle={Object {}}
defaultOpen={false}
disabled={false}
keepTooltipInside={false}
lockScroll={false}
modal={false}
Expand Down Expand Up @@ -1424,6 +1440,7 @@ exports[`it should rendered in the top center position 1`] = `
closeOnEscape={true}
contentStyle={Object {}}
defaultOpen={false}
disabled={false}
keepTooltipInside={false}
lockScroll={false}
modal={false}
Expand Down Expand Up @@ -1527,6 +1544,7 @@ exports[`it should rendered in the top left position 1`] = `
closeOnEscape={true}
contentStyle={Object {}}
defaultOpen={false}
disabled={false}
keepTooltipInside={false}
lockScroll={false}
modal={false}
Expand Down Expand Up @@ -1630,6 +1648,7 @@ exports[`it should rendered in the top right position 1`] = `
closeOnEscape={true}
contentStyle={Object {}}
defaultOpen={false}
disabled={false}
keepTooltipInside={false}
lockScroll={false}
modal={false}
Expand Down Expand Up @@ -1732,6 +1751,7 @@ exports[`it shouldn't close on click outside popup 1`] = `
closeOnEscape={true}
contentStyle={Object {}}
defaultOpen={false}
disabled={false}
keepTooltipInside={false}
lockScroll={false}
modal={false}
Expand Down Expand Up @@ -1834,6 +1854,7 @@ exports[`it shouldn't close on click outside popup 2`] = `
closeOnEscape={true}
contentStyle={Object {}}
defaultOpen={false}
disabled={false}
keepTooltipInside={false}
lockScroll={false}
modal={false}
Expand Down
8 changes: 7 additions & 1 deletion __test__/index.test.js
Expand Up @@ -39,8 +39,14 @@ test("it should render correctly on click ", () => {
expect(getByText("popup content")).toBeDefined();
});

test("it should not render when disabled", () => {
const { getByText, queryByText } = render(<PopupTest disabled />);
fireEvent.click(getByText("Trigger"));
expect(queryByText("popup content")).toBeNull();
});

test("it should render correctly on click (on = 'click') ", () => {
const { getByText } = render(<PopupTest on="click"/>);
const { getByText } = render(<PopupTest on="click" />);
fireEvent.click(getByText("Trigger"));
expect(getByText("popup content")).toBeDefined();
});
Expand Down
1 change: 1 addition & 0 deletions docs/src/markdown/componentApi.md
Expand Up @@ -21,6 +21,7 @@ The reactjs-popup API is inspired by semantic popup docs
| offsetY | 0 | number | OffsetY in pixels to be applied to the Popup. |
| arrow | true | {bool} | Arrow element |
| modal | false | {bool} | A modal component when modal ={true} |
| disabled | false | {bool} | Disable the popup from showing up and close it if it's open |
| lockScroll | false | {bool} | Disable body scroll when modal is open ( work only with modal) |
| closeOnDocumentClick | true | {bool} | close popup when the overlay clicked |
| closeOnEscape | true | {bool} | close popup when Escape clicked |
Expand Down

0 comments on commit df93c99

Please sign in to comment.