@@ -2,6 +2,7 @@ import { afterAll, beforeAll, describe, expect, it, vi } from "vitest";
22import * as $url from "../../../lib/util/url.js" ;
33import * as isWin from "../../../lib/util/is-windows" ;
44import convertPathToPosix from "../../../lib/util/convert-path-to-posix" ;
5+ import { cwd } from "../../../lib/util/url.js" ;
56describe ( "Return the extension of a URL" , ( ) => {
67 it ( "should return an empty string if there isn't any extension" , async ( ) => {
78 const extension = $url . getExtension ( "/file" ) ;
@@ -18,30 +19,32 @@ describe("Return the extension of a URL", () => {
1819 expect ( extension ) . to . equal ( ".yml" ) ;
1920 } ) ;
2021} ) ;
21- describe ( "Handle Windows file paths" , ( ) => {
22- beforeAll ( function ( this : any ) {
23- vi . spyOn ( isWin , "isWindows" ) . mockReturnValue ( true ) ;
24- } ) ;
2522
26- afterAll ( function ( this : any ) {
27- vi . restoreAllMocks ( ) ;
28- } ) ;
23+ if ( ! process . env . BROWSER ) {
24+ describe ( "Handle Windows file paths" , ( ) => {
25+ beforeAll ( function ( this : any ) {
26+ vi . spyOn ( isWin , "isWindows" ) . mockReturnValue ( true ) ;
27+ } ) ;
2928
30- it ( "should handle absolute paths" , async ( ) => {
31- const result = $url . fromFileSystemPath ( "Y:\\A\\Random\\Path\\file.json" ) ;
32- expect ( result )
33- . to . be . a ( "string" )
34- . and . toSatisfy ( ( msg : string ) => msg . startsWith ( "Y:/A/Random/Path" ) ) ;
35- } ) ;
29+ afterAll ( function ( this : any ) {
30+ vi . restoreAllMocks ( ) ;
31+ } ) ;
3632
37- it ( "should handle relative paths" , async ( ) => {
38- const result = $url . fromFileSystemPath ( "Path\\file.json" ) ;
39- const pwd = convertPathToPosix ( process . cwd ( ) ) ;
40- expect ( result )
41- . to . be . a ( "string" )
42- . and . toSatisfy ( ( msg : string ) => msg . startsWith ( pwd ) ) ;
33+ it ( "should handle absolute paths" , async ( ) => {
34+ const result = $url . fromFileSystemPath ( "Y:\\A\\Random\\Path\\file.json" ) ;
35+ expect ( result )
36+ . to . be . a ( "string" )
37+ . and . toSatisfy ( ( msg : string ) => msg . startsWith ( "Y:/A/Random/Path" ) ) ;
38+ } ) ;
39+
40+ it ( "should handle relative paths" , async ( ) => {
41+ const result = $url . fromFileSystemPath ( "Path\\file.json" ) ;
42+ const pwd = convertPathToPosix ( cwd ( ) ) ;
43+ expect ( result ) . to . be . a ( "string" ) ;
44+ expect ( result ) . toSatisfy ( ( msg : string ) => msg . startsWith ( pwd ) ) ;
45+ } ) ;
4346 } ) ;
44- } ) ;
47+ }
4548
4649describe ( "Handle Linux file paths" , ( ) => {
4750 beforeAll ( function ( this : any ) {
0 commit comments