Skip to content

Commit

Permalink
add unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
fhiroki committed Jun 27, 2023
1 parent 3c6bc86 commit 8d120db
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ const getProps = (elementProps: Partial<MultiSelectProto> = {}): Props => ({
label: "Label",
default: [0],
options: ["a", "b", "c"],
placeholder: "Choose an option",
placeholderNoResults: "No results",
placeholder: "Please select",
placeholderNoResults: "No results found",
...elementProps,
}),
width: 0,
Expand Down Expand Up @@ -116,9 +116,7 @@ describe("Multiselect widget", () => {
it("renders when it's not empty", () => {
const props = getProps()
const wrapper = mount(<Multiselect {...props} />)
expect(wrapper.find(UISelect).prop("placeholder")).toBe(
"Choose an option"
)
expect(wrapper.find(UISelect).prop("placeholder")).toBe("Please select")
})

it("renders with empty options", () => {
Expand Down Expand Up @@ -303,7 +301,7 @@ describe("Multiselect widget", () => {

expect(wrapper.find(UISelect).props()).toHaveProperty(
"noResultsMsg",
"No results"
"No results found"
)
})

Expand Down
15 changes: 15 additions & 0 deletions lib/tests/streamlit/elements/multiselect_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@ def test_defaults(self, defaults, expected):
self.assertEqual(c.label, "the label")
self.assertListEqual(c.default[:], expected)
self.assertEqual(c.options, ["Coffee", "Tea", "Water"])
self.assertEqual(c.placeholder, "Choose an option")
self.assertEqual(c.placeholder_no_results, "No results")

@parameterized.expand(
[
Expand Down Expand Up @@ -365,3 +367,16 @@ def test_get_over_max_options_message(
_get_over_max_options_message(current_selections, max_selections),
expected_msg,
)

def test_placeholder(self):
"""Test that it can be called with placeholder and placeholder_no_results params."""
st.multiselect(
"the label",
["Coffee", "Tea", "Water"],
placeholder="Select your beverage",
placeholder_no_results="There is no drink you want.",
)

c = self.get_delta_from_queue().new_element.multiselect
self.assertEqual(c.placeholder, "Select your beverage")
self.assertEqual(c.placeholder_no_results, "There is no drink you want.")

0 comments on commit 8d120db

Please sign in to comment.