From 11da5599d3cc23b3e2720bd484723c73b1868913 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juraj=20=C4=8Eurech?= Date: Fri, 30 Sep 2022 14:03:43 +0200 Subject: [PATCH] Fixed keeping result from prepare activation in ActivationHelper --- src/helpers/ActivationHelper.ts | 8 ++++---- tests/Activations.test.ts | 2 ++ 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/helpers/ActivationHelper.ts b/src/helpers/ActivationHelper.ts index 5173663..c8864ee 100644 --- a/src/helpers/ActivationHelper.ts +++ b/src/helpers/ActivationHelper.ts @@ -235,19 +235,19 @@ export class ActivationHelper { * @returns Promise with void. */ async prepareActivation(prepareData: ActivationHelperPrepareData | undefined = undefined): Promise { - this.prepareResultData = await this.withActivation(activation => this.prepareActivationImpl(activation, prepareData)) - return this.prepareResultData + return this.withActivation(activation => this.prepareActivationImpl(activation, prepareData)) } /** * Prepare activation implementation. */ - private prepareActivationImpl(activation: Activation, data: ActivationHelperPrepareData | undefined): Promise { + private async prepareActivationImpl(activation: Activation, data: ActivationHelperPrepareData | undefined): Promise { if (!this.prepareStep) { throw new Error('Missing prepare step in ActivationHelper') } this.prepareData = data - return this.prepareStep(this, activation, data) + this.prepareResultData = await this.prepareStep(this, activation, data) + return this.prepareResultData } /** diff --git a/tests/Activations.test.ts b/tests/Activations.test.ts index 9e7d1f5..4b7d51b 100644 --- a/tests/Activations.test.ts +++ b/tests/Activations.test.ts @@ -57,6 +57,7 @@ describe('Manage PowerAuth applications', () => { expect(status).toBe(ActivationStatus.CREATED) // await activationHelper.prepareActivation() + expect(activationHelper.prepareActivationResult).toBeTruthy() status = await activationHelper.getActivationStatus() expect(status).toBe(ActivationStatus.PENDING_COMMIT) @@ -68,6 +69,7 @@ describe('Manage PowerAuth applications', () => { test('Test automatic activation create ', async () => { const activation = await activationHelper.createActivation() expect(activationHelper.powerAuthSdk).toBeDefined() + expect(activationHelper.prepareActivationResult).toBeTruthy() let status = await activationHelper.getActivationStatus() expect(status).toBe(ActivationStatus.ACTIVE) })