From f63524e4716e0b707123d3744d739060146af94b Mon Sep 17 00:00:00 2001 From: Kevin Griffin Date: Tue, 3 Oct 2023 10:03:45 -0400 Subject: [PATCH] wip --- test/operations.test.ts | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 test/operations.test.ts diff --git a/test/operations.test.ts b/test/operations.test.ts new file mode 100644 index 0000000..3bbd158 --- /dev/null +++ b/test/operations.test.ts @@ -0,0 +1,36 @@ +import { SignifyClient, Credentials, Operations } from 'signify-ts'; +import { describe, expect, it } from '@jest/globals'; +import { instance, mock, when } from 'ts-mockito'; +import { operations } from '../src/operations'; + +describe('operations', () => { + // it('should complete', () => { + // let mockedClient: SignifyClient = mock(SignifyClient); + + // let c: Credentials = mock(Credentials); + // when(mockedClient.credentials()).thenReturn(instance(c)); + + // let client = instance(mockedClient); + + // let op = { done: true }; + + // operations.getResult(client, op); + // }); + + it('should retry', () => { + 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(mockedClient.operations()).thenReturn(instance(mockedOps)); + + let client = instance(mockedClient); + + let op = { done: false, name: 'my_op' }; + let resp = operations.getResult({ client: client, op: op }); + expect(resp).toEqual('yay'); + }); +});