diff options
Diffstat (limited to 'packages/main/src/reactions')
-rw-r--r-- | packages/main/src/reactions/__tests__/synchronizeConfig.test.ts (renamed from packages/main/src/reactions/__tests__/synchronizeConfig.spec.ts) | 30 | ||||
-rw-r--r-- | packages/main/src/reactions/__tests__/synchronizeNativeTheme.test.ts (renamed from packages/main/src/reactions/__tests__/synchronizeNativeTheme.spec.ts) | 8 |
2 files changed, 19 insertions, 19 deletions
diff --git a/packages/main/src/reactions/__tests__/synchronizeConfig.spec.ts b/packages/main/src/reactions/__tests__/synchronizeConfig.test.ts index 403a608..f0e88c1 100644 --- a/packages/main/src/reactions/__tests__/synchronizeConfig.spec.ts +++ b/packages/main/src/reactions/__tests__/synchronizeConfig.test.ts | |||
@@ -51,12 +51,12 @@ describe('when synchronizeializing', () => { | |||
51 | }); | 51 | }); |
52 | }); | 52 | }); |
53 | 53 | ||
54 | it('should create a new config file', async () => { | 54 | test('should create a new config file', async () => { |
55 | await synchronizeConfig(store, repository); | 55 | await synchronizeConfig(store, repository); |
56 | expect(repository.writeConfig).toHaveBeenCalledTimes(1); | 56 | expect(repository.writeConfig).toHaveBeenCalledTimes(1); |
57 | }); | 57 | }); |
58 | 58 | ||
59 | it('should bail if there is an an error creating the config file', async () => { | 59 | test('should bail if there is an an error creating the config file', async () => { |
60 | mocked(repository.writeConfig).mockRejectedValue(new Error('boo')); | 60 | mocked(repository.writeConfig).mockRejectedValue(new Error('boo')); |
61 | await expect(() => | 61 | await expect(() => |
62 | synchronizeConfig(store, repository), | 62 | synchronizeConfig(store, repository), |
@@ -76,13 +76,13 @@ describe('when synchronizeializing', () => { | |||
76 | }); | 76 | }); |
77 | }); | 77 | }); |
78 | 78 | ||
79 | it('should read the existing config file is there is one', async () => { | 79 | test('should read the existing config file is there is one', async () => { |
80 | await synchronizeConfig(store, repository); | 80 | await synchronizeConfig(store, repository); |
81 | expect(repository.writeConfig).not.toHaveBeenCalled(); | 81 | expect(repository.writeConfig).not.toHaveBeenCalled(); |
82 | expect(store.settings.themeSource).toBe('dark'); | 82 | expect(store.settings.themeSource).toBe('dark'); |
83 | }); | 83 | }); |
84 | 84 | ||
85 | it('should bail if it cannot set up a watcher', async () => { | 85 | test('should bail if it cannot set up a watcher', async () => { |
86 | mocked(repository.watchConfig).mockImplementationOnce(() => { | 86 | mocked(repository.watchConfig).mockImplementationOnce(() => { |
87 | throw new Error('boo'); | 87 | throw new Error('boo'); |
88 | }); | 88 | }); |
@@ -92,7 +92,7 @@ describe('when synchronizeializing', () => { | |||
92 | }); | 92 | }); |
93 | }); | 93 | }); |
94 | 94 | ||
95 | it('should update the config file if new details are added during read', async () => { | 95 | test('should update the config file if new details are added during read', async () => { |
96 | mocked(repository.readConfig).mockResolvedValueOnce({ | 96 | mocked(repository.readConfig).mockResolvedValueOnce({ |
97 | found: true, | 97 | found: true, |
98 | contents: `{ | 98 | contents: `{ |
@@ -109,7 +109,7 @@ describe('when synchronizeializing', () => { | |||
109 | expect(repository.writeConfig).toHaveBeenCalledTimes(1); | 109 | expect(repository.writeConfig).toHaveBeenCalledTimes(1); |
110 | }); | 110 | }); |
111 | 111 | ||
112 | it('should not apply an invalid config file but should not overwrite it', async () => { | 112 | test('should not apply an invalid config file but should not overwrite it', async () => { |
113 | mocked(repository.readConfig).mockResolvedValueOnce({ | 113 | mocked(repository.readConfig).mockResolvedValueOnce({ |
114 | found: true, | 114 | found: true, |
115 | contents: `{ | 115 | contents: `{ |
@@ -122,7 +122,7 @@ describe('when synchronizeializing', () => { | |||
122 | expect(repository.writeConfig).not.toHaveBeenCalled(); | 122 | expect(repository.writeConfig).not.toHaveBeenCalled(); |
123 | }); | 123 | }); |
124 | 124 | ||
125 | it('should bail if it cannot determine whether there is a config file', async () => { | 125 | test('should bail if it cannot determine whether there is a config file', async () => { |
126 | mocked(repository.readConfig).mockRejectedValue(new Error('boo')); | 126 | mocked(repository.readConfig).mockRejectedValue(new Error('boo')); |
127 | await expect(() => | 127 | await expect(() => |
128 | synchronizeConfig(store, repository), | 128 | synchronizeConfig(store, repository), |
@@ -146,7 +146,7 @@ describe('when it has loaded the config', () => { | |||
146 | jest.resetAllMocks(); | 146 | jest.resetAllMocks(); |
147 | }); | 147 | }); |
148 | 148 | ||
149 | it('should throttle saving changes to the config file', () => { | 149 | test('should throttle saving changes to the config file', () => { |
150 | mocked(repository.writeConfig).mockResolvedValue(); | 150 | mocked(repository.writeConfig).mockResolvedValue(); |
151 | store.settings.setThemeSource('dark'); | 151 | store.settings.setThemeSource('dark'); |
152 | jest.advanceTimersByTime(lessThanThrottleMs); | 152 | jest.advanceTimersByTime(lessThanThrottleMs); |
@@ -155,14 +155,14 @@ describe('when it has loaded the config', () => { | |||
155 | expect(repository.writeConfig).toHaveBeenCalledTimes(1); | 155 | expect(repository.writeConfig).toHaveBeenCalledTimes(1); |
156 | }); | 156 | }); |
157 | 157 | ||
158 | it('should handle config writing errors gracefully', () => { | 158 | test('should handle config writing errors gracefully', () => { |
159 | mocked(repository.writeConfig).mockRejectedValue(new Error('boo')); | 159 | mocked(repository.writeConfig).mockRejectedValue(new Error('boo')); |
160 | store.settings.setThemeSource('dark'); | 160 | store.settings.setThemeSource('dark'); |
161 | jest.advanceTimersByTime(throttleMs); | 161 | jest.advanceTimersByTime(throttleMs); |
162 | expect(repository.writeConfig).toHaveBeenCalledTimes(1); | 162 | expect(repository.writeConfig).toHaveBeenCalledTimes(1); |
163 | }); | 163 | }); |
164 | 164 | ||
165 | it('should read the config file when it has changed', async () => { | 165 | test('should read the config file when it has changed', async () => { |
166 | mocked(repository.readConfig).mockResolvedValueOnce({ | 166 | mocked(repository.readConfig).mockResolvedValueOnce({ |
167 | found: true, | 167 | found: true, |
168 | contents: serializeConfig({ | 168 | contents: serializeConfig({ |
@@ -177,7 +177,7 @@ describe('when it has loaded the config', () => { | |||
177 | expect(store.settings.themeSource).toBe('dark'); | 177 | expect(store.settings.themeSource).toBe('dark'); |
178 | }); | 178 | }); |
179 | 179 | ||
180 | it('should update the config file if new details are added', async () => { | 180 | test('should update the config file if new details are added', async () => { |
181 | mocked(repository.readConfig).mockResolvedValueOnce({ | 181 | mocked(repository.readConfig).mockResolvedValueOnce({ |
182 | found: true, | 182 | found: true, |
183 | contents: `{ | 183 | contents: `{ |
@@ -194,7 +194,7 @@ describe('when it has loaded the config', () => { | |||
194 | expect(repository.writeConfig).toHaveBeenCalledTimes(1); | 194 | expect(repository.writeConfig).toHaveBeenCalledTimes(1); |
195 | }); | 195 | }); |
196 | 196 | ||
197 | it('should not apply an invalid config file when it has changed but should not overwrite it', async () => { | 197 | test('should not apply an invalid config file when it has changed but should not overwrite it', async () => { |
198 | mocked(repository.readConfig).mockResolvedValueOnce({ | 198 | mocked(repository.readConfig).mockResolvedValueOnce({ |
199 | found: true, | 199 | found: true, |
200 | contents: `{ | 200 | contents: `{ |
@@ -207,7 +207,7 @@ describe('when it has loaded the config', () => { | |||
207 | expect(repository.writeConfig).not.toHaveBeenCalled(); | 207 | expect(repository.writeConfig).not.toHaveBeenCalled(); |
208 | }); | 208 | }); |
209 | 209 | ||
210 | it('should handle config reading errors gracefully', async () => { | 210 | test('should handle config reading errors gracefully', async () => { |
211 | mocked(repository.readConfig).mockRejectedValue(new Error('boo')); | 211 | mocked(repository.readConfig).mockRejectedValue(new Error('boo')); |
212 | await expect(configChangedCallback()).resolves.not.toThrow(); | 212 | await expect(configChangedCallback()).resolves.not.toThrow(); |
213 | }); | 213 | }); |
@@ -217,11 +217,11 @@ describe('when it has loaded the config', () => { | |||
217 | sutDisposer(); | 217 | sutDisposer(); |
218 | }); | 218 | }); |
219 | 219 | ||
220 | it('should dispose the watcher', () => { | 220 | test('should dispose the watcher', () => { |
221 | expect(watcherDisposer).toHaveBeenCalled(); | 221 | expect(watcherDisposer).toHaveBeenCalled(); |
222 | }); | 222 | }); |
223 | 223 | ||
224 | it('should not listen to store changes any more', () => { | 224 | test('should not listen to store changes any more', () => { |
225 | store.settings.setThemeSource('dark'); | 225 | store.settings.setThemeSource('dark'); |
226 | jest.advanceTimersByTime(2 * throttleMs); | 226 | jest.advanceTimersByTime(2 * throttleMs); |
227 | expect(repository.writeConfig).not.toHaveBeenCalled(); | 227 | expect(repository.writeConfig).not.toHaveBeenCalled(); |
diff --git a/packages/main/src/reactions/__tests__/synchronizeNativeTheme.spec.ts b/packages/main/src/reactions/__tests__/synchronizeNativeTheme.test.ts index cf37568..05f14fb 100644 --- a/packages/main/src/reactions/__tests__/synchronizeNativeTheme.spec.ts +++ b/packages/main/src/reactions/__tests__/synchronizeNativeTheme.test.ts | |||
@@ -50,16 +50,16 @@ beforeEach(() => { | |||
50 | disposeSut = synchronizeNativeTheme(store); | 50 | disposeSut = synchronizeNativeTheme(store); |
51 | }); | 51 | }); |
52 | 52 | ||
53 | it('should register a nativeTheme updated listener', () => { | 53 | test('should register a nativeTheme updated listener', () => { |
54 | expect(nativeTheme.on).toHaveBeenCalledWith('updated', expect.anything()); | 54 | expect(nativeTheme.on).toHaveBeenCalledWith('updated', expect.anything()); |
55 | }); | 55 | }); |
56 | 56 | ||
57 | it('should synchronize themeSource changes to the nativeTheme', () => { | 57 | test('should synchronize themeSource changes to the nativeTheme', () => { |
58 | store.settings.setThemeSource('dark'); | 58 | store.settings.setThemeSource('dark'); |
59 | expect(nativeTheme.themeSource).toBe('dark'); | 59 | expect(nativeTheme.themeSource).toBe('dark'); |
60 | }); | 60 | }); |
61 | 61 | ||
62 | it('should synchronize shouldUseDarkColors changes to the store', () => { | 62 | test('should synchronize shouldUseDarkColors changes to the store', () => { |
63 | const listener = mocked(nativeTheme.on).mock.calls.find( | 63 | const listener = mocked(nativeTheme.on).mock.calls.find( |
64 | ([event]) => event === 'updated', | 64 | ([event]) => event === 'updated', |
65 | )![1]; | 65 | )![1]; |
@@ -68,7 +68,7 @@ it('should synchronize shouldUseDarkColors changes to the store', () => { | |||
68 | expect(store.shouldUseDarkColors).toBe(true); | 68 | expect(store.shouldUseDarkColors).toBe(true); |
69 | }); | 69 | }); |
70 | 70 | ||
71 | it('should remove the listener on dispose', () => { | 71 | test('should remove the listener on dispose', () => { |
72 | const listener = mocked(nativeTheme.on).mock.calls.find( | 72 | const listener = mocked(nativeTheme.on).mock.calls.find( |
73 | ([event]) => event === 'updated', | 73 | ([event]) => event === 'updated', |
74 | )![1]; | 74 | )![1]; |