@@ -537,3 +537,38 @@ describe("isWsl", () => {
537537 } )
538538 } )
539539} )
540+
541+ describe ( "constructOpenOptions" , ( ) => {
542+ it ( "should return options for darwin" , ( ) => {
543+ const platform : NodeJS . Platform | "wsl" = "darwin"
544+ const url = new URL ( "localhost:8080" )
545+ const { args, command, urlSearch } = util . constructOpenOptions ( platform , url . search )
546+ expect ( args ) . toStrictEqual ( [ ] )
547+ expect ( command ) . toBe ( "open" )
548+ expect ( urlSearch ) . toBe ( "" )
549+ } )
550+ it ( "should return options for linux" , ( ) => {
551+ const platform : NodeJS . Platform | "wsl" = "linux"
552+ const url = new URL ( "localhost:8080" )
553+ const { args, command, urlSearch } = util . constructOpenOptions ( platform , url . search )
554+ expect ( args ) . toStrictEqual ( [ ] )
555+ expect ( command ) . toBe ( "xdg-open" )
556+ expect ( urlSearch ) . toBe ( "" )
557+ } )
558+ it ( "should return options for win32" , ( ) => {
559+ const platform : NodeJS . Platform | "wsl" = "win32"
560+ const url = new URL ( "localhost:8080?q=&test" )
561+ const { args, command, urlSearch } = util . constructOpenOptions ( platform , url . search )
562+ expect ( args ) . toStrictEqual ( [ "/c" , "start" , '""' , "/b" ] )
563+ expect ( command ) . toBe ( "cmd" )
564+ expect ( urlSearch ) . toBe ( "?q=^&test" )
565+ } )
566+ it ( "should return options for wsl" , ( ) => {
567+ const platform : NodeJS . Platform | "wsl" = "wsl"
568+ const url = new URL ( "localhost:8080?q=&test" )
569+ const { args, command, urlSearch } = util . constructOpenOptions ( platform , url . search )
570+ expect ( args ) . toStrictEqual ( [ "/c" , "start" , '""' , "/b" ] )
571+ expect ( command ) . toBe ( "cmd.exe" )
572+ expect ( urlSearch ) . toBe ( "?q=^&test" )
573+ } )
574+ } )
0 commit comments