diff options
author | Kristóf Marussy <kristof@marussy.com> | 2022-05-03 19:47:39 +0200 |
---|---|---|
committer | Kristóf Marussy <kristof@marussy.com> | 2022-05-16 00:55:02 +0200 |
commit | d2aa484b600dc0d122bb994b9bb29504ffe4cf12 (patch) | |
tree | 1d3e38fdb22f7afe02f1ebcf4b07734761970985 /packages/main/src/infrastructure/electron/impl/__tests__ | |
parent | refactor: config file saving and debugging (diff) | |
download | sophie-d2aa484b600dc0d122bb994b9bb29504ffe4cf12.tar.gz sophie-d2aa484b600dc0d122bb994b9bb29504ffe4cf12.tar.zst sophie-d2aa484b600dc0d122bb994b9bb29504ffe4cf12.zip |
build: integration testing support
Run integration tests in an electron environment for the main process.
Signed-off-by: Kristóf Marussy <kristof@marussy.com>
Diffstat (limited to 'packages/main/src/infrastructure/electron/impl/__tests__')
3 files changed, 10 insertions, 11 deletions
diff --git a/packages/main/src/infrastructure/electron/impl/__tests__/electron.integ.spec.ts b/packages/main/src/infrastructure/electron/impl/__tests__/electron.integ.spec.ts new file mode 100644 index 0000000..f6bd440 --- /dev/null +++ b/packages/main/src/infrastructure/electron/impl/__tests__/electron.integ.spec.ts | |||
@@ -0,0 +1,9 @@ | |||
1 | import { BrowserWindow } from 'electron'; | ||
2 | |||
3 | import '../ElectronMainWindow'; | ||
4 | |||
5 | it('should create a BrowserWindow', async () => { | ||
6 | const w = new BrowserWindow(); | ||
7 | await expect(w.loadURL('https://example.org')).resolves.toBeUndefined(); | ||
8 | w.close(); | ||
9 | }); | ||
diff --git a/packages/main/src/infrastructure/electron/impl/__tests__/hardenSession.spec.ts b/packages/main/src/infrastructure/electron/impl/__tests__/hardenSession.spec.ts index 7457729..ae10677 100644 --- a/packages/main/src/infrastructure/electron/impl/__tests__/hardenSession.spec.ts +++ b/packages/main/src/infrastructure/electron/impl/__tests__/hardenSession.spec.ts | |||
@@ -30,7 +30,6 @@ import type { | |||
30 | WebContents, | 30 | WebContents, |
31 | } from 'electron'; | 31 | } from 'electron'; |
32 | 32 | ||
33 | import { silenceLogger } from '../../../../utils/log'; | ||
34 | import type Resources from '../../../resources/Resources'; | 33 | import type Resources from '../../../resources/Resources'; |
35 | import hardenSession from '../hardenSession'; | 34 | import hardenSession from '../hardenSession'; |
36 | 35 | ||
@@ -90,10 +89,6 @@ const fakeSession = fake<Session>({ | |||
90 | }, | 89 | }, |
91 | }); | 90 | }); |
92 | 91 | ||
93 | beforeAll(() => { | ||
94 | silenceLogger(); | ||
95 | }); | ||
96 | |||
97 | beforeEach(() => { | 92 | beforeEach(() => { |
98 | permissionRequestHandler = undefined; | 93 | permissionRequestHandler = undefined; |
99 | onBeforeRequest = undefined; | 94 | onBeforeRequest = undefined; |
diff --git a/packages/main/src/infrastructure/electron/impl/__tests__/lockWebContentsToFile.spec.ts b/packages/main/src/infrastructure/electron/impl/__tests__/lockWebContentsToFile.spec.ts index 29c0516..f7bad0a 100644 --- a/packages/main/src/infrastructure/electron/impl/__tests__/lockWebContentsToFile.spec.ts +++ b/packages/main/src/infrastructure/electron/impl/__tests__/lockWebContentsToFile.spec.ts | |||
@@ -25,7 +25,6 @@ import { fake } from '@sophie/test-utils'; | |||
25 | import type { Event, HandlerDetails, WebContents } from 'electron'; | 25 | import type { Event, HandlerDetails, WebContents } from 'electron'; |
26 | import { mocked } from 'jest-mock'; | 26 | import { mocked } from 'jest-mock'; |
27 | 27 | ||
28 | import { silenceLogger } from '../../../../utils/log'; | ||
29 | import type Resources from '../../../resources/Resources'; | 28 | import type Resources from '../../../resources/Resources'; |
30 | import lockWebContentsToFile from '../lockWebContentsToFile'; | 29 | import lockWebContentsToFile from '../lockWebContentsToFile'; |
31 | 30 | ||
@@ -59,17 +58,13 @@ const fakeWebContents = fake<WebContents>({ | |||
59 | } | 58 | } |
60 | return this as WebContents; | 59 | return this as WebContents; |
61 | }, | 60 | }, |
62 | loadURL: jest.fn(), | 61 | loadURL: jest.fn<WebContents['loadURL']>(), |
63 | }); | 62 | }); |
64 | 63 | ||
65 | const event: Event = { | 64 | const event: Event = { |
66 | preventDefault: jest.fn(), | 65 | preventDefault: jest.fn(), |
67 | }; | 66 | }; |
68 | 67 | ||
69 | beforeAll(() => { | ||
70 | silenceLogger(); | ||
71 | }); | ||
72 | |||
73 | beforeEach(async () => { | 68 | beforeEach(async () => { |
74 | windowOpenHandler = undefined; | 69 | windowOpenHandler = undefined; |
75 | willNavigate = undefined; | 70 | willNavigate = undefined; |