All files / components/Commons HealthStrategiesUpdateDropdown.jsx

100% Statements 26/26
100% Branches 1/1
100% Functions 1/1
100% Lines 26/26

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 381x   128x 128x 128x 128x 128x 128x 128x 128x 128x 128x 128x 128x 128x 128x   128x 128x   128x 128x 128x 128x 128x 128x   128x             128x   1x  
import { Form } from "react-bootstrap";
 
function HealthUpdateStrategiesDropdown({
  formName,
  displayName,
  initialValue,
  healthUpdateStrategies,
  register,
}) {
  return (
    <Form.Group className="mb-3">
      <Form.Label htmlFor={formName}>{displayName}</Form.Label>
      {healthUpdateStrategies && (
        <Form.Select
          data-testid={`${formName}-select`}
          id={formName}
          // "required" option is not necessary, since dropdown will always have a value
          {...register(formName)}
          defaultValue={initialValue}
        >
          {healthUpdateStrategies.strategies.map((strategy) => (
            <option
              key={strategy.name}
              value={strategy.name}
              title={strategy.description}
              data-testid={formName + "-" + strategy.name}
            >
              {strategy.displayName}
            </option>
          ))}
        </Form.Select>
      )}
    </Form.Group>
  );
}
 
export default HealthUpdateStrategiesDropdown;