From 292813d2a32ca9c23d24734c05c5646055a5c0ed Mon Sep 17 00:00:00 2001 From: Kevin Griffin Date: Tue, 3 Oct 2023 10:23:46 -0400 Subject: [PATCH] updates tests Signed-off-by: Kevin Griffin --- src/operations.ts | 4 ---- src/qvi/qvi.ts | 2 +- test/operations.test.ts | 23 ++++++++++++----------- 3 files changed, 13 insertions(+), 16 deletions(-) diff --git a/src/operations.ts b/src/operations.ts index 5e773b1..4ab2570 100644 --- a/src/operations.ts +++ b/src/operations.ts @@ -16,14 +16,10 @@ namespace operations { op, time = 1000, }: OperationsArgs) { - console.log('pre while', op, op[DONE]); while (!op[DONE]) { - console.log('done', op, op[DONE]); op = await client.operations().get(op[NAME]); - console.log('get', op); await new Promise((resolve) => setTimeout(resolve, time)); } - console.log('poop', op); return op[RESPONSE]; } } diff --git a/src/qvi/qvi.ts b/src/qvi/qvi.ts index d600163..371c69c 100644 --- a/src/qvi/qvi.ts +++ b/src/qvi/qvi.ts @@ -125,7 +125,7 @@ export class QVI { credential?: any //result for createLegalEntityCredential ) { let sender = await this.client.identifiers().get(''); - sender = await operations.getResult(this.client, sender); + sender = await operations.getResult({client: this.client, op: sender}); if (getFromAgent) { let msgSaid = ''; diff --git a/test/operations.test.ts b/test/operations.test.ts index 3bbd158..c2a591d 100644 --- a/test/operations.test.ts +++ b/test/operations.test.ts @@ -4,33 +4,34 @@ import { instance, mock, when } from 'ts-mockito'; import { operations } from '../src/operations'; describe('operations', () => { - // it('should complete', () => { - // let mockedClient: SignifyClient = mock(SignifyClient); + it('should complete', async () => { + let mockedClient: SignifyClient = mock(SignifyClient); - // let c: Credentials = mock(Credentials); - // when(mockedClient.credentials()).thenReturn(instance(c)); + let c: Credentials = mock(Credentials); + when(mockedClient.credentials()).thenReturn(instance(c)); - // let client = instance(mockedClient); + let client = instance(mockedClient); - // let op = { done: true }; + let op = { done: true, name: 'my_op', response: 'yay'}; - // operations.getResult(client, op); - // }); + let resp = await operations.getResult({client: client, op: op}); + expect(resp).toEqual('yay'); + }); - it('should retry', () => { + it('should retry', async () => { let mockedClient: SignifyClient = mock(SignifyClient); let c: Credentials = mock(Credentials); when(mockedClient.credentials()).thenReturn(instance(c)); let mockedOps: Operations = mock(Operations); - when(mockedOps.get('my_op')).thenResolve(undefined); + when(mockedOps.get('my_op')).thenResolve({done: true, name: 'my_op', response: 'yay'}); when(mockedClient.operations()).thenReturn(instance(mockedOps)); let client = instance(mockedClient); let op = { done: false, name: 'my_op' }; - let resp = operations.getResult({ client: client, op: op }); + let resp = await operations.getResult({ client: client, op: op }); expect(resp).toEqual('yay'); }); });