@@ -16,6 +16,9 @@ import {
16
16
import { getOrCreateMainWindow , mainIsReady } from '../../src/main/windows' ;
17
17
import { overridePlatform , resetPlatform } from '../utils' ;
18
18
19
+ type OpenUrlCallback = ( event : object , url : string ) => void ;
20
+ type SecondInstanceCallback = ( event : object , argv : string [ ] ) => void ;
21
+
19
22
jest . mock ( 'node:fs' ) ;
20
23
21
24
describe ( 'protocol' , ( ) => {
@@ -49,7 +52,7 @@ describe('protocol', () => {
49
52
50
53
listenForProtocolHandler ( ) ;
51
54
52
- const handler = mocked ( app . on ) . mock . calls [ 1 ] [ 1 ] ;
55
+ const handler : SecondInstanceCallback = mocked ( app . on ) . mock . calls [ 1 ] [ 1 ] ;
53
56
54
57
handler ( { } , [ 'electron-fiddle://gist/hi' ] ) ;
55
58
expect ( ipcMainManager . send ) . toHaveBeenCalledWith (
@@ -63,7 +66,7 @@ describe('protocol', () => {
63
66
64
67
listenForProtocolHandler ( ) ;
65
68
66
- const handler = mocked ( app . on ) . mock . calls [ 0 ] [ 1 ] ;
69
+ const handler : OpenUrlCallback = mocked ( app . on ) . mock . calls [ 0 ] [ 1 ] ;
67
70
68
71
handler ( { } , 'electron-fiddle://gist/hi' ) ;
69
72
expect ( ipcMainManager . send ) . toHaveBeenCalledWith (
@@ -77,7 +80,7 @@ describe('protocol', () => {
77
80
78
81
listenForProtocolHandler ( ) ;
79
82
80
- const handler = mocked ( app . on ) . mock . calls [ 0 ] [ 1 ] ;
83
+ const handler : OpenUrlCallback = mocked ( app . on ) . mock . calls [ 0 ] [ 1 ] ;
81
84
82
85
handler ( { } , 'electron-fiddle://gist/username/gistID' ) ;
83
86
expect ( ipcMainManager . send ) . toHaveBeenCalledWith (
@@ -91,7 +94,7 @@ describe('protocol', () => {
91
94
92
95
listenForProtocolHandler ( ) ;
93
96
94
- const handler = mocked ( app . on ) . mock . calls [ 0 ] [ 1 ] ;
97
+ const handler : OpenUrlCallback = mocked ( app . on ) . mock . calls [ 0 ] [ 1 ] ;
95
98
96
99
handler ( { } , 'electron-fiddle://noop' ) ;
97
100
handler ( { } , 'electron-fiddle://gist/noop/noop/null' ) ;
@@ -117,7 +120,7 @@ describe('protocol', () => {
117
120
118
121
listenForProtocolHandler ( ) ;
119
122
120
- const handler = mocked ( app . on ) . mock . calls [ 0 ] [ 1 ] ;
123
+ const handler : OpenUrlCallback = mocked ( app . on ) . mock . calls [ 0 ] [ 1 ] ;
121
124
handler ( { } , 'electron-fiddle://gist/hi-ready' ) ;
122
125
123
126
expect ( ipcMainManager . send ) . toHaveBeenCalledTimes ( 0 ) ;
@@ -138,7 +141,7 @@ describe('protocol', () => {
138
141
// electron-fiddle://electron/{tag}/{path}
139
142
listenForProtocolHandler ( ) ;
140
143
141
- const handler = mocked ( app . on ) . mock . calls [ 0 ] [ 1 ] ;
144
+ const handler : OpenUrlCallback = mocked ( app . on ) . mock . calls [ 0 ] [ 1 ] ;
142
145
143
146
handler ( { } , 'electron-fiddle://electron/v4.0.0/test/path' ) ;
144
147
@@ -156,7 +159,7 @@ describe('protocol', () => {
156
159
it ( 'handles a flawed electron path url' , ( ) => {
157
160
listenForProtocolHandler ( ) ;
158
161
159
- const handler = mocked ( app . on ) . mock . calls [ 0 ] [ 1 ] ;
162
+ const handler : OpenUrlCallback = mocked ( app . on ) . mock . calls [ 0 ] [ 1 ] ;
160
163
handler ( { } , 'electron-fiddle://electron/v4.0.0' ) ;
161
164
162
165
expect ( ipcMainManager . send ) . toHaveBeenCalledTimes ( 0 ) ;
@@ -165,7 +168,7 @@ describe('protocol', () => {
165
168
it ( 'handles a flawed url (unclear instruction)' , ( ) => {
166
169
listenForProtocolHandler ( ) ;
167
170
168
- const handler = mocked ( app . on ) . mock . calls [ 0 ] [ 1 ] ;
171
+ const handler : OpenUrlCallback = mocked ( app . on ) . mock . calls [ 0 ] [ 1 ] ;
169
172
handler ( { } , 'electron-fiddle://noop/123' ) ;
170
173
171
174
expect ( ipcMainManager . send ) . toHaveBeenCalledTimes ( 0 ) ;
@@ -174,7 +177,7 @@ describe('protocol', () => {
174
177
it ( 'handles a flawed url (no instruction)' , ( ) => {
175
178
listenForProtocolHandler ( ) ;
176
179
177
- const handler = mocked ( app . on ) . mock . calls [ 0 ] [ 1 ] ;
180
+ const handler : OpenUrlCallback = mocked ( app . on ) . mock . calls [ 0 ] [ 1 ] ;
178
181
handler ( { } , 'electron-fiddle://' ) ;
179
182
180
183
expect ( ipcMainManager . send ) . toHaveBeenCalledTimes ( 0 ) ;
@@ -185,7 +188,7 @@ describe('protocol', () => {
185
188
listenForProtocolHandler ( ) ;
186
189
187
190
const mainWindow = await getOrCreateMainWindow ( ) ;
188
- const handler = mocked ( app . on ) . mock . calls [ 0 ] [ 1 ] ;
191
+ const handler : OpenUrlCallback = mocked ( app . on ) . mock . calls [ 0 ] [ 1 ] ;
189
192
190
193
handler ( { } , 'electron-fiddle://electron/v4.0.0/test/path' ) ;
191
194
0 commit comments