UNPKG

organism-react-sort-by

Version:
54 lines 961 B
import { expect } from "chai"; import sortCompare from "../sortCompare.mjs"; describe("SortCompare Test", function () { var d = [{ col: 1 }, { col: 3 }, { col: 2 }]; var s = [{ col: "a" }, { col: "c" }, { col: "b" }]; it("test asc sort", function () { expect(d.sort(sortCompare("col"))).to.deep.equal([{ col: 1 }, { col: 2 }, { col: 3 }]); }); it("test desc sort", function () { expect(d.sort(sortCompare("col", 1))).to.deep.equal([{ col: 3 }, { col: 2 }, { col: 1 }]); }); it("test asc sort with string", function () { expect(s.sort(sortCompare("col"))).to.deep.equal([{ col: "a" }, { col: "b" }, { col: "c" }]); }); it("test desc sort with string", function () { expect(s.sort(sortCompare("col", 1))).to.deep.equal([{ col: "c" }, { col: "b" }, { col: "a" }]); }); });