{"size": 1583, "ext": "js", "max_stars_repo_path": "exercises/concept/array-loops/array-loops.spec.js", "max_stars_repo_name": "TheRakeshPurohit/javascript-2", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "exercises/concept/array-loops/array-loops.spec.js", "max_issues_repo_name": "TheRakeshPurohit/javascript-2", "max_issues_repo_issues_event_min_datetime": "2021-05-10T10:37:16.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-25T12:12:26.000Z", "max_forks_repo_path": "exercises/concept/array-loops/array-loops.spec.js", "max_forks_repo_name": "ee7/javascript", "max_forks_repo_forks_event_min_datetime": "2021-11-03T11:30:33.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-03T11:30:33.000Z"}
{"max_stars_count": null, "max_issues_count": 155, "max_forks_count": 1, "avg_line_length": 25.9508196721, "max_line_length": 68, "alphanum_fraction": 0.5407454201}
import {
  determineUniqueCards,
  determineOddEvenCards,
  cardTypeCheck,
} from './array-loops';

/**
 * @template T the expected return type
 * @typedef {Array<[number[], number, T]>} TestSingleMatrix
 */

/**
 * @template T the expected return type
 * @typedef {Array<[number[], T]>} TestAllMatrix
 **/

describe('array-loops', () => {
  describe('cardTypeCheck', () => {
    /** @type {TestSingleMatrix<number>} */
    const cardTypeCheckTests = [
      [[1, 2, 3, 4, 6, 7], 4, 1],
      [[1, 2, 2, -3, -4, -4, 2], 2, 3],
      [[1, 2, 3], 4, 0],
    ];

    cardTypeCheckTests.forEach(([array, card, expected]) => {
      test(`cardTypeCheck([${array}], ${card})`, () => {
        expect(cardTypeCheck(array, card)).toStrictEqual(expected);
      });
    });
  });

  describe('oddEvenCards', () => {
    /** @type {Array<Array<Array<number>, boolean, number>>>} */
    const oddEvenCardsTestCases = [
      [[1, 2, 3], true, 1],
      [[1, 2, 3, -1, 32, 1, 2, 3], false, 4],
    ];

    oddEvenCardsTestCases.forEach(([array, isEven, expected]) => {
      test(`determineOddEvenCards([${array}], isEven)`, () => {
        expect(determineOddEvenCards(array, isEven)).toBe(expected);
      });
    });
  });

  describe('uniqueCards', () => {
    /** @type {Array<Array} */
    const uniqueCardTestCases = [
      [[1, 2, 3], 3],
      [[1, 2, 3, -1, 32, 1, 2, 3], 5],
    ];

    uniqueCardTestCases.forEach(([array, expected]) => {
      test(`determineUniqueCards([${array}])`, () => {
        expect(determineUniqueCards(array)).toBe(expected);
      });
    });
  });
});
