@@ -232,6 +232,41 @@ describe("RecordScanner", () => {
232
232
expect ( request . headers . get ( "Content-Type" ) ) . to . equal ( "application/json" ) ;
233
233
} ) ;
234
234
235
+ it ( "should return OwnedRecord after successfully getting owned record" , async ( ) => {
236
+ recordScanner = new RecordScanner ( { url : "https://record-scanner.aleo.org" , account : defaultAccount } ) ;
237
+ const mockRegisterResponse = {
238
+ ok : true ,
239
+ status : 201 ,
240
+ text : ( ) => Promise . resolve ( '{"uuid": "test-uuid"}' ) ,
241
+ json : ( ) => Promise . resolve ( { uuid : "test-uuid" } )
242
+ } ;
243
+ fetchStub . resolves ( mockRegisterResponse ) ;
244
+ await recordScanner . register ( 0 ) ;
245
+
246
+ fetchStub . resetHistory ( ) ;
247
+
248
+ const mockResponse = {
249
+ ok : true ,
250
+ status : 200 ,
251
+ text : ( ) => Promise . resolve ( JSON . stringify ( OWNED_RECORDS ) ) ,
252
+ json : ( ) => Promise . resolve ( OWNED_RECORDS ) ,
253
+ } ;
254
+ fetchStub . resolves ( mockResponse ) ;
255
+ const ownedRecord = await recordScanner . findRecord ( {
256
+ uuid : "test-uuid" ,
257
+ } ) ;
258
+ expect ( ownedRecord ) . to . deep . equal ( OWNED_RECORDS [ 0 ] ) ;
259
+
260
+ const request = fetchStub . firstCall . args [ 0 ] as Request ;
261
+ const body = await request . text ( ) ;
262
+ const expectedBody = JSON . stringify ( {
263
+ uuid : "test-uuid" ,
264
+ } ) ;
265
+ expect ( body ) . to . equal ( expectedBody ) ;
266
+ expect ( request . method ) . to . equal ( "POST" ) ;
267
+ expect ( request . headers . get ( "Content-Type" ) ) . to . equal ( "application/json" ) ;
268
+ } ) ;
269
+
235
270
it ( "should throw an error if the uuid is not registered" , async ( ) => {
236
271
recordScanner = new RecordScanner ( { url : "https://record-scanner.aleo.org" , account : defaultAccount } ) ;
237
272
let failed = false ;
0 commit comments