Skip to main content
Module

x/alosaur/src/route/get-action.test.ts

Alosaur - Deno web framework with many decorators
Very Popular
Go to Latest
File
import { assert } from "../deps_test.ts";import { getAction } from "./get-action.ts";import { RouteMetadata } from "../metadata/route.ts";import { ActionMetadataArgs } from "../metadata/action.ts";const { test } = Deno;
test({ name: "testGetActions", fn() { const routes: RouteMetadata[] = [ { baseRoute: "/test", route: "/test/:id/:name", target: {}, areaObject: {}, controllerObject: {}, actionObject: {}, actionMetadata: {} as ActionMetadataArgs, action: "test", method: "GET", params: [], }, { baseRoute: "/test", route: "/test/:name", target: {}, areaObject: {}, controllerObject: {}, actionObject: {}, actionMetadata: {} as ActionMetadataArgs, action: "test", method: "GET", params: [], }, ]; const actionWithName = getAction( routes, "GET", "http://localhost:8000/test/name", ); const actionWithIdName = getAction( routes, "GET", "http://localhost:8000/test/2/name", );
assert( actionWithName && actionWithName.routeParams && actionWithName.routeParams.name === "name", ); assert( actionWithIdName && actionWithIdName.routeParams && actionWithIdName.routeParams.id === "2" && actionWithIdName.routeParams.name === "name", ); },});