From a17ad789c95069c5355527b82f37ba89a3add125 Mon Sep 17 00:00:00 2001 From: EuAndreh Date: Fri, 15 Mar 2024 12:24:15 -0300 Subject: src/hero.mjs: Add isValidLabel() --- tests/js/hero.mjs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'tests/js/hero.mjs') diff --git a/tests/js/hero.mjs b/tests/js/hero.mjs index 4330cb2..d9c01d4 100644 --- a/tests/js/hero.mjs +++ b/tests/js/hero.mjs @@ -20,6 +20,7 @@ import { normalizeSegments, pathToSegments, hasPathParams, + isValidLabel, addRoute, findStaticHandler, firstParamMatch, @@ -576,6 +577,23 @@ const test_hasPathParams = async t => { }); }; +const test_isValidLabel = async t => { + t.start("isValidLabel()"); + + await t.test("typo examples", () => { + assert.ok(!isValidLabel("get")); + assert.ok(!isValidLabel("WebSocket")); + assert.ok(!isValidLabel("WEBSOCKETS")); + assert.ok(!isValidLabel("ws")); + }); + + await t.test("valid usages", () => { + assert.ok(isValidLabel("GET")); + assert.ok(isValidLabel("PUT")); + assert.ok(isValidLabel("WEBSOCKET")); + }); +}; + const test_addRoute = async t => { t.start("addRoute()"); @@ -1787,6 +1805,7 @@ await runner.runTests([ test_normalizeSegments, test_pathToSegments, test_hasPathParams, + test_isValidLabel, test_addRoute, test_findStaticHandler, test_firstParamMatch, -- cgit v1.2.3