Skip to main content
Module

x/ruck/serve.test.mjs

Ruck is an open source buildless React web application framework for Deno.
Go to Latest
File
// @ts-check
import { assertRejects } from "std/testing/asserts.ts";
import serve from "./serve.mjs";
Deno.test("`serve` with option `clientImportMap` not a `URL` instance.", async () => { await assertRejects( () => serve({ // @ts-expect-error Testing invalid. clientImportMap: true, port: 3000, }), TypeError, "Option `clientImportMap` must be a `URL` instance.", );});
Deno.test("`serve` with option `esModuleShimsSrc` not a string.", async () => { await assertRejects( () => serve({ clientImportMap: new URL("./importMap.json", import.meta.url), // @ts-expect-error Testing invalid. esModuleShimsSrc: true, port: 3000, }), TypeError, "Option `esModuleShimsSrc` must be a string.", );});
Deno.test("`serve` with option `publicDir` not a `URL` instance.", async () => { await assertRejects( () => serve({ clientImportMap: new URL("./importMap.json", import.meta.url), // @ts-expect-error Testing invalid. publicDir: true, port: 3000, }), TypeError, "Option `publicDir` must be a `URL` instance.", );});
Deno.test( "`serve` with option `publicDir` not a URL ending with `/`.", async () => { await assertRejects( () => serve({ clientImportMap: new URL("./importMap.json", import.meta.url), publicDir: new URL(import.meta.url), port: 3000, }), TypeError, "Option `publicDir` must be a URL ending with `/`.", ); },);
Deno.test("`serve` with option `htmlComponent` not a function.", async () => { await assertRejects( () => serve({ clientImportMap: new URL("./importMap.json", import.meta.url), port: 3000, // @ts-expect-error Testing invalid. htmlComponent: true, }), TypeError, "Option `htmlComponent` must be a function.", );});
Deno.test("`serve` with option `port` not a number.", async () => { await assertRejects( () => serve({ clientImportMap: new URL("./importMap.json", import.meta.url), // @ts-expect-error Testing invalid. port: true, }), TypeError, "Option `port` must be a number.", );});
Deno.test( "`serve` with option `signal` not an `AbortSignal` instance.", async () => { await assertRejects( () => serve({ clientImportMap: new URL("./importMap.json", import.meta.url), port: 3000, // @ts-expect-error Testing invalid. signal: true, }), TypeError, "Option `signal` must be an `AbortSignal` instance.", ); },);