From 3558c8fd1dbedef8484c329e117390d1ffdc119f Mon Sep 17 00:00:00 2001 From: EuAndreh Date: Fri, 15 Mar 2024 12:28:34 -0300 Subject: src/hero.mjs: Add comboForLabel() --- tests/js/hero.mjs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'tests/js/hero.mjs') diff --git a/tests/js/hero.mjs b/tests/js/hero.mjs index d9c01d4..171e01f 100644 --- a/tests/js/hero.mjs +++ b/tests/js/hero.mjs @@ -21,6 +21,7 @@ import { pathToSegments, hasPathParams, isValidLabel, + comboForLabel, addRoute, findStaticHandler, firstParamMatch, @@ -594,6 +595,24 @@ const test_isValidLabel = async t => { }); }; +const test_comboForLabel = async t => { + t.start("comboForLabel()"); + + await t.test("websocket gets its own combo", () => { + assert.deepEqual( + comboForLabel("WEBSOCKET", "IGNORED"), + [ "websocket", "GET" ], + ); + }); + + await t.test("otherwise we get what pass", () => { + assert.deepEqual( + comboForLabel("not-websocket", "a-keyword"), + [ "a-keyword", "not-websocket" ], + ); + }); +}; + const test_addRoute = async t => { t.start("addRoute()"); @@ -1806,6 +1825,7 @@ await runner.runTests([ test_pathToSegments, test_hasPathParams, test_isValidLabel, + test_comboForLabel, test_addRoute, test_findStaticHandler, test_firstParamMatch, -- cgit v1.2.3