All files / components/TabComponent CATMETabComponent.jsx

100% Statements 6/6
100% Branches 0/0
100% Functions 3/3
100% Lines 6/6

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          8x 4x       8x 4x 4x     8x                                    
import React from "react";
import { Button } from "react-bootstrap";
import { toast } from "react-toastify";
 
export default function CATMETabComponent({ courseId, testIdPrefix }) {
  const onSuccessDownloadTriggered = () => {
    toast("Download successfully initiated.");
  };
 
  // The download uses the same format as DonwloadsTabComponent with the toast called in this function.
  const downloadFormattedCATMECsv = () => {
    window.open(`/api/csv/catme?courseId=${courseId}`, "_blank");
    onSuccessDownloadTriggered();
  };
 
  return (
    <div data-testid={`${testIdPrefix}-catme-tab-component`}>
      <h4
        className="mt-4"
        data-testid={`${testIdPrefix}-downloads-teams-header`}
      >
        CATME Downloads
      </h4>
      <Button
        variant="primary"
        onClick={downloadFormattedCATMECsv}
        data-testid={`${testIdPrefix}-btn-catme-formatted-teams-csv`}
      >
        Download CSV Roster in CATME format
      </Button>
    </div>
  );
}