11// SPDX-License-Identifier: MIT
2- // Copyright (c) 2021-2024 The Pybricks Authors
2+ // Copyright (c) 2021-2025 The Pybricks Authors
33
44import { AnyAction } from 'redux' ;
55import {
@@ -44,8 +44,10 @@ test('initial state', () => {
4444 "hasRepl": false,
4545 "maxBleWriteSize": 0,
4646 "maxUserProgramSize": 0,
47+ "numOfSlots": 0,
4748 "preferredFileFormat": null,
4849 "runtime": "hub.runtime.disconnected",
50+ "selectedSlot": 0,
4951 "useLegacyDownload": false,
5052 "useLegacyStartUserProgram": false,
5153 "useLegacyStdio": false,
@@ -158,55 +160,55 @@ describe('runtime', () => {
158160 expect (
159161 reducers (
160162 { runtime : HubRuntimeState . Disconnected } as State ,
161- didReceiveStatusReport ( statusToFlag ( Status . UserProgramRunning ) , 0 ) ,
163+ didReceiveStatusReport ( statusToFlag ( Status . UserProgramRunning ) , 0 , 0 ) ,
162164 ) . runtime ,
163165 ) . toBe ( HubRuntimeState . Disconnected ) ;
164166
165167 // status update ignored while download not finished
166168 expect (
167169 reducers (
168170 { runtime : HubRuntimeState . Loading } as State ,
169- didReceiveStatusReport ( statusToFlag ( Status . UserProgramRunning ) , 0 ) ,
171+ didReceiveStatusReport ( statusToFlag ( Status . UserProgramRunning ) , 0 , 0 ) ,
170172 ) . runtime ,
171173 ) . toBe ( HubRuntimeState . Loading ) ;
172174
173175 // normal operation - user program started
174176 expect (
175177 reducers (
176178 { runtime : HubRuntimeState . Unknown } as State ,
177- didReceiveStatusReport ( statusToFlag ( Status . UserProgramRunning ) , 0 ) ,
179+ didReceiveStatusReport ( statusToFlag ( Status . UserProgramRunning ) , 0 , 0 ) ,
178180 ) . runtime ,
179181 ) . toBe ( HubRuntimeState . Running ) ;
180182
181183 // really short program run finished before receiving download finished
182184 expect (
183185 reducers (
184186 { runtime : HubRuntimeState . Unknown } as State ,
185- didReceiveStatusReport ( 0 , 0 ) ,
187+ didReceiveStatusReport ( 0 , 0 , 0 ) ,
186188 ) . runtime ,
187189 ) . toBe ( HubRuntimeState . Idle ) ;
188190
189191 // normal operation - user program stopped
190192 expect (
191193 reducers (
192194 { runtime : HubRuntimeState . Running } as State ,
193- didReceiveStatusReport ( 0 , 0 ) ,
195+ didReceiveStatusReport ( 0 , 0 , 0 ) ,
194196 ) . runtime ,
195197 ) . toBe ( HubRuntimeState . Idle ) ;
196198
197199 // ignored during start repl command
198200 expect (
199201 reducers (
200202 { runtime : HubRuntimeState . StartingRepl } as State ,
201- didReceiveStatusReport ( 0 , 0 ) ,
203+ didReceiveStatusReport ( 0 , 0 , 0 ) ,
202204 ) . runtime ,
203205 ) . toBe ( HubRuntimeState . StartingRepl ) ;
204206
205207 // ignored during stop user program command
206208 expect (
207209 reducers (
208210 { runtime : HubRuntimeState . StoppingUserProgram } as State ,
209- didReceiveStatusReport ( 0 , 0 ) ,
211+ didReceiveStatusReport ( 0 , 0 , 0 ) ,
210212 ) . runtime ,
211213 ) . toBe ( HubRuntimeState . StoppingUserProgram ) ;
212214 } ) ;
@@ -301,7 +303,7 @@ describe('maxBleWriteSize', () => {
301303 expect (
302304 reducers (
303305 { maxBleWriteSize : 0 } as State ,
304- blePybricksServiceDidReceiveHubCapabilities ( size , 0 , 100 ) ,
306+ blePybricksServiceDidReceiveHubCapabilities ( size , 0 , 100 , 0 ) ,
305307 ) . maxBleWriteSize ,
306308 ) . toBe ( size ) ;
307309 } ) ;
@@ -312,7 +314,7 @@ describe('maxUserProgramSize', () => {
312314 expect (
313315 reducers (
314316 { maxUserProgramSize : 0 } as State ,
315- blePybricksServiceDidReceiveHubCapabilities ( 23 , 0 , size ) ,
317+ blePybricksServiceDidReceiveHubCapabilities ( 23 , 0 , size , 0 ) ,
316318 ) . maxUserProgramSize ,
317319 ) . toBe ( size ) ;
318320 } ) ;
@@ -340,7 +342,7 @@ describe('hasRepl', () => {
340342 expect (
341343 reducers (
342344 { hasRepl : true } as State ,
343- blePybricksServiceDidReceiveHubCapabilities ( 23 , flag , 100 ) ,
345+ blePybricksServiceDidReceiveHubCapabilities ( 23 , flag , 100 , 0 ) ,
344346 ) . hasRepl ,
345347 ) . toBe ( Boolean ( flag & HubCapabilityFlag . HasRepl ) ) ;
346348 } ,
@@ -374,6 +376,7 @@ describe('preferredFileFormat', () => {
374376 23 ,
375377 HubCapabilityFlag . UserProgramMultiMpy6 ,
376378 100 ,
379+ 0 ,
377380 ) ,
378381 ) . preferredFileFormat ,
379382 ) . toBe ( FileFormat . MultiMpy6 ) ;
@@ -383,7 +386,7 @@ describe('preferredFileFormat', () => {
383386 expect (
384387 reducers (
385388 { preferredFileFormat : FileFormat . MultiMpy6 } as State ,
386- blePybricksServiceDidReceiveHubCapabilities ( 23 , 0 , 100 ) ,
389+ blePybricksServiceDidReceiveHubCapabilities ( 23 , 0 , 100 , 0 ) ,
387390 ) . preferredFileFormat ,
388391 ) . toBeNull ( ) ;
389392 } ) ;
@@ -403,7 +406,7 @@ describe('useLegacyDownload', () => {
403406 expect (
404407 reducers (
405408 { useLegacyDownload : true } as State ,
406- blePybricksServiceDidReceiveHubCapabilities ( 23 , 0 , 100 ) ,
409+ blePybricksServiceDidReceiveHubCapabilities ( 23 , 0 , 100 , 0 ) ,
407410 ) . useLegacyDownload ,
408411 ) . toBeFalsy ( ) ;
409412 } ) ;
0 commit comments