Commit 65b176f5 authored by Giannis Kepas's avatar Giannis Kepas
Browse files

assignment 4 tests

parent bcf23881
Loading
Loading
Loading
Loading

test/assignment-4/test_24.js

deleted100644 → 0
+0 −21
Original line number Diff line number Diff line
import filterRange from "../solution_24.js";
import assert from "assert";

describe("\n\nSolution_24", () => {
  [
    [[5, 3, 8, 1], 1, 4, [3, 1]],
    [[2, 15, 30, 80], 14, 23, [15]],
    [[2, 3, 10, 4], 2, 5, [2, 3, 4]],
  ].map((obj) => {
    let [arr, num1, num2, filtered] = obj;
    let init = [...arr];
    it(`should return ${JSON.stringify(
      filtered
    )} for filterRange(${JSON.stringify(arr)}, ${num1}, ${num2})`, () => {
      assert.deepEqual(filterRange(arr, num1, num2), filtered);
    });
    it(`should not modify parameter array`, () => {
      assert.deepEqual(arr, init);
    });
  });
});

test/assignment-4/test_25.js

deleted100644 → 0
+0 −18
Original line number Diff line number Diff line
import filterRangeInPlace from "../solution_25.js";
import assert from "assert";

describe("\n\nSolution_25", () => {
  [
    [[5, 3, 8, 1], 1, 4, [3, 1]],
    [[2, 15, 30, 80], 14, 23, [15]],
    [[2, 3, 10, 4], 2, 5, [2, 3, 4]],
  ].map((obj) => {
    let [arr, a, b, filtered] = obj;
    it(`should return ${JSON.stringify(
      filtered
    )} for filterRangeInPlace('${JSON.stringify(arr)}', ${a}, ${b})`, () => {
      filterRangeInPlace(arr, a, b);
      assert.deepEqual(arr, filtered);
    });
  });
});

test/assignment-4/test_26.js

deleted100644 → 0
+0 −28
Original line number Diff line number Diff line
import mySort from "../solution_26.js";
import assert from "assert";

describe("\n\nSolution_26", () => {
  [
    [
      [5, 3, 8, 1],
      [8, 5, 3, 1],
    ],
    [
      [2, 15, 30, 80],
      [80, 30, 15, 2],
    ],
    [
      [2, 3, 10, 4],
      [10, 4, 3, 2],
    ],
  ].map((obj) => {
    let [arr, sorted] = obj;

    it(`should return ${JSON.stringify(sorted)} for mySort(${JSON.stringify(
      arr
    )})`, () => {
      mySort(arr);
      assert.deepEqual(arr, sorted);
    });
  });
});

test/assignment-4/test_27.js

deleted100644 → 0
+0 −27
Original line number Diff line number Diff line
import copySorted from "../solution_27.js";
import assert from "assert";

describe("\n\nSolution_27", () => {
  [
    [
      ["HTML", "JavaScript", "CSS"],
      ["CSS", "HTML", "JavaScript"],
    ],
    [
      ["ccc", "xxx", "aaa", "bbb"],
      ["aaa", "bbb", "ccc", "xxx"],
    ],
  ].map((obj) => {
    let [arr, sorted] = obj;

    let init = [...arr];
    it(`should return ${JSON.stringify(sorted)} for copySorted(${JSON.stringify(
      arr
    )})`, () => {
      assert.deepEqual(copySorted(arr), sorted);
    });
    it(`should not modify argument`, () => {
      assert.deepEqual(arr, init);
    });
  });
});

test/assignment-4/test_28.js

deleted100644 → 0
+0 −31
Original line number Diff line number Diff line
import getNames from "../solution_28.js";
import assert from "assert";

describe("\n\nSolution_28", () => {
  [
    [
      [
        { name: "John", age: 25 },
        { name: "Pete", age: 30 },
        { name: "Mary", age: 28 },
      ],
      ["John", "Pete", "Mary"],
    ],
    [
      [
        { name: "Jim", age: 25 },
        { name: "Jane", age: 30 },
        { name: "Maria", age: 28 },
      ],
      ["Jim", "Jane", "Maria"],
    ],
  ].map((obj) => {
    let [arr, names] = obj;

    it(`should return ${JSON.stringify(names)} for getNames('${JSON.stringify(
      arr
    )}')`, () => {
      assert.deepEqual(getNames(arr), names);
    });
  });
});
Loading