fix: ensure typescript routes are hit most to least specific

This commit is contained in:
Andy Burke 2025-06-25 20:24:51 -07:00
parent 4f68a64a88
commit 1928bfcb5e
6 changed files with 35 additions and 12 deletions

View file

@ -16,15 +16,28 @@ Deno.test({
Deno.env.set('SERVERUS_ROOT', './tests/www');
test_server_info = await get_ephemeral_listen_server();
const response = await fetch(`http://${test_server_info.hostname}:${test_server_info.port}/echo/hi`, {
method: 'GET'
});
const echoes: Record<string, string> = {
'': 'echo! .... echo. ................... echo?',
hi: 'hello',
yo: 'yo',
'whoa there': 'whoa there'
};
const body = await response.text();
for await (const key of Object.keys(echoes)) {
const response = await fetch(`http://${test_server_info.hostname}:${test_server_info.port}/echo/${key}`, {
method: 'GET'
});
asserts.assert(response.ok);
asserts.assert(body);
asserts.assertEquals(body, 'hello');
const body = await response.text();
asserts.assert(response.ok);
asserts.assert(body);
console.dir({
body,
key
});
asserts.assertEquals(body, echoes[key]);
}
} finally {
Deno.env.delete('SERVERUS_ROOT');
if (test_server_info) {