Mirror of https://github.com/roostorg/coop
github.com/roostorg/coop
1// We allow the test files, and only the test files, to reference node types cuz
2// we don't run these in the browser.
3/// <reference types="node" />
4import * as assert from 'node:assert';
5import { describe, it } from 'node:test';
6
7import { makeDateString } from '../index.js';
8
9const stringsAndExpectedResults = {
10 '': undefined,
11 abc: undefined,
12 '1': undefined,
13 '2023-04-12T19:47:09.406Z': '2023-04-12T19:47:09.406Z',
14 '2023.0.1.01': undefined,
15 '2023.01.01': undefined,
16 '2023-04-12T19:47:09.40604Z': '2023-04-12T19:47:09.406Z',
17 '2023-04-12T19:47:09.4Z': '2023-04-12T19:47:09.400Z',
18};
19
20describe('makeDateString', () => {
21 it('should properly handle inputs', () => {
22 Object.entries(stringsAndExpectedResults).map(([key, value]) => {
23 const result = makeDateString(key);
24 assert.ok(
25 result === value,
26 `makeDateString('${key}') was expected to be ${value}, but instead was ${result}.`,
27 );
28 });
29 });
30});