@@ -81,54 +81,52 @@ describe("DesktopPreReadyPlatform", () => {
8181 ) ;
8282 } ) ;
8383
84- for ( const previousEntry of [ undefined , 'Exec="/Applications/deleted-previous.AppImage" %U' ] ) {
85- it . effect (
86- `prepares a ${ previousEntry ? "stale" : "missing" } Linux desktop entry before startup yields` ,
87- ( ) => {
88- vi . stubEnv ( "VITE_DEV_SERVER_URL" , "" ) ;
89- vi . stubEnv ( "XDG_DATA_HOME" , "/xdg" ) ;
90- vi . stubEnv ( "APPIMAGE" , "/Applications/current.AppImage" ) ;
91- getSwitchValueMock . mockReturnValue ( "" ) ;
92- let desktopName = "t3code.desktop" ;
93- let desktopEntry = previousEntry ;
94- let iconInstalled = false ;
95- copyFileSyncMock . mockImplementation ( ( _source : string , destination : string ) => {
96- iconInstalled = destination === "/xdg/icons/com.t3tools.T3Code.desktop.png" ;
97- } ) ;
98- setDesktopNameMock . mockImplementation ( ( name : string ) => {
99- desktopName = name ;
100- } ) ;
101- writeFileSyncMock . mockImplementation ( ( path : string , contents : string ) => {
102- if ( path === "/xdg/applications/com.t3tools.T3Code.desktop" ) desktopEntry = contents ;
103- } ) ;
84+ it . effect . each ( [
85+ { previousEntry : undefined , label : "missing" } ,
86+ { previousEntry : 'Exec="/Applications/deleted-previous.AppImage" %U' , label : "stale" } ,
87+ ] ) ( "prepares a $label Linux desktop entry before startup yields" , ( { previousEntry } ) => {
88+ vi . stubEnv ( "VITE_DEV_SERVER_URL" , "" ) ;
89+ vi . stubEnv ( "XDG_DATA_HOME" , "/xdg" ) ;
90+ vi . stubEnv ( "APPIMAGE" , "/Applications/current.AppImage" ) ;
91+ getSwitchValueMock . mockReturnValue ( "" ) ;
92+ let desktopName = "t3code.desktop" ;
93+ let desktopEntry = previousEntry ;
94+ let iconInstalled = false ;
95+ copyFileSyncMock . mockImplementation ( ( _source : string , destination : string ) => {
96+ iconInstalled = destination === "/xdg/icons/com.t3tools.T3Code.desktop.png" ;
97+ } ) ;
98+ setDesktopNameMock . mockImplementation ( ( name : string ) => {
99+ desktopName = name ;
100+ } ) ;
101+ writeFileSyncMock . mockImplementation ( ( path : string , contents : string ) => {
102+ if ( path === "/xdg/applications/com.t3tools.T3Code.desktop" ) desktopEntry = contents ;
103+ } ) ;
104104
105- return Effect . scoped (
106- Effect . gen ( function * ( ) {
107- const portalIdentity = Promise . resolve ( ) . then ( ( ) => ( {
108- desktopName,
109- desktopEntry,
110- iconInstalled,
111- } ) ) ;
112- yield * Layer . build (
113- DesktopPreReadyPlatform . layer . pipe (
114- Layer . provide ( Layer . succeed ( HostProcessPlatform , "linux" ) ) ,
115- ) ,
116- ) ;
117- const identity = yield * Effect . promise ( ( ) => portalIdentity ) ;
118- assert . equal ( identity . desktopName , "com.t3tools.T3Code.desktop" ) ;
119- assert . include ( identity . desktopEntry ?? "" , 'Exec="/Applications/current.AppImage" %U' ) ;
120- assert . include ( identity . desktopEntry ?? "" , "Name=T3 Code (Alpha)" ) ;
121- assert . include ( identity . desktopEntry ?? "" , "MimeType=x-scheme-handler/t3code;" ) ;
122- assert . include (
123- identity . desktopEntry ?? "" ,
124- "Icon=/xdg/icons/com.t3tools.T3Code.desktop.png" ,
125- ) ;
126- assert . isTrue ( identity . iconInstalled ) ;
127- } ) ,
128- ) . pipe ( Effect . ensuring ( Effect . sync ( ( ) => vi . unstubAllEnvs ( ) ) ) ) ;
129- } ,
130- ) ;
131- }
105+ return Effect . scoped (
106+ Effect . gen ( function * ( ) {
107+ const portalIdentity = Promise . resolve ( ) . then ( ( ) => ( {
108+ desktopName,
109+ desktopEntry,
110+ iconInstalled,
111+ } ) ) ;
112+ yield * Layer . build (
113+ DesktopPreReadyPlatform . layer . pipe (
114+ Layer . provide ( Layer . succeed ( HostProcessPlatform , "linux" ) ) ,
115+ ) ,
116+ ) ;
117+ const identity = yield * Effect . promise ( ( ) => portalIdentity ) ;
118+ assert . equal ( identity . desktopName , "com.t3tools.T3Code.desktop" ) ;
119+ assert . include ( identity . desktopEntry ?? "" , 'Exec="/Applications/current.AppImage" %U' ) ;
120+ assert . include ( identity . desktopEntry ?? "" , "Name=T3 Code (Alpha)" ) ;
121+ assert . include ( identity . desktopEntry ?? "" , "MimeType=x-scheme-handler/t3code;" ) ;
122+ assert . include (
123+ identity . desktopEntry ?? "" ,
124+ "Icon=/xdg/icons/com.t3tools.T3Code.desktop.png" ,
125+ ) ;
126+ assert . isTrue ( identity . iconInstalled ) ;
127+ } ) ,
128+ ) . pipe ( Effect . ensuring ( Effect . sync ( ( ) => vi . unstubAllEnvs ( ) ) ) ) ;
129+ } ) ;
132130
133131 it . effect ( "keeps startup available when the early desktop entry cannot be written" , ( ) => {
134132 getSwitchValueMock . mockReturnValue ( "" ) ;
0 commit comments