@@ -4,11 +4,18 @@ import sandboxSdk from '@telefonica/opengateway-sandbox-sdk';
44import fs from 'fs' ;
55import path from 'path' ;
66
7- const { DeviceLocation, Simswap } = sandboxSdk ;
7+ const { DeviceLocation, Simswap, DeviceStatus , NumberVerification , QualityOnDemand , DeviceSwap , KnowYourCustomer , AgeVerification , Tenure } = sandboxSdk ;
88
99jest . mock ( '@telefonica/opengateway-sandbox-sdk' , ( ) => ( {
1010 DeviceLocation : jest . fn ( ) ,
11- Simswap : jest . fn ( )
11+ Simswap : jest . fn ( ) ,
12+ DeviceStatus : jest . fn ( ) ,
13+ NumberVerification : jest . fn ( ) ,
14+ QualityOnDemand : jest . fn ( ) ,
15+ DeviceSwap : jest . fn ( ) ,
16+ KnowYourCustomer : jest . fn ( ) ,
17+ AgeVerification : jest . fn ( ) ,
18+ Tenure : jest . fn ( )
1219} ) ) ;
1320
1421const credentials = {
@@ -82,3 +89,166 @@ describe('Simswap Client', () => {
8289 console . log . mock . calls . forEach ( call => console . log ( ...call ) ) ;
8390 } ) ;
8491} ) ;
92+
93+ describe ( 'DeviceStatus Client' , ( ) => {
94+ let getConnectivityMock ;
95+
96+ beforeEach ( ( ) => {
97+ jest . clearAllMocks ( ) ;
98+ getConnectivityMock = jest . fn ( ) . mockReturnValue ( { status : 'CONNECTED_DATA' } ) ;
99+ DeviceStatus . mockImplementation ( ( ) => ( {
100+ getConnectivity : getConnectivityMock
101+ } ) ) ;
102+ } ) ;
103+
104+ test ( 'should call DeviceStatus and getConnectivity with correct parameters' , ( ) => {
105+ console . log = jest . fn ( ) ;
106+
107+ const deviceStatus = new DeviceStatus ( credentials , undefined , CUSTOMER_PHONE_NUMBER ) ;
108+ const result = deviceStatus . getConnectivity ( ) ;
109+
110+ expect ( DeviceStatus ) . toHaveBeenCalledWith ( credentials , undefined , CUSTOMER_PHONE_NUMBER ) ;
111+ expect ( getConnectivityMock ) . toHaveBeenCalled ( ) ;
112+ expect ( result . status ) . toBe ( 'CONNECTED_DATA' ) ;
113+ } ) ;
114+ } ) ;
115+
116+ describe ( 'NumberVerification Client' , ( ) => {
117+ let verifyNumberMock ;
118+
119+ beforeEach ( ( ) => {
120+ jest . clearAllMocks ( ) ;
121+ verifyNumberMock = jest . fn ( ) . mockReturnValue ( true ) ;
122+ NumberVerification . mockImplementation ( ( ) => ( {
123+ verifyNumber : verifyNumberMock
124+ } ) ) ;
125+ } ) ;
126+
127+ test ( 'should call NumberVerification and verifyNumber with correct parameters' , ( ) => {
128+ console . log = jest . fn ( ) ;
129+
130+ const numberVerification = new NumberVerification ( credentials , undefined , CUSTOMER_PHONE_NUMBER ) ;
131+ const result = numberVerification . verifyNumber ( ) ;
132+
133+ expect ( NumberVerification ) . toHaveBeenCalledWith ( credentials , undefined , CUSTOMER_PHONE_NUMBER ) ;
134+ expect ( verifyNumberMock ) . toHaveBeenCalled ( ) ;
135+ expect ( result ) . toBe ( true ) ;
136+ } ) ;
137+ } ) ;
138+
139+ describe ( 'QualityOnDemand Client' , ( ) => {
140+ let createSessionMock ;
141+
142+ beforeEach ( ( ) => {
143+ jest . clearAllMocks ( ) ;
144+ createSessionMock = jest . fn ( ) . mockReturnValue ( { sessionId : '12345' , status : 'AVAILABLE' } ) ;
145+ QualityOnDemand . mockImplementation ( ( ) => ( {
146+ createSession : createSessionMock
147+ } ) ) ;
148+ } ) ;
149+
150+ test ( 'should call QualityOnDemand and createSession with correct parameters' , ( ) => {
151+ console . log = jest . fn ( ) ;
152+
153+ const qod = new QualityOnDemand ( credentials , undefined , CUSTOMER_PHONE_NUMBER ) ;
154+ const result = qod . createSession ( ) ;
155+
156+ expect ( QualityOnDemand ) . toHaveBeenCalledWith ( credentials , undefined , CUSTOMER_PHONE_NUMBER ) ;
157+ expect ( createSessionMock ) . toHaveBeenCalled ( ) ;
158+ expect ( result . sessionId ) . toBe ( '12345' ) ;
159+ expect ( result . status ) . toBe ( 'AVAILABLE' ) ;
160+ } ) ;
161+ } ) ;
162+
163+ describe ( 'DeviceSwap Client' , ( ) => {
164+ let checkSwapMock ;
165+
166+ beforeEach ( ( ) => {
167+ jest . clearAllMocks ( ) ;
168+ checkSwapMock = jest . fn ( ) . mockReturnValue ( { swapped : true , lastSwapDate : '2023-12-25' } ) ;
169+ DeviceSwap . mockImplementation ( ( ) => ( {
170+ checkSwap : checkSwapMock
171+ } ) ) ;
172+ } ) ;
173+
174+ test ( 'should call DeviceSwap and checkSwap with correct parameters' , ( ) => {
175+ console . log = jest . fn ( ) ;
176+
177+ const deviceSwap = new DeviceSwap ( credentials , undefined , CUSTOMER_PHONE_NUMBER ) ;
178+ const result = deviceSwap . checkSwap ( ) ;
179+
180+ expect ( DeviceSwap ) . toHaveBeenCalledWith ( credentials , undefined , CUSTOMER_PHONE_NUMBER ) ;
181+ expect ( checkSwapMock ) . toHaveBeenCalled ( ) ;
182+ expect ( result . swapped ) . toBe ( true ) ;
183+ expect ( result . lastSwapDate ) . toBe ( '2023-12-25' ) ;
184+ } ) ;
185+ } ) ;
186+
187+ describe ( 'KnowYourCustomer Client' , ( ) => {
188+ let matchMock ;
189+
190+ beforeEach ( ( ) => {
191+ jest . clearAllMocks ( ) ;
192+ matchMock = jest . fn ( ) . mockReturnValue ( { match : true } ) ;
193+ KnowYourCustomer . mockImplementation ( ( ) => ( {
194+ match : matchMock
195+ } ) ) ;
196+ } ) ;
197+
198+ test ( 'should call KnowYourCustomer and match with correct parameters' , ( ) => {
199+ console . log = jest . fn ( ) ;
200+
201+ const kyc = new KnowYourCustomer ( credentials , undefined , CUSTOMER_PHONE_NUMBER ) ;
202+ const result = kyc . match ( ) ;
203+
204+ expect ( KnowYourCustomer ) . toHaveBeenCalledWith ( credentials , undefined , CUSTOMER_PHONE_NUMBER ) ;
205+ expect ( matchMock ) . toHaveBeenCalled ( ) ;
206+ expect ( result . match ) . toBe ( true ) ;
207+ } ) ;
208+ } ) ;
209+
210+ describe ( 'AgeVerification Client' , ( ) => {
211+ let verifyAgeMock ;
212+
213+ beforeEach ( ( ) => {
214+ jest . clearAllMocks ( ) ;
215+ verifyAgeMock = jest . fn ( ) . mockReturnValue ( { verificationResult : true } ) ;
216+ AgeVerification . mockImplementation ( ( ) => ( {
217+ verifyAge : verifyAgeMock
218+ } ) ) ;
219+ } ) ;
220+
221+ test ( 'should call AgeVerification and verifyAge with correct parameters' , ( ) => {
222+ console . log = jest . fn ( ) ;
223+
224+ const ageVerification = new AgeVerification ( credentials , undefined , CUSTOMER_PHONE_NUMBER ) ;
225+ const result = ageVerification . verifyAge ( ) ;
226+
227+ expect ( AgeVerification ) . toHaveBeenCalledWith ( credentials , undefined , CUSTOMER_PHONE_NUMBER ) ;
228+ expect ( verifyAgeMock ) . toHaveBeenCalled ( ) ;
229+ expect ( result . verificationResult ) . toBe ( true ) ;
230+ } ) ;
231+ } ) ;
232+
233+ describe ( 'Tenure Client' , ( ) => {
234+ let getTenureMock ;
235+
236+ beforeEach ( ( ) => {
237+ jest . clearAllMocks ( ) ;
238+ getTenureMock = jest . fn ( ) . mockReturnValue ( { tenure : 24 } ) ;
239+ Tenure . mockImplementation ( ( ) => ( {
240+ getTenure : getTenureMock
241+ } ) ) ;
242+ } ) ;
243+
244+ test ( 'should call Tenure and getTenure with correct parameters' , ( ) => {
245+ console . log = jest . fn ( ) ;
246+
247+ const tenure = new Tenure ( credentials , undefined , CUSTOMER_PHONE_NUMBER ) ;
248+ const result = tenure . getTenure ( ) ;
249+
250+ expect ( Tenure ) . toHaveBeenCalledWith ( credentials , undefined , CUSTOMER_PHONE_NUMBER ) ;
251+ expect ( getTenureMock ) . toHaveBeenCalled ( ) ;
252+ expect ( result . tenure ) . toBe ( 24 ) ;
253+ } ) ;
254+ } ) ;
0 commit comments