aboutsummaryrefslogtreecommitdiffstats
path: root/packages/main/src/controllers/__tests__
diff options
context:
space:
mode:
Diffstat (limited to 'packages/main/src/controllers/__tests__')
-rw-r--r--packages/main/src/controllers/__tests__/initConfig.spec.ts20
-rw-r--r--packages/main/src/controllers/__tests__/initNativeTheme.spec.ts8
2 files changed, 21 insertions, 7 deletions
diff --git a/packages/main/src/controllers/__tests__/initConfig.spec.ts b/packages/main/src/controllers/__tests__/initConfig.spec.ts
index e386a07..7b6d6ab 100644
--- a/packages/main/src/controllers/__tests__/initConfig.spec.ts
+++ b/packages/main/src/controllers/__tests__/initConfig.spec.ts
@@ -60,8 +60,12 @@ describe('when initializing', () => {
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 () => {
63 mocked(persistenceService.writeConfig).mockRejectedValue(new Error('boo')); 63 mocked(persistenceService.writeConfig).mockRejectedValue(
64 await expect(() => initConfig(config, persistenceService)).rejects.toBeInstanceOf(Error); 64 new Error('boo'),
65 );
66 await expect(() =>
67 initConfig(config, persistenceService),
68 ).rejects.toBeInstanceOf(Error);
65 }); 69 });
66 }); 70 });
67 71
@@ -85,7 +89,9 @@ describe('when initializing', () => {
85 mocked(persistenceService.watchConfig).mockImplementationOnce(() => { 89 mocked(persistenceService.watchConfig).mockImplementationOnce(() => {
86 throw new Error('boo'); 90 throw new Error('boo');
87 }); 91 });
88 await expect(() => initConfig(config, persistenceService)).rejects.toBeInstanceOf(Error); 92 await expect(() =>
93 initConfig(config, persistenceService),
94 ).rejects.toBeInstanceOf(Error);
89 }); 95 });
90 }); 96 });
91 97
@@ -102,7 +108,9 @@ describe('when initializing', () => {
102 108
103 it('should bail if it cannot determine whether there is a config file', async () => { 109 it('should bail if it cannot determine whether there is a config file', async () => {
104 mocked(persistenceService.readConfig).mockRejectedValue(new Error('boo')); 110 mocked(persistenceService.readConfig).mockRejectedValue(new Error('boo'));
105 await expect(() => initConfig(config, persistenceService)).rejects.toBeInstanceOf(Error); 111 await expect(() =>
112 initConfig(config, persistenceService),
113 ).rejects.toBeInstanceOf(Error);
106 }); 114 });
107}); 115});
108 116
@@ -118,7 +126,9 @@ describe('when it has loaded the config', () => {
118 }); 126 });
119 mocked(persistenceService.watchConfig).mockReturnValueOnce(watcherDisposer); 127 mocked(persistenceService.watchConfig).mockReturnValueOnce(watcherDisposer);
120 sutDisposer = await initConfig(config, persistenceService, throttleMs); 128 sutDisposer = await initConfig(config, persistenceService, throttleMs);
121 [[configChangedCallback]] = mocked(persistenceService.watchConfig).mock.calls; 129 [[configChangedCallback]] = mocked(
130 persistenceService.watchConfig,
131 ).mock.calls;
122 jest.resetAllMocks(); 132 jest.resetAllMocks();
123 }); 133 });
124 134
diff --git a/packages/main/src/controllers/__tests__/initNativeTheme.spec.ts b/packages/main/src/controllers/__tests__/initNativeTheme.spec.ts
index bd33f48..d4068af 100644
--- a/packages/main/src/controllers/__tests__/initNativeTheme.spec.ts
+++ b/packages/main/src/controllers/__tests__/initNativeTheme.spec.ts
@@ -58,14 +58,18 @@ it('should synchronize themeSource changes to the nativeTheme', () => {
58}); 58});
59 59
60it('should synchronize shouldUseDarkColors changes to the store', () => { 60it('should synchronize shouldUseDarkColors changes to the store', () => {
61 const listener = mocked(nativeTheme.on).mock.calls.find(([event]) => event === 'updated')![1]; 61 const listener = mocked(nativeTheme.on).mock.calls.find(
62 ([event]) => event === 'updated',
63 )![1];
62 shouldUseDarkColors = true; 64 shouldUseDarkColors = true;
63 listener(); 65 listener();
64 expect(store.shared.shouldUseDarkColors).toBe(true); 66 expect(store.shared.shouldUseDarkColors).toBe(true);
65}); 67});
66 68
67it('should remove the listener on dispose', () => { 69it('should remove the listener on dispose', () => {
68 const listener = mocked(nativeTheme.on).mock.calls.find(([event]) => event === 'updated')![1]; 70 const listener = mocked(nativeTheme.on).mock.calls.find(
71 ([event]) => event === 'updated',
72 )![1];
69 disposeSut(); 73 disposeSut();
70 expect(nativeTheme.off).toBeCalledWith('updated', listener); 74 expect(nativeTheme.off).toBeCalledWith('updated', listener);
71}); 75});