From beae3e06d4e246cdb9390cc80e74ff9e1085a356 Mon Sep 17 00:00:00 2001 From: vanilla-wave Date: Thu, 3 Aug 2023 11:42:17 +0200 Subject: [PATCH] feat: add step pass hook --- src/controller.test.ts | 14 ++++++++++++++ src/controller.ts | 1 + src/types.ts | 3 +++ 3 files changed, 18 insertions(+) diff --git a/src/controller.test.ts b/src/controller.test.ts index 5ea0af3..22d5dc0 100644 --- a/src/controller.test.ts +++ b/src/controller.test.ts @@ -327,6 +327,20 @@ describe('pass step', function () { expect(newProgressState.finishedPresets).toEqual(['createProject']); expect(options.onSave.progress).toHaveBeenCalledTimes(1); }); + + describe('step hooks', function () { + it('pass step -> call onPass hook', async function () { + const options = getOptions(); + const mock = jest.fn(); + + options.config.presets.createProject.steps[1].hooks = {onStepPass: mock}; + + const controller = new Controller(options); + await controller.passStep('createSprint'); + + expect(mock).toHaveBeenCalled(); + }); + }); }); describe('hints', function () { diff --git a/src/controller.ts b/src/controller.ts index 029a203..266db4b 100644 --- a/src/controller.ts +++ b/src/controller.ts @@ -115,6 +115,7 @@ export class Controller { if (step?.passMode !== 'onShowHint') { diff --git a/src/types.ts b/src/types.ts index 8200519..7d5847d 100644 --- a/src/types.ts +++ b/src/types.ts @@ -27,6 +27,9 @@ export type PresetStep = { hintParams?: HintParams; closeOnElementUnmount?: boolean; passRestriction?: 'afterPrevious'; + hooks?: { + onStepPass?: () => void; + }; }; export type Preset = {