@@ -7,55 +7,62 @@ describe("fetchIntroSteps", () => {
7
7
const steps = fetchIntroSteps . call (
8
8
{
9
9
_options : {
10
- steps : [ {
11
- element : '#element_does_not_exist' ,
12
- intro : 'hello world'
13
- } , {
14
- intro : 'second'
15
- } ]
10
+ steps : [
11
+ {
12
+ element : "#element_does_not_exist" ,
13
+ intro : "hello world" ,
14
+ } ,
15
+ {
16
+ intro : "second" ,
17
+ } ,
18
+ ] ,
16
19
} ,
17
20
} ,
18
21
targetElement
19
22
) ;
20
23
21
24
expect ( steps . length ) . toBe ( 2 ) ;
22
25
23
- expect ( steps [ 0 ] . position ) . toBe ( ' floating' ) ;
24
- expect ( steps [ 0 ] . intro ) . toBe ( ' hello world' ) ;
26
+ expect ( steps [ 0 ] . position ) . toBe ( " floating" ) ;
27
+ expect ( steps [ 0 ] . intro ) . toBe ( " hello world" ) ;
25
28
expect ( steps [ 0 ] . step ) . toBe ( 1 ) ;
26
29
27
- expect ( steps [ 1 ] . position ) . toBe ( ' floating' ) ;
28
- expect ( steps [ 1 ] . intro ) . toBe ( ' second' ) ;
30
+ expect ( steps [ 1 ] . position ) . toBe ( " floating" ) ;
31
+ expect ( steps [ 1 ] . intro ) . toBe ( " second" ) ;
29
32
expect ( steps [ 1 ] . step ) . toBe ( 2 ) ;
30
33
} ) ;
31
34
32
35
test ( "should find and add elements from options.steps to the list" , ( ) => {
33
36
const targetElement = document . createElement ( "div" ) ;
34
37
35
- const stepOne = document . createElement ( ' div' ) ;
36
- stepOne . setAttribute ( 'id' , ' first' ) ;
38
+ const stepOne = document . createElement ( " div" ) ;
39
+ stepOne . setAttribute ( "id" , " first" ) ;
37
40
38
- const stepTwo = document . createElement ( ' div' ) ;
39
- stepTwo . setAttribute ( 'id' , ' second' ) ;
41
+ const stepTwo = document . createElement ( " div" ) ;
42
+ stepTwo . setAttribute ( "id" , " second" ) ;
40
43
41
44
document . body . appendChild ( stepOne ) ;
42
45
document . body . appendChild ( stepTwo ) ;
43
46
44
47
const steps = fetchIntroSteps . call (
45
48
{
46
49
_options : {
47
- tooltipPosition : 'bottom' ,
48
- steps : [ {
49
- element : '#first' ,
50
- intro : 'first'
51
- } , {
52
- element : '#second' ,
53
- intro : 'second' ,
54
- position : 'top'
55
- } , {
56
- element : '#not_found' ,
57
- intro : 'third'
58
- } ]
50
+ tooltipPosition : "bottom" ,
51
+ steps : [
52
+ {
53
+ element : "#first" ,
54
+ intro : "first" ,
55
+ } ,
56
+ {
57
+ element : "#second" ,
58
+ intro : "second" ,
59
+ position : "top" ,
60
+ } ,
61
+ {
62
+ element : "#not_found" ,
63
+ intro : "third" ,
64
+ } ,
65
+ ] ,
59
66
} ,
60
67
} ,
61
68
targetElement
@@ -64,111 +71,114 @@ describe("fetchIntroSteps", () => {
64
71
expect ( steps . length ) . toBe ( 3 ) ;
65
72
66
73
expect ( steps [ 0 ] . element ) . toBe ( stepOne ) ;
67
- expect ( steps [ 0 ] . position ) . toBe ( ' bottom' ) ;
68
- expect ( steps [ 0 ] . intro ) . toBe ( ' first' ) ;
74
+ expect ( steps [ 0 ] . position ) . toBe ( " bottom" ) ;
75
+ expect ( steps [ 0 ] . intro ) . toBe ( " first" ) ;
69
76
expect ( steps [ 0 ] . step ) . toBe ( 1 ) ;
70
77
71
78
expect ( steps [ 1 ] . element ) . toBe ( stepTwo ) ;
72
- expect ( steps [ 1 ] . position ) . toBe ( ' top' ) ;
73
- expect ( steps [ 1 ] . intro ) . toBe ( ' second' ) ;
79
+ expect ( steps [ 1 ] . position ) . toBe ( " top" ) ;
80
+ expect ( steps [ 1 ] . intro ) . toBe ( " second" ) ;
74
81
expect ( steps [ 1 ] . step ) . toBe ( 2 ) ;
75
82
76
- expect ( steps [ 2 ] . position ) . toBe ( ' floating' ) ;
77
- expect ( steps [ 2 ] . intro ) . toBe ( ' third' ) ;
83
+ expect ( steps [ 2 ] . position ) . toBe ( " floating" ) ;
84
+ expect ( steps [ 2 ] . intro ) . toBe ( " third" ) ;
78
85
expect ( steps [ 2 ] . step ) . toBe ( 3 ) ;
79
86
} ) ;
80
87
81
88
test ( "should find the data-* elements from the DOM" , ( ) => {
82
89
const targetElement = document . createElement ( "div" ) ;
83
90
84
- const stepOne = document . createElement ( ' div' ) ;
85
- stepOne . setAttribute ( ' data-intro' , ' first' ) ;
91
+ const stepOne = document . createElement ( " div" ) ;
92
+ stepOne . setAttribute ( " data-intro" , " first" ) ;
86
93
87
- const stepTwo = document . createElement ( ' div' ) ;
88
- stepTwo . setAttribute ( ' data-intro' , ' second' ) ;
89
- stepTwo . setAttribute ( ' data-position' , ' left' ) ;
94
+ const stepTwo = document . createElement ( " div" ) ;
95
+ stepTwo . setAttribute ( " data-intro" , " second" ) ;
96
+ stepTwo . setAttribute ( " data-position" , " left" ) ;
90
97
91
98
targetElement . appendChild ( stepOne ) ;
92
99
targetElement . appendChild ( stepTwo ) ;
93
100
94
101
const steps = fetchIntroSteps . call (
95
102
{
96
103
_options : {
97
- tooltipPosition : ' bottom'
104
+ tooltipPosition : " bottom" ,
98
105
} ,
99
106
} ,
100
107
targetElement
101
108
) ;
102
109
103
110
expect ( steps . length ) . toBe ( 2 ) ;
104
111
105
- expect ( steps [ 0 ] . position ) . toBe ( ' bottom' ) ;
106
- expect ( steps [ 0 ] . intro ) . toBe ( ' first' ) ;
112
+ expect ( steps [ 0 ] . position ) . toBe ( " bottom" ) ;
113
+ expect ( steps [ 0 ] . intro ) . toBe ( " first" ) ;
107
114
expect ( steps [ 0 ] . step ) . toBe ( 1 ) ;
108
115
109
- expect ( steps [ 1 ] . position ) . toBe ( ' left' ) ;
110
- expect ( steps [ 1 ] . intro ) . toBe ( ' second' ) ;
116
+ expect ( steps [ 1 ] . position ) . toBe ( " left" ) ;
117
+ expect ( steps [ 1 ] . intro ) . toBe ( " second" ) ;
111
118
expect ( steps [ 1 ] . step ) . toBe ( 2 ) ;
112
119
} ) ;
113
120
114
121
test ( "should respect the custom step attribute (DOM)" , ( ) => {
115
122
const targetElement = document . createElement ( "div" ) ;
116
123
117
- const stepOne = document . createElement ( ' div' ) ;
118
- stepOne . setAttribute ( ' data-intro' , ' second' ) ;
119
- stepOne . setAttribute ( ' data-step' , '5' ) ;
124
+ const stepOne = document . createElement ( " div" ) ;
125
+ stepOne . setAttribute ( " data-intro" , " second" ) ;
126
+ stepOne . setAttribute ( " data-step" , "5" ) ;
120
127
121
- const stepTwo = document . createElement ( ' div' ) ;
122
- stepTwo . setAttribute ( ' data-intro' , ' first' ) ;
128
+ const stepTwo = document . createElement ( " div" ) ;
129
+ stepTwo . setAttribute ( " data-intro" , " first" ) ;
123
130
124
131
targetElement . appendChild ( stepOne ) ;
125
132
targetElement . appendChild ( stepTwo ) ;
126
133
127
134
const steps = fetchIntroSteps . call (
128
135
{
129
136
_options : {
130
- tooltipPosition : ' bottom'
137
+ tooltipPosition : " bottom" ,
131
138
} ,
132
139
} ,
133
140
targetElement
134
141
) ;
135
142
136
143
expect ( steps . length ) . toBe ( 2 ) ;
137
144
138
- expect ( steps [ 0 ] . intro ) . toBe ( ' first' ) ;
145
+ expect ( steps [ 0 ] . intro ) . toBe ( " first" ) ;
139
146
expect ( steps [ 0 ] . step ) . toBe ( 1 ) ;
140
147
141
- expect ( steps [ 1 ] . intro ) . toBe ( ' second' ) ;
148
+ expect ( steps [ 1 ] . intro ) . toBe ( " second" ) ;
142
149
expect ( steps [ 1 ] . step ) . toBe ( 5 ) ;
143
150
} ) ;
144
151
145
152
test ( "should ignore DOM elements when options.steps is available" , ( ) => {
146
153
const targetElement = document . createElement ( "div" ) ;
147
154
148
- const stepOne = document . createElement ( ' div' ) ;
149
- stepOne . setAttribute ( ' data-intro' , ' first' ) ;
155
+ const stepOne = document . createElement ( " div" ) ;
156
+ stepOne . setAttribute ( " data-intro" , " first" ) ;
150
157
151
- const stepTwo = document . createElement ( ' div' ) ;
152
- stepTwo . setAttribute ( ' data-intro' , ' second' ) ;
158
+ const stepTwo = document . createElement ( " div" ) ;
159
+ stepTwo . setAttribute ( " data-intro" , " second" ) ;
153
160
154
161
targetElement . appendChild ( stepOne ) ;
155
162
targetElement . appendChild ( stepTwo ) ;
156
163
157
164
const steps = fetchIntroSteps . call (
158
165
{
159
166
_options : {
160
- steps : [ {
161
- intro : 'steps-first' ,
162
- } , {
163
- intro : 'steps-second' ,
164
- } ]
167
+ steps : [
168
+ {
169
+ intro : "steps-first" ,
170
+ } ,
171
+ {
172
+ intro : "steps-second" ,
173
+ } ,
174
+ ] ,
165
175
} ,
166
176
} ,
167
177
targetElement
168
178
) ;
169
179
170
180
expect ( steps . length ) . toBe ( 2 ) ;
171
- expect ( steps [ 0 ] . intro ) . toBe ( ' steps-first' ) ;
172
- expect ( steps [ 1 ] . intro ) . toBe ( ' steps-second' ) ;
181
+ expect ( steps [ 0 ] . intro ) . toBe ( " steps-first" ) ;
182
+ expect ( steps [ 1 ] . intro ) . toBe ( " steps-second" ) ;
173
183
} ) ;
174
184
} ) ;
0 commit comments