Skip to content

Commit

Permalink
Fixed keeping result from prepare activation in ActivationHelper
Browse files Browse the repository at this point in the history
  • Loading branch information
hvge committed Sep 30, 2022
1 parent 2657ce2 commit 11da559
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/helpers/ActivationHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -235,19 +235,19 @@ export class ActivationHelper<SDK, PrepareResult> {
* @returns Promise with void.
*/
async prepareActivation(prepareData: ActivationHelperPrepareData | undefined = undefined): Promise<PrepareResult> {
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<PrepareResult> {
private async prepareActivationImpl(activation: Activation, data: ActivationHelperPrepareData | undefined): Promise<PrepareResult> {
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
}

/**
Expand Down
2 changes: 2 additions & 0 deletions tests/Activations.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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)
})
Expand Down

0 comments on commit 11da559

Please sign in to comment.