Skip to content
This repository has been archived by the owner on May 29, 2024. It is now read-only.

Commit

Permalink
updates tests
Browse files Browse the repository at this point in the history
Signed-off-by: Kevin Griffin <[email protected]>
  • Loading branch information
m00sey committed Oct 3, 2023
1 parent f63524e commit 292813d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 16 deletions.
4 changes: 0 additions & 4 deletions src/operations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/qvi/qvi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = '';
Expand Down
23 changes: 12 additions & 11 deletions test/operations.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
});
});

0 comments on commit 292813d

Please sign in to comment.