import {
  transform,
  calculateLength,
} from "../../../../src/utils/translators/ldb/staffStation";

import { inputs } from "./stationInputs";
import { outputs } from "./stationOutputs";
import { noLength as serviceNoLength } from "./trainServiceInputs";
import { trainServices } from "./trainServiceInputs";

describe("transform", () => {
  test("Should return null for empty input", () => {
    const input = {};
    expect(transform(input)).toBeNull();
  });

  for (const testNo in inputs) {
    test(`Should correctly transform data ${testNo}`, () => {
      const input = inputs[testNo];
      const expectedOutput = outputs[testNo];

      expect(transform(input)).toEqual(expectedOutput);
    });
  }
});

// Write test for calculateLength(input: TrainServices): number | undefined

describe("calculateLength", () => {
  test("Should return ubdefined for no length", () => {
    const input = serviceNoLength;
    expect(calculateLength(input)).toBeUndefined();
  });

  for (const testNo in trainServices) {
    test(`Should correctly calculate ${testNo}`, () => {
      const input = trainServices[testNo];
      const expectedOutput = 4;

      expect(calculateLength(input)).toEqual(expectedOutput);
    });
  }
});
