@@ -84,7 +84,7 @@ describe('boards-data-store', function () {
84
84
it ( 'should update board details of selected board (selected with FQBN)' , async ( ) => {
85
85
const updated = boardsServiceProvider . updateConfig ( board ) ;
86
86
expect ( updated ) . to . be . ok ;
87
- await wait ( 50 ) ;
87
+ await wait ( 1 ) ;
88
88
89
89
const selectedBoardData = boardsDataStore [ '_selectedBoardData' ] ;
90
90
expect ( selectedBoardData ) . to . be . deep . equal ( {
@@ -102,7 +102,7 @@ describe('boards-data-store', function () {
102
102
const board = { name, fqbn } ;
103
103
const updated = boardsServiceProvider . updateConfig ( board ) ;
104
104
expect ( updated ) . to . ok ;
105
- await wait ( 50 ) ;
105
+ await wait ( 1 ) ;
106
106
107
107
const selectedBoardData = boardsDataStore [ '_selectedBoardData' ] ;
108
108
expect ( selectedBoardData ) . to . be . undefined ;
@@ -111,7 +111,7 @@ describe('boards-data-store', function () {
111
111
it ( 'should unset the the board details of selected board when no board was selected' , async ( ) => {
112
112
let updated = boardsServiceProvider . updateConfig ( board ) ;
113
113
expect ( updated ) . to . ok ;
114
- await wait ( 50 ) ;
114
+ await wait ( 1 ) ;
115
115
116
116
let selectedBoardData = boardsDataStore [ '_selectedBoardData' ] ;
117
117
expect ( selectedBoardData ) . to . be . deep . equal ( {
@@ -124,18 +124,18 @@ describe('boards-data-store', function () {
124
124
125
125
updated = boardsServiceProvider . updateConfig ( 'unset-board' ) ;
126
126
expect ( updated ) . to . be . true ;
127
- await wait ( 50 ) ;
127
+ await wait ( 1 ) ;
128
128
129
129
selectedBoardData = boardsDataStore [ '_selectedBoardData' ] ;
130
130
expect ( selectedBoardData ) . to . be . undefined ;
131
131
} ) ;
132
132
133
133
it ( 'should provide startup tasks when the data is available for the selected board' , async ( ) => {
134
- const updated = boardsServiceProvider . updateConfig ( board ) ;
134
+ let updated = boardsServiceProvider . updateConfig ( board ) ;
135
135
expect ( updated ) . to . be . true ;
136
- await wait ( 50 ) ;
136
+ await wait ( 1 ) ;
137
137
138
- const tasks = boardsDataStore . tasks ( ) ;
138
+ let tasks = boardsDataStore . tasks ( ) ;
139
139
expect ( tasks ) . to . be . deep . equal ( [
140
140
{
141
141
command : 'arduino-use-inherited-boards-data' ,
@@ -150,13 +150,156 @@ describe('boards-data-store', function () {
150
150
] ,
151
151
} ,
152
152
] ) ;
153
+
154
+ updated = boardsServiceProvider . updateConfig ( 'unset-board' ) ;
155
+ expect ( updated ) . to . be . true ;
156
+ await wait ( 1 ) ;
157
+
158
+ tasks = boardsDataStore . tasks ( ) ;
159
+ expect ( tasks ) . to . be . empty ;
153
160
} ) ;
154
161
155
162
it ( 'should not provide any startup tasks when no data is available for the selected board' , async ( ) => {
156
163
const tasks = boardsDataStore . tasks ( ) ;
157
164
expect ( tasks ) . to . be . empty ;
158
165
} ) ;
159
166
167
+ it ( 'should update the startup task arg when the selected programmer changes' , async ( ) => {
168
+ let tasks = boardsDataStore . tasks ( ) ;
169
+ expect ( tasks ) . to . be . empty ;
170
+
171
+ let data = await boardsDataStore . getData ( fqbn ) ;
172
+ expect ( data ) . to . be . deep . equal ( {
173
+ configOptions : [ configOption1 ] ,
174
+ programmers : [ edbg , jlink ] ,
175
+ } ) ;
176
+
177
+ const updated = boardsServiceProvider . updateConfig ( board ) ;
178
+ expect ( updated ) . to . be . ok ;
179
+ await wait ( 1 ) ;
180
+
181
+ tasks = boardsDataStore . tasks ( ) ;
182
+ expect ( tasks ) . to . be . deep . equal ( [
183
+ {
184
+ command : 'arduino-use-inherited-boards-data' ,
185
+ args : [
186
+ {
187
+ fqbn,
188
+ data : {
189
+ configOptions : [ configOption1 ] ,
190
+ programmers : [ edbg , jlink ] ,
191
+ } ,
192
+ } ,
193
+ ] ,
194
+ } ,
195
+ ] ) ;
196
+
197
+ const result = await boardsDataStore . selectProgrammer ( {
198
+ fqbn,
199
+ selectedProgrammer : edbg ,
200
+ } ) ;
201
+ expect ( result ) . to . be . ok ;
202
+
203
+ data = await boardsDataStore . getData ( fqbn ) ;
204
+ expect ( data ) . to . be . deep . equal ( {
205
+ configOptions : [ configOption1 ] ,
206
+ programmers : [ edbg , jlink ] ,
207
+ selectedProgrammer : edbg ,
208
+ } ) ;
209
+ tasks = boardsDataStore . tasks ( ) ;
210
+ expect ( tasks ) . to . be . deep . equal ( [
211
+ {
212
+ command : 'arduino-use-inherited-boards-data' ,
213
+ args : [
214
+ {
215
+ fqbn,
216
+ data : {
217
+ configOptions : [ configOption1 ] ,
218
+ programmers : [ edbg , jlink ] ,
219
+ selectedProgrammer : edbg ,
220
+ } ,
221
+ } ,
222
+ ] ,
223
+ } ,
224
+ ] ) ;
225
+ } ) ;
226
+
227
+ it ( 'should update the startup task arg when the config options change' , async ( ) => {
228
+ let tasks = boardsDataStore . tasks ( ) ;
229
+ expect ( tasks ) . to . be . empty ;
230
+
231
+ let data = await boardsDataStore . getData ( fqbn ) ;
232
+ expect ( data ) . to . be . deep . equal ( {
233
+ configOptions : [ configOption1 ] ,
234
+ programmers : [ edbg , jlink ] ,
235
+ } ) ;
236
+
237
+ const updated = boardsServiceProvider . updateConfig ( board ) ;
238
+ expect ( updated ) . to . be . ok ;
239
+ await wait ( 1 ) ;
240
+
241
+ tasks = boardsDataStore . tasks ( ) ;
242
+ expect ( tasks ) . to . be . deep . equal ( [
243
+ {
244
+ command : 'arduino-use-inherited-boards-data' ,
245
+ args : [
246
+ {
247
+ fqbn,
248
+ data : {
249
+ configOptions : [ configOption1 ] ,
250
+ programmers : [ edbg , jlink ] ,
251
+ } ,
252
+ } ,
253
+ ] ,
254
+ } ,
255
+ ] ) ;
256
+
257
+ const result = await boardsDataStore . selectConfigOption ( {
258
+ fqbn,
259
+ option : configOption1 . option ,
260
+ selectedValue : configOption1 . values [ 1 ] . value ,
261
+ } ) ;
262
+ expect ( result ) . to . be . ok ;
263
+
264
+ data = await boardsDataStore . getData ( fqbn ) ;
265
+ expect ( data ) . to . be . deep . equal ( {
266
+ configOptions : [
267
+ {
268
+ ...configOption1 ,
269
+ values : [
270
+ { label : 'C1V1' , selected : false , value : 'v1' } ,
271
+ { label : 'C1V2' , selected : true , value : 'v2' } ,
272
+ ] ,
273
+ } ,
274
+ ] ,
275
+ programmers : [ edbg , jlink ] ,
276
+ } ) ;
277
+
278
+ tasks = boardsDataStore . tasks ( ) ;
279
+ expect ( tasks ) . to . be . deep . equal ( [
280
+ {
281
+ command : 'arduino-use-inherited-boards-data' ,
282
+ args : [
283
+ {
284
+ fqbn,
285
+ data : {
286
+ configOptions : [
287
+ {
288
+ ...configOption1 ,
289
+ values : [
290
+ { label : 'C1V1' , selected : false , value : 'v1' } ,
291
+ { label : 'C1V2' , selected : true , value : 'v2' } ,
292
+ ] ,
293
+ } ,
294
+ ] ,
295
+ programmers : [ edbg , jlink ] ,
296
+ } ,
297
+ } ,
298
+ ] ,
299
+ } ,
300
+ ] ) ;
301
+ } ) ;
302
+
160
303
it ( 'should select the default programmer' , async ( ) => {
161
304
const storedData = await getStoredData ( fqbn ) ;
162
305
expect ( storedData ) . to . be . undefined ;
@@ -349,7 +492,7 @@ describe('boards-data-store', function () {
349
492
boardsDataStore . onDidChange ( ( ) => didChangeCounter ++ )
350
493
) ;
351
494
notificationCenter . notifyPlatformDidInstall ( { item : boardsPackage } ) ;
352
- await wait ( 50 ) ;
495
+ await wait ( 1 ) ;
353
496
expect ( didChangeCounter ) . to . be . equal ( 0 ) ;
354
497
355
498
storedData = await getStoredData ( fqbn ) ;
@@ -369,7 +512,7 @@ describe('boards-data-store', function () {
369
512
boardsDataStore . onDidChange ( ( ) => didChangeCounter ++ )
370
513
) ;
371
514
notificationCenter . notifyPlatformDidInstall ( { item : boardsPackage } ) ;
372
- await wait ( 50 ) ;
515
+ await wait ( 1 ) ;
373
516
expect ( didChangeCounter ) . to . be . equal ( 1 ) ;
374
517
375
518
storedData = await getStoredData ( fqbn ) ;
@@ -402,7 +545,7 @@ describe('boards-data-store', function () {
402
545
boardsDataStore . onDidChange ( ( ) => didChangeCounter ++ )
403
546
) ;
404
547
notificationCenter . notifyPlatformDidInstall ( { item : boardsPackage } ) ;
405
- await wait ( 50 ) ;
548
+ await wait ( 1 ) ;
406
549
expect ( didChangeCounter ) . to . be . equal ( 1 ) ;
407
550
408
551
storedData = await boardsDataStore . getData ( fqbn ) ;
0 commit comments