File tree Expand file tree Collapse file tree 2 files changed +5
-22
lines changed
Expand file tree Collapse file tree 2 files changed +5
-22
lines changed Original file line number Diff line number Diff line change 1- import { baseApi } from '../../../baseApi'
2- import ResponseParser from '../../../helpers/ResponseParser'
1+ import crud from '../../../crudOperations'
32
43const statusURL = 'v3/cmp/system/status'
54const settingsURL = 'v3/cmp/system/settings'
@@ -9,27 +8,11 @@ export default {
98 * Retrieve System Status to display on the System Status Widget
109 * @returns {Promise } API Response object of System Status objects
1110 */
12- status : async ( ) => {
13- try {
14- const response = await baseApi . get ( statusURL )
15- return response
16- } catch ( error ) {
17- const errMsg = ResponseParser . getErrorMessage ( error )
18- throw new Error ( errMsg )
19- }
20- } ,
11+ status : ( options ) => crud . getItemByEndpoint ( statusURL , options ) ,
2112
2213 /**
2314 * Retrieve System Settings to display on the System Settings Widget
2415 * @returns {Promise } API Response object of System Settings objects
2516 */
26- settings : async ( ) => {
27- try {
28- const response = await baseApi . get ( settingsURL )
29- return response
30- } catch ( error ) {
31- const errMsg = ResponseParser . getErrorMessage ( error )
32- throw new Error ( errMsg )
33- }
34- }
17+ settings : ( options ) => crud . getItemByEndpoint ( settingsURL , options )
3518}
Original file line number Diff line number Diff line change @@ -4,11 +4,11 @@ import SystemService from './SystemService'
44test ( 'status calls the correct endpoint' , async ( ) => {
55 const mockFn = jest . spyOn ( baseApi , 'get' ) . mockResolvedValue ( { } )
66 await SystemService . status ( )
7- expect ( mockFn ) . toHaveBeenCalledWith ( 'v3/cmp/system/status' )
7+ expect ( mockFn ) . toHaveBeenCalledWith ( '/ v3/cmp/system/status/ ' )
88} )
99
1010test ( 'settings calls the correct endpoint' , async ( ) => {
1111 const mockFn = jest . spyOn ( baseApi , 'get' ) . mockResolvedValue ( { } )
1212 await SystemService . settings ( )
13- expect ( mockFn ) . toHaveBeenCalledWith ( 'v3/cmp/system/settings' )
13+ expect ( mockFn ) . toHaveBeenCalledWith ( '/ v3/cmp/system/settings/ ' )
1414} )
You can’t perform that action at this time.
0 commit comments