Skip to content

Commit a821cd5

Browse files
BrianSippleRobbieTheWagner
authored andcommitted
Implement Tour.hide (#265)
Closes [#249](#249).
1 parent bd7a3a4 commit a821cd5

File tree

3 files changed

+31
-2
lines changed

3 files changed

+31
-2
lines changed

src/js/step.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -292,10 +292,10 @@ export class Step extends Evented {
292292

293293
/**
294294
* Check if the step is open and visible
295-
* @return {*|boolean} True if the step is open and visible
295+
* @return {boolean} True if the step is open and visible
296296
*/
297297
isOpen() {
298-
return this.el && !this.el.hidden;
298+
return Boolean(this.el && !this.el.hidden);
299299
}
300300

301301
/**

src/js/tour.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,17 @@ export class Tour extends Evented {
148148
return this.currentStep;
149149
}
150150

151+
/**
152+
* Hide the current step
153+
*/
154+
hide() {
155+
const currentStep = this.getCurrentStep();
156+
157+
if (currentStep) {
158+
return currentStep.hide();
159+
}
160+
}
161+
151162
/**
152163
* Go to the next step in the tour
153164
* If we are at the end, call `complete`

test/unit/test.tour.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,24 @@ describe('Tour', function() {
147147
});
148148
});
149149

150+
describe('.hide()', function() {
151+
it('hides the current step', () => {
152+
const firstStep = instance.steps[0];
153+
const hideStepSpy = spy(firstStep, 'hide');
154+
155+
assert.equal(firstStep.isOpen(), false);
156+
157+
instance.start();
158+
159+
assert.equal(firstStep.isOpen(), true);
160+
161+
instance.hide();
162+
163+
assert.equal(firstStep.isOpen(), false);
164+
assert.equal(hideStepSpy.callCount, 1);
165+
});
166+
});
167+
150168
describe('.next()/.back()', function() {
151169
it('goes to the next/previous steps', function() {
152170
instance.start();

0 commit comments

Comments
 (0)