1
1
import { assertEquals , assertRejects , assertStringIncludes } from "./deps.dev.ts" ;
2
2
import { $ , CommandBuilder } from "./deps.ts" ;
3
3
4
- const mod = $ . relativePath ( import . meta. url , "mod .ts" ) ;
5
- const demo = $ . relativePath ( import . meta. url , "demo.md" ) ;
4
+ const cli = $ . relativePath ( import . meta. url , "cli .ts" ) ;
5
+ const demo = $ . relativePath ( import . meta. url , ".." , " demo.md") ;
6
6
const demoText = Deno . readTextFileSync ( demo ) ;
7
7
8
8
const t$ = $ . build$ ( {
@@ -55,7 +55,7 @@ function withServer(action: (serverUrl: URL) => Promise<void>) {
55
55
}
56
56
57
57
Deno . test ( "mdrb works with local file" , async ( ) => {
58
- const { combined } = await t$ `deno run -A ${ mod } ${ demo } ` . stdinText ( "" ) ;
58
+ const { combined } = await t$ `deno run -A ${ cli } ${ demo } ` . stdinText ( "" ) ;
59
59
60
60
const expected = $ . dedent `
61
61
step 1 of 3 // say hello to the world
@@ -75,7 +75,7 @@ Deno.test("mdrb works with local file", async () => {
75
75
} ) ;
76
76
77
77
Deno . test ( "mdrb shows error output for local file if no file exists" , async ( ) => {
78
- const { combined, code } = await t$ `deno run -A ${ mod } ./does-not-exist.md` . stdinText ( "" ) ;
78
+ const { combined, code } = await t$ `deno run -A ${ cli } ./does-not-exist.md` . stdinText ( "" ) ;
79
79
80
80
assertEquals ( code , 2 ) ;
81
81
assertStringIncludes ( combined , "no file exists at ./does-not-exist.md" ) ;
@@ -84,7 +84,7 @@ Deno.test("mdrb shows error output for local file if no file exists", async () =
84
84
Deno . test ( "mdrb shows error output for local file if text read" , async ( ) => {
85
85
const file = await Deno . makeTempFile ( { prefix : "mdrb-test_" , suffix : ".md" } ) ;
86
86
87
- const { combined, code } = await t$ `deno run -A ${ mod } ${ file } ` . stdinText ( "" ) ;
87
+ const { combined, code } = await t$ `deno run -A ${ cli } ${ file } ` . stdinText ( "" ) ;
88
88
89
89
assertEquals ( code , 2 ) ;
90
90
assertStringIncludes ( combined , `no code to run for ${ file } ` ) ;
@@ -94,7 +94,7 @@ Deno.test("mdrb works with http", async () => {
94
94
await withServer ( async ( serverURL ) => {
95
95
const url = new URL ( "/demo" , serverURL ) ;
96
96
97
- const { combined } = await t$ `deno run -A ${ mod } ${ url } ` . stdinText ( "" ) ;
97
+ const { combined } = await t$ `deno run -A ${ cli } ${ url } ` . stdinText ( "" ) ;
98
98
99
99
const expected = $ . dedent `
100
100
step 1 of 3 // say hello to the world
@@ -118,15 +118,15 @@ Deno.test("mdrb shows error output for http if no text served", async () => {
118
118
await withServer ( async ( serverURL ) => {
119
119
const url = new URL ( "/does-not-exist" , serverURL ) ;
120
120
121
- const { combined, code } = await t$ `deno run -A ${ mod } ${ url } ` . stdinText ( "" ) ;
121
+ const { combined, code } = await t$ `deno run -A ${ cli } ${ url } ` . stdinText ( "" ) ;
122
122
123
123
assertEquals ( code , 2 ) ;
124
124
assertStringIncludes ( combined , "no code to run for http://localhost" ) ;
125
125
} ) ;
126
126
} ) ;
127
127
128
128
Deno . test ( "mdrb works with stdin" , async ( ) => {
129
- const { combined } = await t$ `deno run -A ${ mod } ` . stdinText ( demoText ) ;
129
+ const { combined } = await t$ `deno run -A ${ cli } ` . stdinText ( demoText ) ;
130
130
131
131
const expected = $ . dedent `
132
132
step 1 of 3 // say hello to the world
@@ -146,7 +146,7 @@ Deno.test("mdrb works with stdin", async () => {
146
146
} ) ;
147
147
148
148
Deno . test ( "mdrb shows error output for stdin if no text piped" , async ( ) => {
149
- const { combined, code } = await t$ `deno run -A ${ mod } ` . stdinText ( "" ) ;
149
+ const { combined, code } = await t$ `deno run -A ${ cli } ` . stdinText ( "" ) ;
150
150
151
151
assertEquals ( code , 2 ) ;
152
152
assertStringIncludes ( combined , "no code to run from stdin" ) ;
@@ -157,7 +157,7 @@ Deno.test(
157
157
async ( ) => {
158
158
const timeout = 3_000 ;
159
159
160
- await t$ `deno run -A ${ mod } --mode runbook` . stdinText ( demoText )
160
+ await t$ `deno run -A ${ cli } --mode runbook` . stdinText ( demoText )
161
161
. timeout ( timeout ) . noThrow ( false ) ;
162
162
} ,
163
163
) ;
@@ -169,7 +169,7 @@ Deno.test("$ is defined by default", async () => {
169
169
~~~
170
170
` ;
171
171
172
- const { combined } = await t$ `deno run -A ${ mod } `
172
+ const { combined } = await t$ `deno run -A ${ cli } `
173
173
. stdinText ( md ) ;
174
174
175
175
assertStringIncludes ( combined , "$ is function" ) ;
@@ -182,7 +182,7 @@ Deno.test("$ is undefined if dax integration disabled", async () => {
182
182
~~~
183
183
` ;
184
184
185
- const { combined } = await t$ `deno run -A ${ mod } --dax=false`
185
+ const { combined } = await t$ `deno run -A ${ cli } --dax=false`
186
186
. stdinText ( md ) ;
187
187
188
188
assertStringIncludes ( combined , "$ is undefined" ) ;
@@ -201,7 +201,7 @@ Deno.test("single mode throws if blocks are incompatible", async () => {
201
201
~~~
202
202
` ;
203
203
204
- await t$ `deno run -A ${ mod } --mode=single` . stdinText ( md ) . noThrow ( false ) ;
204
+ await t$ `deno run -A ${ cli } --mode=single` . stdinText ( md ) . noThrow ( false ) ;
205
205
} ) ;
206
206
} ) ;
207
207
@@ -216,7 +216,7 @@ Deno.test("summary is printed if one is available", async () => {
216
216
~~~
217
217
` ;
218
218
219
- const { combined } = await t$ `deno run -A ${ mod } `
219
+ const { combined } = await t$ `deno run -A ${ cli } `
220
220
. stdinText ( md ) ;
221
221
222
222
assertStringIncludes ( combined , `step 1 of 1 // ${ summary } ` ) ;
@@ -233,7 +233,7 @@ Deno.test("summary is not printed if one is not available", async () => {
233
233
~~~
234
234
` ;
235
235
236
- const { stderr } = await t$ `deno run -A ${ mod } `
236
+ const { stderr } = await t$ `deno run -A ${ cli } `
237
237
. captureCombined ( false ) . stdinText ( md ) ;
238
238
239
239
assertEquals ( stderr . trim ( ) , "step 1 of 1" ) ;
0 commit comments