All files / components/Utils PageSizeSelector.jsx

100% Statements 4/4
100% Branches 2/2
100% Functions 3/3
100% Lines 4/4

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40                  426x 11x     426x                           2034x                        
import React from "react";
import { Form } from "react-bootstrap";
 
export default function PageSizeSelector({
  value,
  onChange,
  options = [20, 50, 100, 200, 500],
  testid = "page-size-selector",
}) {
  const handleChange = (e) => {
    onChange(parseInt(e.target.value, 10));
  };
 
  return (
    <Form.Group className="d-flex align-items-center gap-2 mt-2">
      <Form.Label htmlFor="pageSize" className="mb-0">
        Page Size
      </Form.Label>
      <Form.Select
        id="pageSize"
        data-testid={testid}
        value={value}
        onChange={handleChange}
        // Stryker disable next-line all : this is for styling, which is unnecessary to test
        style={{ width: "100px" }}
      >
        {options.map((option) => (
          <option
            key={option}
            value={option}
            data-testid={`${testid}-option-${option}`}
          >
            {option}
          </option>
        ))}
      </Form.Select>
    </Form.Group>
  );
}