Skip to content

Commit 24d94bc

Browse files
authored
Merge pull request #2150 from Parvinmh/fix/tour
merge new options and defualt options
2 parents baa6c55 + 57994d2 commit 24d94bc

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

src/packages/hint/hint.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export class Hint implements Package<HintOptions> {
4545
) {
4646
this._targetElement = getContainerElement(elementOrSelector);
4747
this._options = options
48-
? setOptions(this._options, options)
48+
? setOptions(this._options, { ...getDefaultHintOptions(), ...options })
4949
: getDefaultHintOptions();
5050
}
5151

src/packages/tour/tour.test.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import {
1919
waitMsForExitTransition,
2020
} from "../../util/sleep";
2121
import { axe, toHaveNoViolations } from "jest-axe";
22-
2322
expect.extend(toHaveNoViolations);
2423
jest.setTimeout(40000);
2524

@@ -47,6 +46,19 @@ describe("Tour", () => {
4746
// Assert
4847
expect(tour.getTargetElement()).toBe(stubTargetElement);
4948
});
49+
50+
test("should merge user options with default options", () => {
51+
// Arrange
52+
const userOptions = { showStepNumbers: true };
53+
54+
// Act
55+
const tour = new Tour(undefined, userOptions);
56+
57+
// Assert
58+
expect(tour.getOption("showStepNumbers")).toBe(true);
59+
expect(tour.getOption("showButtons")).toBe(true);
60+
expect(tour.getOption("exitOnEsc")).toBe(true);
61+
});
5062
});
5163

5264
describe("start", () => {

src/packages/tour/tour.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ export class Tour implements Package<TourOptions> {
6262
) {
6363
this._targetElement = getContainerElement(elementOrSelector);
6464
this._options = options
65-
? setOptions(this._options, options)
65+
? setOptions(this._options, { ...getDefaultTourOptions(), ...options })
6666
: getDefaultTourOptions();
6767
}
6868

0 commit comments

Comments
 (0)