File tree 1 file changed +30
-0
lines changed
1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -46,6 +46,7 @@ test('It should set defaults', (t) => {
46
46
t . not ( inst . options . duration , undefined ) ;
47
47
t . not ( inst . options . easing , undefined ) ;
48
48
t . not ( inst . options . callback , undefined ) ;
49
+ t . not ( inst . options . container , undefined ) ;
49
50
} ) ;
50
51
51
52
test ( 'It should pass ease function(s) when creating instance' , ( t ) => {
@@ -148,3 +149,32 @@ test.serial.cb('It should scroll to target element', (t) => {
148
149
} , 1000 ) ;
149
150
} ) ;
150
151
152
+ test . serial . cb ( 'It should scroll to target position inside an element' , ( t ) => {
153
+ const container = document . createElement ( 'div' ) ;
154
+
155
+ document . body . appendChild ( container ) ;
156
+
157
+ const inst = new MoveTo ( {
158
+ container : container
159
+ } ) ;
160
+
161
+ const calls = [ ] ;
162
+
163
+ // mock scroll.
164
+ const originalScroll = container . scroll ;
165
+ container . scroll = function ( _ , y ) {
166
+ calls . push ( y ) ;
167
+ } ;
168
+
169
+ inst . move ( 1500 ) ;
170
+
171
+ setTimeout ( ( ) => {
172
+ // revert scroll.
173
+ container . scroll = originalScroll ;
174
+
175
+ t . is ( calls [ calls . length - 1 ] , 1500 ) ;
176
+
177
+ t . end ( ) ;
178
+ } , 1000 ) ;
179
+ } ) ;
180
+
You can’t perform that action at this time.
0 commit comments