BulkActions.spec.js
46 lines
| 1 | import { render, screen } from "@testing-library/react"; |
| 2 | import BulkActions from "../BulkActions"; |
| 3 | |
| 4 | describe("BulkActions selectedLabel", () => { |
| 5 | const noop = () => {}; |
| 6 | |
| 7 | it("falls back to the default 'media selected' label when selectedLabel is not provided", () => { |
| 8 | render( |
| 9 | <BulkActions |
| 10 | selected={[1, 2, 3]} |
| 11 | onDelete={noop} |
| 12 | onStatusChange={noop} |
| 13 | onCancel={noop} |
| 14 | /> |
| 15 | ); |
| 16 | expect(screen.getByText(/3 media selected/)).toBeInTheDocument(); |
| 17 | }); |
| 18 | |
| 19 | it("renders the consumer-provided selectedLabel verbatim", () => { |
| 20 | render( |
| 21 | <BulkActions |
| 22 | selected={[1, 2, 3]} |
| 23 | selectedLabel="3 email submissions selected" |
| 24 | onDelete={noop} |
| 25 | onStatusChange={noop} |
| 26 | onCancel={noop} |
| 27 | /> |
| 28 | ); |
| 29 | expect(screen.getByText("3 email submissions selected")).toBeInTheDocument(); |
| 30 | expect(screen.queryByText(/media selected/)).not.toBeInTheDocument(); |
| 31 | }); |
| 32 | |
| 33 | it("falls back to the default label when selectedLabel is an empty string", () => { |
| 34 | render( |
| 35 | <BulkActions |
| 36 | selected={[1, 2]} |
| 37 | selectedLabel="" |
| 38 | onDelete={noop} |
| 39 | onStatusChange={noop} |
| 40 | onCancel={noop} |
| 41 | /> |
| 42 | ); |
| 43 | expect(screen.getByText(/2 media selected/)).toBeInTheDocument(); |
| 44 | }); |
| 45 | }); |
| 46 |