All files / components/Commons HealthStrategiesUpdateDropdown.js

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

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                  106x                       258x                                  
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;