@@ -6,6 +6,7 @@ import * as server from '../utils/serverAPI';
66
77jest . mock ( '../utils/serverAPI' , ( ) => ( {
88 GET : jest . fn ( ) ,
9+ PATCH : jest . fn ( ) ,
910 api : {
1011 fetch : jest . fn ( ( elem , device ) => `/mock-api/${ elem } /${ device } ` ) ,
1112 } ,
@@ -19,17 +20,25 @@ jest.mock('../utils/serverAPI', () => ({
1920 } ,
2021 peripheralPath : jest . fn ( ( device , path ) => `/mock-api/peripheral/${ device } /${ path } ` ) ,
2122 attributes : jest . fn ( ( ) => '/mock-api/attributes' ) ,
23+ deviceInfo : jest . fn ( ( device ) => `/mock-api/device-info/${ device } ` ) , // Mock `deviceInfo`
2224} ) ) ;
2325
2426const TestComponent = ( ) => {
25- const { updateGlobalState, clockingState, peripherals, acpuNames, fetchAttributes, GetOptions } = useGlobalState ( ) ;
27+ const {
28+ updateGlobalState,
29+ clockingState,
30+ peripherals,
31+ acpuNames,
32+ fetchAttributes,
33+ GetOptions,
34+ } = useGlobalState ( ) ;
2635 const options = GetOptions ( 'mock-attribute' ) ;
2736
2837 return (
2938 < div >
3039 < div data-testid = "clocking-state" > { clockingState . join ( ', ' ) } </ div >
3140 < div data-testid = "peripherals-count" > { peripherals . length } </ div >
32- < div data-testid = "acpu-names" > { acpuNames . map ( acpu => acpu . text ) . join ( ', ' ) } </ div >
41+ < div data-testid = "acpu-names" > { acpuNames . map ( ( acpu ) => acpu . text ) . join ( ', ' ) } </ div >
3342 < button onClick = { ( ) => updateGlobalState ( 'mock-device' ) } > Update Global State</ button >
3443 < button onClick = { fetchAttributes } > Fetch Attributes</ button >
3544 < div data-testid = "options" > { options . join ( ', ' ) } </ div >
@@ -60,6 +69,8 @@ describe('GlobalStateProvider', () => {
6069 callback ( [ { href : '/mock-peripheral' , type : 'DMA' } ] ) ;
6170 } else if ( url . includes ( 'mock-peripheral' ) ) {
6271 callback ( { consumption : { messages : 'DMA Message' } , targets : 8 } ) ;
72+ } else if ( url . includes ( 'device-info' ) ) {
73+ callback ( { specification : { thermal : { } , power : { } } } ) ; // Mock device info response
6374 }
6475 } ) ;
6576
0 commit comments