@@ -13,6 +13,7 @@ import { createDownloadableTestApp } from '../../test/testFixtures';
13
13
import appCompatibilityWarning , {
14
14
checkEngineIsSupported ,
15
15
checkEngineVersionIsSet ,
16
+ checkJLinkRequirements ,
16
17
} from './appCompatibilityWarning' ;
17
18
18
19
const requiringEngine = ( engineVersion ?: string ) : LaunchableApp =>
@@ -105,6 +106,78 @@ describe('check compatibility of an app with the launcher', () => {
105
106
} ) ;
106
107
} ) ;
107
108
109
+ describe ( 'Check if the tested version of J-Link is installed' , ( ) => {
110
+ const app = ( nrfutilDeviceVersion : string ) =>
111
+ createDownloadableTestApp ( undefined , {
112
+ // @ts -expect-error -- Needs to be added to Installed in shared as `nrfutil?: NrfutilModules;`
113
+ nrfutil : { device : [ nrfutilDeviceVersion ] } ,
114
+ } ) ;
115
+
116
+ it ( `No installed J-Link as reported before nrfutil-device 2.7` , async ( ) => {
117
+ jest . mocked ( resolveModuleVersion ) . mockReturnValue ( undefined ) ;
118
+
119
+ expect (
120
+ await checkJLinkRequirements ( app ( '2.0.0' ) , '5.0.0' )
121
+ ) . toMatchObject (
122
+ failingCheck (
123
+ 'Required SEGGER J-Link not found: expected version V7.88j'
124
+ )
125
+ ) ;
126
+ } ) ;
127
+
128
+ it ( `No installed J-Link as reported since nrfutil-device 2.7` , async ( ) => {
129
+ // @ts -expect-error -- The type for dependencies still needs to be updated in shared
130
+ jest . mocked ( resolveModuleVersion ) . mockReturnValue ( {
131
+ expectedVersion : {
132
+ versionFormat : 'string' ,
133
+ version : 'JLink_V7.94i' ,
134
+ } ,
135
+ name : 'JlinkARM' ,
136
+ } ) ;
137
+
138
+ expect (
139
+ await checkJLinkRequirements ( app ( '2.0.1' ) , '5.0.0' )
140
+ ) . toMatchObject (
141
+ failingCheck (
142
+ 'Required SEGGER J-Link not found: expected version V7.88j'
143
+ )
144
+ ) ;
145
+ } ) ;
146
+
147
+ it ( `Wrong JLink version` , async ( ) => {
148
+ jest . mocked ( resolveModuleVersion ) . mockReturnValue ( {
149
+ expectedVersion : {
150
+ versionFormat : 'string' ,
151
+ version : 'JLink_V7.94i' ,
152
+ } ,
153
+ name : 'JlinkARM' ,
154
+ versionFormat : 'string' ,
155
+ version : 'JLink_V7.94e' ,
156
+ } ) ;
157
+
158
+ expect (
159
+ await checkJLinkRequirements ( app ( '2.0.2' ) , '5.0.0' )
160
+ ) . toMatchObject (
161
+ failingCheck (
162
+ 'Untested version V7.94e of SEGGER J-Link found: expected at least version V7.94i'
163
+ )
164
+ ) ;
165
+ } ) ;
166
+
167
+ it ( 'Calls resolveModuleVersion exactly once per version of nrfutil-device' , async ( ) => {
168
+ const mockedGetSandbox = jest
169
+ . mocked ( resolveModuleVersion )
170
+ . mockReset ( ) ;
171
+
172
+ await checkJLinkRequirements ( app ( '3.0.0' ) , '5.0.0' ) ;
173
+ await checkJLinkRequirements ( app ( '3.0.0' ) , '5.0.0' ) ;
174
+ await checkJLinkRequirements ( app ( '3.0.1' ) , '5.0.0' ) ;
175
+ await checkJLinkRequirements ( app ( '3.0.2' ) , '5.0.0' ) ;
176
+
177
+ expect ( mockedGetSandbox ) . toBeCalledTimes ( 3 ) ;
178
+ } ) ;
179
+ } ) ;
180
+
108
181
describe ( 'integrating all the checkes' , ( ) => {
109
182
describe ( 'some checks fails if' , ( ) => {
110
183
[
@@ -188,83 +261,5 @@ describe('check compatibility of an app with the launcher', () => {
188
261
}
189
262
) ;
190
263
} ) ;
191
-
192
- describe ( 'Jlink Tests' , ( ) => {
193
- const app = ( nrfutilDeviceVersion : string ) : LaunchableApp => ( {
194
- engineVersion : '5.0.0' ,
195
- source : '' ,
196
- latestVersion : 'v1.0.0' ,
197
- isWithdrawn : true ,
198
- name : 'name' ,
199
- displayName : '' ,
200
- iconPath : '' ,
201
- description : 'All versions are exactly as specified' ,
202
- currentVersion : 'v1.0.0' ,
203
- // @ts -expect-error -- Needs to be added to Installed in shared as `nrfutil?: NrfutilModules;`
204
- nrfutil : { device : [ nrfutilDeviceVersion ] } ,
205
- installed : { path : '' } ,
206
- } ) ;
207
-
208
- it ( `No installed J-Link as reported before nrfutil-device 2.7` , async ( ) => {
209
- jest . mocked ( resolveModuleVersion ) . mockReturnValue ( undefined ) ;
210
-
211
- expect (
212
- ( await appCompatibilityWarning ( app ( '2.0.0' ) , '5.0.0' ) )
213
- ?. warning
214
- ) . toBe (
215
- 'Required SEGGER J-Link not found: expected version V7.88j'
216
- ) ;
217
- } ) ;
218
-
219
- it ( `No installed J-Link as reported since nrfutil-device 2.7` , async ( ) => {
220
- // @ts -expect-error -- The type for dependencies still needs to be updated in shared
221
- jest . mocked ( resolveModuleVersion ) . mockReturnValue ( {
222
- expectedVersion : {
223
- versionFormat : 'string' ,
224
- version : 'JLink_V7.94i' ,
225
- } ,
226
- name : 'JlinkARM' ,
227
- } ) ;
228
-
229
- expect (
230
- ( await appCompatibilityWarning ( app ( '2.0.1' ) , '5.0.0' ) )
231
- ?. warning
232
- ) . toBe (
233
- 'Required SEGGER J-Link not found: expected version V7.88j'
234
- ) ;
235
- } ) ;
236
-
237
- it ( `Wrong JLink version` , async ( ) => {
238
- jest . mocked ( resolveModuleVersion ) . mockReturnValue ( {
239
- expectedVersion : {
240
- versionFormat : 'string' ,
241
- version : 'JLink_V7.94i' ,
242
- } ,
243
- name : 'JlinkARM' ,
244
- versionFormat : 'string' ,
245
- version : 'JLink_V7.94e' ,
246
- } ) ;
247
-
248
- expect (
249
- ( await appCompatibilityWarning ( app ( '2.0.2' ) , '5.0.0' ) )
250
- ?. warning
251
- ) . toBe (
252
- 'Untested version V7.94e of SEGGER J-Link found: expected at least version V7.94i'
253
- ) ;
254
- } ) ;
255
-
256
- it ( 'Calls resolveModuleVersion exactly once per version of nrfutil-device' , async ( ) => {
257
- const mockedGetSandbox = jest
258
- . mocked ( resolveModuleVersion )
259
- . mockReset ( ) ;
260
-
261
- await appCompatibilityWarning ( app ( '3.0.0' ) , '5.0.0' ) ;
262
- await appCompatibilityWarning ( app ( '3.0.0' ) , '5.0.0' ) ;
263
- await appCompatibilityWarning ( app ( '3.0.1' ) , '5.0.0' ) ;
264
- await appCompatibilityWarning ( app ( '3.0.2' ) , '5.0.0' ) ;
265
-
266
- expect ( mockedGetSandbox ) . toBeCalledTimes ( 3 ) ;
267
- } ) ;
268
- } ) ;
269
264
} ) ;
270
265
} ) ;
0 commit comments