@@ -6,11 +6,15 @@ import { usersFixture } from '../fixture';
6
6
import { Product , ProductType } from '../../src/entity/Product' ;
7
7
import type { AuthContext } from '../../src/Context' ;
8
8
import { createClient } from '@connectrpc/connect' ;
9
- import { Credits , EntityType , TransferStatus } from '@dailydotdev/schema' ;
9
+ import { Credits , EntityType } from '@dailydotdev/schema' ;
10
10
import * as njordCommon from '../../src/common/njord' ;
11
11
import { User } from '../../src/entity/user/User' ;
12
12
import { ForbiddenError } from 'apollo-server-errors' ;
13
- import { UserTransaction } from '../../src/entity/user/UserTransaction' ;
13
+ import {
14
+ UserTransaction ,
15
+ UserTransactionProcessor ,
16
+ UserTransactionStatus ,
17
+ } from '../../src/entity/user/UserTransaction' ;
14
18
import * as redisFile from '../../src/redis' ;
15
19
import { ioRedisPool } from '../../src/redis' ;
16
20
import { parseBigInt } from '../../src/common' ;
@@ -100,8 +104,9 @@ describe('transferCores', () => {
100
104
101
105
expect ( transaction ) . toMatchObject ( {
102
106
id : expect . any ( String ) ,
107
+ processor : UserTransactionProcessor . Njord ,
103
108
receiverId : 't-tc-2' ,
104
- status : TransferStatus . SUCCESS ,
109
+ status : UserTransactionStatus . Success ,
105
110
productId : 'dd65570f-86c0-40a0-b8a0-3fdbd0d3945d' ,
106
111
senderId : 't-tc-1' ,
107
112
value : 42 ,
@@ -207,7 +212,7 @@ describe('getBalance', () => {
207
212
} ) ;
208
213
209
214
const result = await njordCommon . getBalance ( {
210
- ctx : { userId : 't-gb-1' } as AuthContext ,
215
+ userId : 't-gb-1' ,
211
216
} ) ;
212
217
213
218
expect ( result ) . toEqual ( { amount : 100 } ) ;
@@ -223,7 +228,7 @@ describe('getBalance', () => {
223
228
const getRedisObjectSpy = jest . spyOn ( redisFile , 'getRedisObject' ) ;
224
229
225
230
const result = await njordCommon . getBalance ( {
226
- ctx : { userId : 't-gb-1' } as AuthContext ,
231
+ userId : 't-gb-1' ,
227
232
} ) ;
228
233
229
234
expect ( result ) . toEqual ( { amount : 0 } ) ;
@@ -259,7 +264,7 @@ describe('getBalance', () => {
259
264
} ) ;
260
265
261
266
const resultNotCached = await njordCommon . getBalance ( {
262
- ctx : { userId : 't-gb-1' } as AuthContext ,
267
+ userId : 't-gb-1' ,
263
268
} ) ;
264
269
265
270
expect ( resultNotCached ) . toEqual ( { amount : 42 } ) ;
@@ -269,7 +274,7 @@ describe('getBalance', () => {
269
274
expect ( getFreshBalanceSpy ) . toHaveBeenCalledTimes ( 1 ) ;
270
275
271
276
const result = await njordCommon . getBalance ( {
272
- ctx : { userId : 't-gb-1' } as AuthContext ,
277
+ userId : 't-gb-1' ,
273
278
} ) ;
274
279
275
280
expect ( result ) . toEqual ( { amount : 42 } ) ;
@@ -300,7 +305,7 @@ describe('getBalance', () => {
300
305
} ) ;
301
306
302
307
const resultNotCached = await njordCommon . getBalance ( {
303
- ctx : { userId : 't-gb-1' } as AuthContext ,
308
+ userId : 't-gb-1' ,
304
309
} ) ;
305
310
306
311
expect ( resultNotCached ) . toEqual ( { amount : 42 } ) ;
@@ -310,7 +315,7 @@ describe('getBalance', () => {
310
315
expect ( getFreshBalanceSpy ) . toHaveBeenCalledTimes ( 1 ) ;
311
316
312
317
const result = await njordCommon . getBalance ( {
313
- ctx : { userId : 't-gb-1' } as AuthContext ,
318
+ userId : 't-gb-1' ,
314
319
} ) ;
315
320
316
321
expect ( result ) . toEqual ( { amount : 42 } ) ;
@@ -324,7 +329,7 @@ describe('getBalance', () => {
324
329
} ) ;
325
330
326
331
const resultExpired = await njordCommon . getBalance ( {
327
- ctx : { userId : 't-gb-1' } as AuthContext ,
332
+ userId : 't-gb-1' ,
328
333
} ) ;
329
334
330
335
expect ( resultExpired ) . toEqual ( { amount : 42 } ) ;
@@ -336,7 +341,7 @@ describe('getBalance', () => {
336
341
337
342
it ( 'should return 0 if no balance' , async ( ) => {
338
343
const result = await njordCommon . getBalance ( {
339
- ctx : { userId : 't-gb-1-not-exists' } as AuthContext ,
344
+ userId : 't-gb-1-not-exists' ,
340
345
} ) ;
341
346
342
347
expect ( result ) . toEqual ( { amount : 0 } ) ;
@@ -361,7 +366,7 @@ describe('updatedBalanceCache', () => {
361
366
) ;
362
367
363
368
const resultBefore = await njordCommon . getBalance ( {
364
- ctx : { userId : 't-ubc-1' } as AuthContext ,
369
+ userId : 't-ubc-1' ,
365
370
} ) ;
366
371
367
372
expect ( resultBefore ) . toEqual ( { amount : 0 } ) ;
@@ -378,7 +383,7 @@ describe('updatedBalanceCache', () => {
378
383
) ;
379
384
380
385
const resultAfter = await njordCommon . getBalance ( {
381
- ctx : { userId : 't-ubc-1' } as AuthContext ,
386
+ userId : 't-ubc-1' ,
382
387
} ) ;
383
388
384
389
expect ( resultAfter ) . toEqual ( { amount : 101 } ) ;
@@ -401,13 +406,13 @@ describe('expireBalanceCache', () => {
401
406
const getFreshBalanceSpy = jest . spyOn ( njordCommon , 'getFreshBalance' ) ;
402
407
403
408
await njordCommon . getBalance ( {
404
- ctx : { userId : 't-ebc-1' } as AuthContext ,
409
+ userId : 't-ebc-1' ,
405
410
} ) ;
406
411
407
412
expect ( getFreshBalanceSpy ) . toHaveBeenCalledTimes ( 1 ) ;
408
413
409
414
await njordCommon . getBalance ( {
410
- ctx : { userId : 't-ebc-1' } as AuthContext ,
415
+ userId : 't-ebc-1' ,
411
416
} ) ;
412
417
413
418
expect ( getFreshBalanceSpy ) . toHaveBeenCalledTimes ( 1 ) ;
@@ -421,7 +426,7 @@ describe('expireBalanceCache', () => {
421
426
) ;
422
427
423
428
await njordCommon . getBalance ( {
424
- ctx : { userId : 't-ebc-1' } as AuthContext ,
429
+ userId : 't-ebc-1' ,
425
430
} ) ;
426
431
427
432
expect ( getFreshBalanceSpy ) . toHaveBeenCalledTimes ( 2 ) ;
0 commit comments