import { describe, expect, it } from "vitest";

import { validateUpc } from "../../util";
import {
  TGridUpcs,
  getIcuFrontPanelUpcs,
  getIcuLeftPanelUpcs,
  getIcuRightPanelUpcs,
  getWinkPanelUpcs,
} from "./util";

const panels: Record<string, () => TGridUpcs> = {
  icuLeftPanel: getIcuLeftPanelUpcs,
  icuFrontPanel: getIcuFrontPanelUpcs,
  icuRightPanel: getIcuRightPanelUpcs,
  winkPanel: getWinkPanelUpcs,
};

describe.each(Object.entries(panels))("%s", (_panelName, getGridUpcs) => {
  const [, strengthGroups] = getGridUpcs();

  for (const [strength, upcs] of Object.entries(strengthGroups)) {
    for (const upc of upcs) {
      it(`strength ${strength}: ${upc} is a valid UPC`, () => {
        expect(validateUpc(upc)).toBe(true);
      });
    }
  }
});
