File tree Expand file tree Collapse file tree 2 files changed +37
-2
lines changed Expand file tree Collapse file tree 2 files changed +37
-2
lines changed Original file line number Diff line number Diff line change @@ -128,7 +128,7 @@ export class IntroJs {
128128 return this ;
129129 }
130130
131- addStep ( step : IntroStep ) {
131+ addStep ( step : Partial < IntroStep > ) {
132132 if ( ! this . _options . steps ) {
133133 this . _options . steps = [ ] ;
134134 }
@@ -138,7 +138,7 @@ export class IntroJs {
138138 return this ;
139139 }
140140
141- addSteps ( steps : IntroStep [ ] ) {
141+ addSteps ( steps : Partial < IntroStep > [ ] ) {
142142 if ( ! steps . length ) return this ;
143143
144144 for ( let index = 0 ; index < steps . length ; index ++ ) {
Original file line number Diff line number Diff line change 11import { nextStep , previousStep } from "../../../src/core/steps" ;
22import _showElement from "../../../src/core/showElement" ;
33import { IntroJs } from "../../../src/intro" ;
4+ import introJs from "../../../src" ;
45
56jest . mock ( "../../../src/core/showElement" ) ;
67jest . mock ( "../../../src/core/exitIntro" ) ;
@@ -123,5 +124,39 @@ describe("steps", () => {
123124 expect ( fnCompleteCallback ) . toBeCalledTimes ( 1 ) ;
124125 expect ( fnCompleteCallback ) . toHaveBeenCalledWith ( 2 , "end" ) ;
125126 } ) ;
127+
128+ test ( "should be able to add steps using addStep()" , async ( ) => {
129+ const intro = introJs ( ) ;
130+
131+ intro . addStep ( {
132+ element : document . createElement ( "div" ) ,
133+ intro : "test step" ,
134+ } ) ;
135+
136+ await intro . start ( ) ;
137+
138+ expect ( intro . _introItems ) . toHaveLength ( 1 ) ;
139+ expect ( intro . _introItems [ 0 ] . intro ) . toBe ( "test step" ) ;
140+ } ) ;
141+
142+ test ( "should be able to add steps using addSteps()" , async ( ) => {
143+ const intro = introJs ( ) ;
144+
145+ intro . addSteps ( [
146+ {
147+ intro : "first step" ,
148+ } ,
149+ {
150+ element : document . createElement ( "div" ) ,
151+ intro : "second step" ,
152+ } ,
153+ ] ) ;
154+
155+ await intro . start ( ) ;
156+
157+ expect ( intro . _introItems ) . toHaveLength ( 2 ) ;
158+ expect ( intro . _introItems [ 0 ] . intro ) . toBe ( "first step" ) ;
159+ expect ( intro . _introItems [ 1 ] . intro ) . toBe ( "second step" ) ;
160+ } ) ;
126161 } ) ;
127162} ) ;
You can’t perform that action at this time.
0 commit comments