All files / components/Jobs JobsTable.jsx

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

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 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57          43x                     7x         7x         7x         7x                   12x                     43x   43x    
import React from "react";
import OurTable from "main/components/OurTable";
import { formatTime } from "main/utils/dateUtils";
 
export default function JobsTable({ jobs }) {
  const columns = [
    {
      header: "id",
      accessorKey: "id",
    },
    {
      header: "Job Name",
      accessorKey: "jobName",
    },
    {
      header: "User Email",
      accessorFn: (row) => row.createdBy?.email,
      id: "createdByEmail",
    },
    {
      header: "Course Name",
      accessorFn: (row) => row.course?.courseName ?? "",
      id: "courseName",
    },
    {
      header: "Created",
      accessorFn: (row) => formatTime(row.createdAt),
      id: "createdAt",
    },
    {
      header: "Updated",
      accessorFn: (row) => formatTime(row.updatedAt),
      id: "updatedAt",
    },
    {
      header: "Status",
      accessorKey: "status",
    },
    {
      header: "Log",
      accessorKey: "log",
      cell: ({ cell }) => (
        <div
          style={{ maxWidth: 450, maxHeight: 100, overflowY: "auto" }}
          data-testid={`JobsTable-cell-row-${cell.row.index}-col-${cell.column.id}-div`}
        >
          <pre style={{ whiteSpace: "pre-wrap" }}>{cell.getValue()}</pre>
        </div>
      ),
    },
  ];
 
  const testid = "JobsTable";
 
  return <OurTable data={jobs} columns={columns} testid={testid} />;
}