@@ -2,6 +2,7 @@ import type { Tunnel, TunnelOptions } from "@hongminhee/localtunnel";
22import { runSync } from "@optique/run" ;
33import { deepEqual , rejects } from "node:assert/strict" ;
44import test from "node:test" ;
5+ import { runCli } from "./runner.ts" ;
56import type { Ora } from "ora" ;
67import { runTunnel , tunnelCommand } from "./tunnel.ts" ;
78
@@ -21,6 +22,57 @@ test("tunnel command structure", () => {
2122 deepEqual ( testCommandWithoutOptions . service , undefined ) ;
2223} ) ;
2324
25+ test ( "tunnel runner accepts omitted tunnel service" , async ( ) => {
26+ const result = await runCli ( [ "tunnel" , "3000" , "--ignore-config" ] ) ;
27+
28+ deepEqual ( result . command , "tunnel" ) ;
29+ deepEqual ( result . port , 3000 ) ;
30+ deepEqual ( ( result as { service ?: unknown } ) . service , undefined ) ;
31+ } ) ;
32+
33+ test ( "inbox runner accepts tunnel options without a tunnel service" , async ( ) => {
34+ const withoutTunnel = await runCli ( [
35+ "inbox" ,
36+ "--no-tunnel" ,
37+ "--ignore-config" ,
38+ ] ) ;
39+ const withOtherOption = await runCli ( [
40+ "inbox" ,
41+ "--actor-name" ,
42+ "Test Inbox" ,
43+ "--ignore-config" ,
44+ ] ) ;
45+
46+ deepEqual ( withoutTunnel . command , "inbox" ) ;
47+ deepEqual ( ( withoutTunnel as { tunnel ?: unknown } ) . tunnel , false ) ;
48+ deepEqual (
49+ ( withoutTunnel as { tunnelService ?: unknown } ) . tunnelService ,
50+ undefined ,
51+ ) ;
52+ deepEqual ( withOtherOption . command , "inbox" ) ;
53+ deepEqual ( ( withOtherOption as { tunnel ?: unknown } ) . tunnel , true ) ;
54+ deepEqual (
55+ ( withOtherOption as { actorName ?: unknown } ) . actorName ,
56+ "Test Inbox" ,
57+ ) ;
58+ deepEqual (
59+ ( withOtherOption as { tunnelService ?: unknown } ) . tunnelService ,
60+ undefined ,
61+ ) ;
62+ } ) ;
63+
64+ test ( "relay runner accepts tunnel options without a tunnel service" , async ( ) => {
65+ const result = await runCli ( [
66+ "relay" ,
67+ "--no-tunnel" ,
68+ "--ignore-config" ,
69+ ] ) ;
70+
71+ deepEqual ( result . command , "relay" ) ;
72+ deepEqual ( ( result as { tunnel ?: unknown } ) . tunnel , false ) ;
73+ deepEqual ( ( result as { tunnelService ?: unknown } ) . tunnelService , undefined ) ;
74+ } ) ;
75+
2476test ( "tunnel successfully creates and manages tunnel" , async ( ) => {
2577 const mockCommand = {
2678 command : "tunnel" as const ,
0 commit comments