@@ -35,10 +35,11 @@ import * as path from 'path';
3535
3636import { CommandServiceImpl , CommandServiceInstance } from '@bfemulator/sdk-shared' ;
3737import { SharedConstants } from '@bfemulator/app-shared' ;
38- import { systemPreferences } from 'electron' ;
38+ import { nativeTheme } from 'electron' ;
3939
4040import { emulatorApplication } from './main' ;
4141
42+ let mockShouldUseInvertedColorScheme = true ;
4243jest . mock ( 'electron' , ( ) => ( {
4344 app : {
4445 on : ( ) => void 0 ,
@@ -72,6 +73,12 @@ jest.mock('electron', () => ({
7273 on : jest . fn ( ( ) => null ) ,
7374 onInvertedColorSchemeChanged : jest . fn ( ( ) => true ) ,
7475 } ,
76+ nativeTheme : {
77+ on : jest . fn ( ( ) => null ) ,
78+ get shouldUseInvertedColorScheme ( ) {
79+ return mockShouldUseInvertedColorScheme ;
80+ } ,
81+ } ,
7582} ) ) ;
7683
7784jest . mock ( './server/webSocketServer' , ( ) => ( {
@@ -89,18 +96,19 @@ describe('main', () => {
8996 const decorator = CommandServiceInstance ( ) ;
9097 const descriptor = decorator ( { descriptor : { } } , 'none' ) as any ;
9198 commandService = descriptor . descriptor . get ( ) ;
99+ mockShouldUseInvertedColorScheme = true ;
92100 } ) ;
93101
94102 afterEach ( ( ) => {
95103 emulatorAppSpy . mockClear ( ) ;
96104 } ) ;
97105
98- it ( 'should call `onInvertedColorSchemeChanged` when `inverted-color-scheme-changed ` event is triggered' , ( ) => {
99- const onSpy = jest . spyOn ( systemPreferences , 'on' ) ;
106+ it ( 'should call `onInvertedColorSchemeChanged` when `updated ` event is triggered' , ( ) => {
107+ const onSpy = jest . spyOn ( nativeTheme , 'on' ) ;
100108
101109 ( emulatorApplication as any ) . initializeSystemPreferencesListeners ( ) ;
102110
103- expect ( onSpy ) . toHaveBeenCalledWith ( 'inverted-color-scheme-changed ' , jasmine . any ( Function ) ) ;
111+ expect ( onSpy ) . toHaveBeenCalledWith ( 'updated ' , jasmine . any ( Function ) ) ;
104112
105113 onSpy . mockClear ( ) ;
106114 } ) ;
@@ -123,7 +131,7 @@ describe('main', () => {
123131 it ( 'should not change to high contrast when theme is not high contrast' , ( ) => {
124132 const commandServiceSpy = jest . spyOn ( commandService , 'remoteCall' ) ;
125133
126- ( systemPreferences . isInvertedColorScheme as any ) . mockImplementationOnce ( ( ) => false ) ;
134+ mockShouldUseInvertedColorScheme = false ;
127135
128136 ( emulatorApplication as any ) . onInvertedColorSchemeChanged ( ) ;
129137
0 commit comments