@@ -15,6 +15,17 @@ vi.mock('electron', () => ({
1515vi . mock ( 'electron-updater' , ( ) => ( {
1616 default : {
1717 autoUpdater : {
18+ _channel : null as string | null ,
19+ get channel ( ) : string | null {
20+ return this . _channel
21+ } ,
22+ set channel ( value : string | null ) {
23+ if ( this . _channel !== null ) {
24+ if ( typeof value !== 'string' ) throw new Error ( `Channel must be a string, but got: ${ String ( value ) } ` )
25+ if ( value . length === 0 ) throw new Error ( 'Channel must be not an empty string' )
26+ }
27+ this . _channel = value
28+ } ,
1829 on : vi . fn ( ) ,
1930 checkForUpdates : vi . fn ( ) ,
2031 downloadUpdate : vi . fn ( ( ) => Promise . resolve ( [ ] ) ) ,
@@ -58,7 +69,7 @@ afterEach(() => {
5869 autoUpdater . autoInstallOnAppQuit = undefined as unknown as boolean
5970 autoUpdater . allowPrerelease = undefined as unknown as boolean
6071 autoUpdater . allowDowngrade = undefined as unknown as boolean
61- autoUpdater . channel = null
72+ ; ( autoUpdater as unknown as { _channel : string | null } ) . _channel = null
6273} )
6374
6475function temporaryDirectory ( ) : string {
@@ -225,7 +236,7 @@ describe('strict update consent', () => {
225236 expect ( setLocalUpdateChannel ( 'nightly' ) ) . toMatchObject ( { channel : 'nightly' , status : 'idle' } )
226237 expect ( setLocalNotifyUpdate ( false ) ) . toMatchObject ( { notifyUpdate : false } )
227238 expect ( setLocalUpdateChannel ( 'stable' ) ) . toMatchObject ( { channel : 'stable' , status : 'idle' } )
228- expect ( localAutoUpdater . channel ) . toBeNull ( )
239+ expect ( localAutoUpdater . channel ) . toBe ( 'latest' )
229240 expect ( localAutoUpdater . allowPrerelease ) . toBe ( false )
230241 expect ( localAutoUpdater . allowDowngrade ) . toBe ( false )
231242 expect ( localAutoUpdater . autoDownload ) . toBe ( false )
0 commit comments