@@ -3,8 +3,27 @@ import { describe, expect, it } from "vitest";
33import { normalizePathForInlineCode } from "./normalize-path-for-inline-code" ;
44
55describe ( "normalizePathForInlineCode" , ( ) => {
6- it ( "should extract production env vars" , ( ) => {
7- const result = normalizePathForInlineCode ( "TODO" ) ;
8- expect ( result ) . toBeFalsy ( ) ;
6+ describe . runIf ( process . platform === "win32" ) ( "windows" , ( ) => {
7+ it ( "should produce an absolute path ready to be embedded in inlined code" , ( ) => {
8+ const code = `const d = require('${ normalizePathForInlineCode ( "/Users/me/projects/cloudflare/index.mjs" ) } ').default;` ;
9+ expect ( code ) . toEqual ( "const d = require('\\Users\\me\\projects\\cloudflare\\index.mjs').default;" ) ;
10+ } ) ;
11+
12+ it ( "should produce a relative path ready to be embedded in inlined code" , ( ) => {
13+ const code = `const d = require('${ normalizePathForInlineCode ( "../../tmp/index.mjs" ) } ').default;` ;
14+ expect ( code ) . toEqual ( "const d = require('..\\..\\tmp\\index.mjs').default;" ) ;
15+ } ) ;
16+ } ) ;
17+
18+ describe . runIf ( process . platform === "linux" || process . platform === "darwin" ) ( "linux/mac" , ( ) => {
19+ it ( "should produce an absolute path ready to be embedded in inlined code" , ( ) => {
20+ const code = `const d = require('${ normalizePathForInlineCode ( "/Users/me/projects/cloudflare/index.mjs" ) } ').default;` ;
21+ expect ( code ) . toEqual ( "const d = require('/Users/me/projects/cloudflare/index.mjs').default;" ) ;
22+ } ) ;
23+
24+ it ( "should produce a relative path ready to be embedded in inlined code" , ( ) => {
25+ const code = `const d = require('${ normalizePathForInlineCode ( "../../tmp/index.mjs" ) } ').default;` ;
26+ expect ( code ) . toEqual ( "const d = require('../../tmp/index.mjs').default;" ) ;
27+ } ) ;
928 } ) ;
1029} ) ;
0 commit comments