Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/js/step.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand Down
11 changes: 11 additions & 0 deletions src/js/tour.js
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down
18 changes: 18 additions & 0 deletions test/unit/test.tour.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down