Skip to main content
Module

x/bob/utils/sort-date.test.ts

A static site generator for the dynamic web - develop with TSX and build with Deno
Latest
File
/*Copyright 2021 Eric Selin
This file is part of `bob`.
`bob` is free software: you can redistribute it and/or modifyit under the terms of the GNU Lesser General Public License as published bythe Free Software Foundation, either version 3 of the License, or(at your option) any later version.
`bob` is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See theGNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public Licensealong with `bob`. If not, see <https://www.gnu.org/licenses/>.
Please contact the developers via GitHub <https://www.github.com/ericselin>or email eric.selin@gmail.com <mailto:eric.selin@gmail.com>*/
import { assertEquals } from "../deps.ts";import { sortDateDesc } from "./sort-date.ts";
Deno.test("desc date sorting works and puts no-date at top", () => { const arr = [ { order: 3, date: new Date("2021-10-03") }, { order: 1 }, { order: 5, date: new Date("2021-10-01") }, { order: 4, date: new Date("2021-10-02") }, { order: 2 }, ]; const order = arr.sort(sortDateDesc).map(({ order }) => order); assertEquals(order, [1, 2, 3, 4, 5]);});