UNPKG

ev-recharge-sdk

Version:

This API Product provides the option to manage charging at all public Shell Recharge locations. The end points provides control to start, stop and get status of the charging session.

172 lines (137 loc) 4.89 kB
/** * Shell EVLib * * This file was automatically generated by APIMATIC v3.0 ( https://www.apimatic.io ). */ import { ActiveResponse200Json, ChargingController, GetChargeSessionRetrieveResponse200Json, GetChargeSessionRetrieveResponse200JsonStatusEnum, InlineResponse202, InlineResponse2021, } from '../src'; import { testClient } from './testClient'; import { expectHeadersToMatch, expectMatchingWithOptions, makeApiCall, } from './testHelper'; describe('ChargingController', () => { let controller : ChargingController; beforeAll(() => { controller = new ChargingController(testClient); }); it('should Test Start', async () => { const requestId = '123e4567-e89b-12d3-a456-426614174000'; const response = await makeApiCall( () => controller.start(requestId, undefined) ); expect(response.statusCode).toBe(200); const expectedHeaders = { 'Content-Type': ['application/json', true] }; expectHeadersToMatch(response.headers, expectedHeaders); const expected: InlineResponse202 = { requestId: '9d2dee33-7803-485a-a2b1-2c7538e597ee', status: GetChargeSessionRetrieveResponse200JsonStatusEnum.SUCCESS, data: [ { sessionId: 'c3e332f0-1bb2-4f50-a96b-e075bbb71e68', } ], }; expect(response.result).not.toBeNull(); expectMatchingWithOptions( expected, response.result, { allowExtra: true, isOrdered: false, checkValues: false } ); }); it('should Test Stop', async () => { const requestId = '123e4567-e89b-12d3-a456-426614174000'; const sessionId = 'c3e332f0-1bb2-4f50-a96b-e075bbb71e68'; const response = await makeApiCall( () => controller.stop(requestId, sessionId) ); expect(response.statusCode).toBe(200); const expectedHeaders = { 'Content-Type': ['application/json', true] }; expectHeadersToMatch(response.headers, expectedHeaders); const expected: InlineResponse2021 = { requestId: '9d2dee33-7803-485a-a2b1-2c7538e597ee', status: GetChargeSessionRetrieveResponse200JsonStatusEnum.SUCCESS, }; expect(response.result).not.toBeNull(); expectMatchingWithOptions( expected, response.result, { allowExtra: true, isOrdered: false, checkValues: false } ); }); it('should Test GetChargeSessionRetrieve', async () => { const requestId = '123e4567-e89b-12d3-a456-426614174000'; const sessionId = 'c3e332f0-1bb2-4f50-a96b-e075bbb71e68'; const response = await makeApiCall( () => controller.getChargeSessionRetrieve(requestId, sessionId) ); expect(response.statusCode).toBe(200); const expectedHeaders = { 'Content-Type': ['application/json', true] }; expectHeadersToMatch(response.headers, expectedHeaders); const expected: GetChargeSessionRetrieveResponse200Json = { requestId: '9d2dee33-7803-485a-a2b1-2c7538e597ee', status: GetChargeSessionRetrieveResponse200JsonStatusEnum.SUCCESS, data: [ { id: '78b5d7a3-bdba-43d7-9851-1c84fcddb782', userId: '281482b6-2c9a-4fd1-b3ea-1928edb40ef9', emaId: 'NL-TNM-C00122045-K', evseId: 'NL*TNM*E02003451*0', lastUpdated: '2024-06-19T07:36:57.985998Z', startedAt: '2024-06-19T11:20:27Z', stoppedAt: '2014-06-19T12:20:27Z', sessionState: { status: 'Started', }, } ], }; expect(response.result).not.toBeNull(); expectMatchingWithOptions( expected, response.result, { allowExtra: true, isOrdered: false, checkValues: false } ); }); it('should Test Active', async () => { const requestId = '123e4567-e89b-12d3-a456-426614174000'; const emaId = 'NL-TNM-C0216599X-A'; const response = await makeApiCall( () => controller.active(requestId, emaId) ); expect(response.statusCode).toBe(200); const expectedHeaders = { 'Content-Type': ['application/json', true] }; expectHeadersToMatch(response.headers, expectedHeaders); const expected: ActiveResponse200Json = { requestId: '9d2dee33-7803-485a-a2b1-2c7538e597ee', status: GetChargeSessionRetrieveResponse200JsonStatusEnum.SUCCESS, data: [ { id: '78b5d7a3-bdba-43d7-9851-1c84fcddb782', userId: '281482b6-2c9a-4fd1-b3ea-1928edb40ef9', emaId: 'NL-TNM-C00122045-K', evseId: 'NL*TNM*E02003451*0', startedAt: '2015-08-19T11:20:27Z', stoppedAt: '2015-08-19T11:20:27Z', sessionState: { status: 'Started', }, lastUpdated: '2024-07-17T07:36:57.985998Z', } ], }; expect(response.result).not.toBeNull(); expectMatchingWithOptions( expected, response.result, { allowExtra: true, isOrdered: false, checkValues: false } ); }); });