@@ -2,6 +2,7 @@ import { afterAll, beforeAll, describe, expect, it, vi } from "vitest";
2
2
import * as $url from "../../../lib/util/url.js" ;
3
3
import * as isWin from "../../../lib/util/is-windows" ;
4
4
import convertPathToPosix from "../../../lib/util/convert-path-to-posix" ;
5
+ import { cwd } from "../../../lib/util/url.js" ;
5
6
describe ( "Return the extension of a URL" , ( ) => {
6
7
it ( "should return an empty string if there isn't any extension" , async ( ) => {
7
8
const extension = $url . getExtension ( "/file" ) ;
@@ -18,30 +19,32 @@ describe("Return the extension of a URL", () => {
18
19
expect ( extension ) . to . equal ( ".yml" ) ;
19
20
} ) ;
20
21
} ) ;
21
- describe ( "Handle Windows file paths" , ( ) => {
22
- beforeAll ( function ( this : any ) {
23
- vi . spyOn ( isWin , "isWindows" ) . mockReturnValue ( true ) ;
24
- } ) ;
25
22
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
+ } ) ;
29
28
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
+ } ) ;
36
32
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
+ } ) ;
43
46
} ) ;
44
- } ) ;
47
+ }
45
48
46
49
describe ( "Handle Linux file paths" , ( ) => {
47
50
beforeAll ( function ( this : any ) {
0 commit comments