Skip to content

Commit

Permalink
Implement Tour.hide
Browse files Browse the repository at this point in the history
Closes [#249](#249).
  • Loading branch information
BrianSipple committed Oct 9, 2018
1 parent bd7a3a4 commit e864184
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 2 deletions.
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 && typeof currentStep.hide === 'function') {
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

0 comments on commit e864184

Please sign in to comment.