diff options
author | EuAndreh <eu@euandre.org> | 2024-02-28 11:30:33 -0300 |
---|---|---|
committer | EuAndreh <eu@euandre.org> | 2024-02-28 11:30:33 -0300 |
commit | ba13007dce63d211eb6a168f502f58af01a6ca1f (patch) | |
tree | 9bfbc3da317ed3cf8ec7e75e9e07b8e68acdafef /tests/js/utils.mjs | |
parent | tests/runner.mjs: Use process.stderr.write() to avoid printing newlines when ... (diff) | |
download | papod-ba13007dce63d211eb6a168f502f58af01a6ca1f.tar.gz papod-ba13007dce63d211eb6a168f502f58af01a6ca1f.tar.xz |
src/utils.mjs: Define strSortFn() and use it on all files
Diffstat (limited to 'tests/js/utils.mjs')
-rw-r--r-- | tests/js/utils.mjs | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/js/utils.mjs b/tests/js/utils.mjs index 004af95..178f6c8 100644 --- a/tests/js/utils.mjs +++ b/tests/js/utils.mjs @@ -10,6 +10,7 @@ import { first, promisify, partial, + strSortFn, } from "../../src/utils.mjs"; const test_eq = t => { @@ -344,6 +345,22 @@ const test_partial = t => { }); }; +const test_strSortFn = t => { + t.start("strSortFn()"); + + t.test("empty value", () => { + assert.equal(strSortFn("", ""), 0); + }); + + t.test("default sort", () => { + const arr = [ "a", "Z" ]; + assert.deepEqual( + [...arr].sort(strSortFn), + [...arr].sort().reverse(), + ); + }); +}; + await runner.runTests([ test_eq, @@ -354,4 +371,5 @@ await runner.runTests([ test_first, test_promisify, test_partial, + test_strSortFn, ]); |