File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import { expect } from "@std/expect" ;
2- import { parseRootPath } from "./config.ts" ;
2+ import { normalizeConfig , parseRootPath } from "./config.ts" ;
33
44Deno . test ( "parseRootPath" , ( ) => {
55 const cwd = Deno . cwd ( ) . replaceAll ( "\\" , "/" ) ;
@@ -22,3 +22,16 @@ Deno.test("parseRootPath", () => {
2222 expect ( parseRootPath ( "/foo/bar.jsx" , cwd ) ) . toEqual ( "/foo" ) ;
2323 expect ( parseRootPath ( "/foo/bar.mjs" , cwd ) ) . toEqual ( "/foo" ) ;
2424} ) ;
25+
26+ Deno . test ( "normalizeConfig - root" , ( ) => {
27+ const cwd = Deno . cwd ( ) . replaceAll ( "\\" , "/" ) ;
28+ const configRoot = ( root ?: string ) => normalizeConfig ( { root } ) . root ;
29+
30+ expect ( configRoot ( ) ) . toEqual ( cwd ) ;
31+ expect ( configRoot ( "/foo/bar" ) ) . toEqual ( "/foo/bar" ) ;
32+ expect ( configRoot ( "/foo/bar.ts" ) ) . toEqual ( "/foo" ) ;
33+ expect ( configRoot ( "file:///foo/bar" ) ) . toEqual ( "/foo/bar" ) ;
34+ expect ( configRoot ( "file:///C:/foo/bar" ) ) . toEqual ( "C:/foo/bar" ) ;
35+ expect ( configRoot ( "./foo/bar" ) ) . toEqual ( `${ cwd } /foo/bar` ) ;
36+ expect ( configRoot ( "./foo/bar.ts" ) ) . toEqual ( `${ cwd } /foo` ) ;
37+ } ) ;
You can’t perform that action at this time.
0 commit comments