diff --git a/src/js/step.js b/src/js/step.js index 53e321ce1..8fe47aa29 100644 --- a/src/js/step.js +++ b/src/js/step.js @@ -292,10 +292,10 @@ export class Step extends Evented { /** * Check if the step is open and visible - * @return {*|boolean} True if the step is open and visible + * @return {boolean} True if the step is open and visible */ isOpen() { - return this.el && !this.el.hidden; + return Boolean(this.el && !this.el.hidden); } /** diff --git a/src/js/tour.js b/src/js/tour.js index d12329439..cd31cb7fb 100644 --- a/src/js/tour.js +++ b/src/js/tour.js @@ -148,6 +148,17 @@ export class Tour extends Evented { return this.currentStep; } + /** + * Hide the current step + */ + hide() { + const currentStep = this.getCurrentStep(); + + if (currentStep) { + return currentStep.hide(); + } + } + /** * Go to the next step in the tour * If we are at the end, call `complete` diff --git a/test/unit/test.tour.js b/test/unit/test.tour.js index 23de505c0..589ffb09d 100644 --- a/test/unit/test.tour.js +++ b/test/unit/test.tour.js @@ -147,6 +147,24 @@ describe('Tour', function() { }); }); + describe('.hide()', function() { + it('hides the current step', () => { + const firstStep = instance.steps[0]; + const hideStepSpy = spy(firstStep, 'hide'); + + assert.equal(firstStep.isOpen(), false); + + instance.start(); + + assert.equal(firstStep.isOpen(), true); + + instance.hide(); + + assert.equal(firstStep.isOpen(), false); + assert.equal(hideStepSpy.callCount, 1); + }); + }); + describe('.next()/.back()', function() { it('goes to the next/previous steps', function() { instance.start();