From 209632934137de9b9764b259f0da286878d312c3 Mon Sep 17 00:00:00 2001 From: Matthias Kretschmann Date: Mon, 3 Feb 2020 11:46:48 +0100 Subject: [PATCH] add unit test for compute.checkOutput() --- src/ocean/OceanCompute.ts | 2 +- test/unit/ocean/OceanCompute.test.ts | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/src/ocean/OceanCompute.ts b/src/ocean/OceanCompute.ts index ea8fc33..1c0c653 100644 --- a/src/ocean/OceanCompute.ts +++ b/src/ocean/OceanCompute.ts @@ -93,7 +93,7 @@ export class OceanCompute extends Instantiable { * @param {Output} output Output section used for publishing the result. * @return {Promise} Returns output object */ - private checkOutput(consumerAccount: Account, output?: Output): Output { + public checkOutput(consumerAccount: Account, output?: Output): Output { const isDefault = !output || (!output.publishAlgorithmLog && !output.publishOutput) diff --git a/test/unit/ocean/OceanCompute.test.ts b/test/unit/ocean/OceanCompute.test.ts index 74901bb..9026c22 100644 --- a/test/unit/ocean/OceanCompute.test.ts +++ b/test/unit/ocean/OceanCompute.test.ts @@ -103,4 +103,27 @@ describe('OceanCompute', () => { assert(response[0].status === ComputeJobStatus.Started) }) }) + + describe('#checkOutput()', () => { + it('should return default values', async () => { + const defaultOutput = { publishAlgorithmLog: false, publishOutput: false } + const output = compute.checkOutput(account, undefined) + assert.deepEqual(output, defaultOutput) + }) + + it('should return output values', async () => { + const newOutput = { + publishAlgorithmLog: true, + publishOutput: true, + brizoAddress: 'hello', + brizoUri: 'hello', + metadataUri: 'hello', + nodeUri: 'hello', + owner: '0xhello', + secretStoreUri: 'hello' + } + const output = compute.checkOutput(account, newOutput) + assert.deepEqual(output, newOutput) + }) + }) })