Skip to content

Commit

Permalink
Merge pull request #15 from gravity-ui/update-stete-hook-fix
Browse files Browse the repository at this point in the history
fix: emit state change after load progress
  • Loading branch information
vanilla-wave authored Aug 4, 2023
2 parents 6ca331f + 799336b commit b593670
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/controller.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -920,6 +920,21 @@ describe('store api', function () {
expect(cb).not.toHaveBeenCalled();
});

it('load progress -> trigger callback', async function () {
const options = getOptions();

const controller = new Controller(options);
const cb = jest.fn();
controller.subscribe(cb);

await controller.stepElementReached({
stepSlug: 'createSprint',
element: getAnchorElement(),
});

expect(cb).toHaveBeenCalled();
});

it('change state -> trigger callback', async function () {
const options = getOptions();

Expand Down
1 change: 1 addition & 0 deletions src/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,7 @@ export class Controller<HintParams, Presets extends string, Steps extends string
...newProgressState,
};
this.status = 'active';
this.emitChange();

this.logger.debug('Onboarding progress data loaded');
} catch (e) {
Expand Down

0 comments on commit b593670

Please sign in to comment.