aboutsummaryrefslogtreecommitdiffstats
path: root/packages/main/src/controllers/__tests__/initConfig.spec.ts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/main/src/controllers/__tests__/initConfig.spec.ts')
-rw-r--r--packages/main/src/controllers/__tests__/initConfig.spec.ts18
1 files changed, 9 insertions, 9 deletions
diff --git a/packages/main/src/controllers/__tests__/initConfig.spec.ts b/packages/main/src/controllers/__tests__/initConfig.spec.ts
index 7b6d6ab..9a5f85e 100644
--- a/packages/main/src/controllers/__tests__/initConfig.spec.ts
+++ b/packages/main/src/controllers/__tests__/initConfig.spec.ts
@@ -56,7 +56,7 @@ describe('when initializing', () => {
56 56
57 it('should create a new config file', async () => { 57 it('should create a new config file', async () => {
58 await initConfig(config, persistenceService); 58 await initConfig(config, persistenceService);
59 expect(persistenceService.writeConfig).toBeCalledTimes(1); 59 expect(persistenceService.writeConfig).toHaveBeenCalledTimes(1);
60 }); 60 });
61 61
62 it('should bail if there is an an error creating the config file', async () => { 62 it('should bail if there is an an error creating the config file', async () => {
@@ -81,7 +81,7 @@ describe('when initializing', () => {
81 81
82 it('should read the existing config file is there is one', async () => { 82 it('should read the existing config file is there is one', async () => {
83 await initConfig(config, persistenceService); 83 await initConfig(config, persistenceService);
84 expect(persistenceService.writeConfig).not.toBeCalled(); 84 expect(persistenceService.writeConfig).not.toHaveBeenCalled();
85 expect(config.themeSource).toBe('dark'); 85 expect(config.themeSource).toBe('dark');
86 }); 86 });
87 87
@@ -138,14 +138,14 @@ describe('when it has loaded the config', () => {
138 jest.advanceTimersByTime(lessThanThrottleMs); 138 jest.advanceTimersByTime(lessThanThrottleMs);
139 config.setThemeSource('light'); 139 config.setThemeSource('light');
140 jest.advanceTimersByTime(throttleMs); 140 jest.advanceTimersByTime(throttleMs);
141 expect(persistenceService.writeConfig).toBeCalledTimes(1); 141 expect(persistenceService.writeConfig).toHaveBeenCalledTimes(1);
142 }); 142 });
143 143
144 it('should handle config writing errors gracefully', () => { 144 it('should handle config writing errors gracefully', () => {
145 mocked(persistenceService.writeConfig).mockRejectedValue(new Error('boo')); 145 mocked(persistenceService.writeConfig).mockRejectedValue(new Error('boo'));
146 config.setThemeSource('dark'); 146 config.setThemeSource('dark');
147 jest.advanceTimersByTime(throttleMs); 147 jest.advanceTimersByTime(throttleMs);
148 expect(persistenceService.writeConfig).toBeCalledTimes(1); 148 expect(persistenceService.writeConfig).toHaveBeenCalledTimes(1);
149 }); 149 });
150 150
151 it('should read the config file when it has changed', async () => { 151 it('should read the config file when it has changed', async () => {
@@ -157,7 +157,7 @@ describe('when it has loaded the config', () => {
157 }); 157 });
158 await configChangedCallback(); 158 await configChangedCallback();
159 // Do not write back the changes we have just read. 159 // Do not write back the changes we have just read.
160 expect(persistenceService.writeConfig).not.toBeCalled(); 160 expect(persistenceService.writeConfig).not.toHaveBeenCalled();
161 expect(config.themeSource).toBe('dark'); 161 expect(config.themeSource).toBe('dark');
162 }); 162 });
163 163
@@ -172,9 +172,9 @@ describe('when it has loaded the config', () => {
172 expect(config.themeSource).not.toBe(-1); 172 expect(config.themeSource).not.toBe(-1);
173 }); 173 });
174 174
175 it('should handle config writing errors gracefully', async () => { 175 it('should handle config reading errors gracefully', async () => {
176 mocked(persistenceService.readConfig).mockRejectedValue(new Error('boo')); 176 mocked(persistenceService.readConfig).mockRejectedValue(new Error('boo'));
177 await configChangedCallback(); 177 await expect(configChangedCallback()).resolves.not.toThrow();
178 }); 178 });
179 179
180 describe('when it was disposed', () => { 180 describe('when it was disposed', () => {
@@ -183,13 +183,13 @@ describe('when it has loaded the config', () => {
183 }); 183 });
184 184
185 it('should dispose the watcher', () => { 185 it('should dispose the watcher', () => {
186 expect(watcherDisposer).toBeCalled(); 186 expect(watcherDisposer).toHaveBeenCalled();
187 }); 187 });
188 188
189 it('should not listen to store changes any more', () => { 189 it('should not listen to store changes any more', () => {
190 config.setThemeSource('dark'); 190 config.setThemeSource('dark');
191 jest.advanceTimersByTime(2 * throttleMs); 191 jest.advanceTimersByTime(2 * throttleMs);
192 expect(persistenceService.writeConfig).not.toBeCalled(); 192 expect(persistenceService.writeConfig).not.toHaveBeenCalled();
193 }); 193 });
194 }); 194 });
195}); 195});