File tree Expand file tree Collapse file tree 3 files changed +20
-2
lines changed Expand file tree Collapse file tree 3 files changed +20
-2
lines changed Original file line number Diff line number Diff line change @@ -168,6 +168,7 @@ export default class Drift {
168
168
}
169
169
170
170
destroy ( ) {
171
+ this . trigger . _hide ( ) ;
171
172
this . trigger . _unbindEvents ( ) ;
172
173
}
173
174
}
Original file line number Diff line number Diff line change @@ -121,7 +121,9 @@ export default class Trigger {
121
121
}
122
122
123
123
_hide ( e ) {
124
- e . preventDefault ( ) ;
124
+ if ( e ) {
125
+ e . preventDefault ( ) ;
126
+ }
125
127
126
128
this . _lastMovement = null ;
127
129
Original file line number Diff line number Diff line change 1
- /* global describe it expect beforeEach afterEach */
1
+ /* global describe it expect beforeEach afterEach spyOn */
2
2
3
3
import Drift from "../src/js/Drift" ;
4
4
@@ -137,5 +137,20 @@ describe("Drift", () => {
137
137
expect ( drift . trigger . enabled ) . toBe ( false ) ;
138
138
} ) ;
139
139
} ) ;
140
+
141
+ describe ( "#destroy" , ( ) => {
142
+ it ( "should hide and unbind events" , function ( ) {
143
+ const anchor = document . querySelector ( ".test-anchor" ) ;
144
+ const drift = new Drift ( anchor ) ;
145
+
146
+ const hideSpy = spyOn ( drift . trigger , "_hide" ) ;
147
+ const unbindEventsSpy = spyOn ( drift . trigger , "_unbindEvents" ) ;
148
+
149
+ drift . destroy ( ) ;
150
+
151
+ expect ( hideSpy ) . toHaveBeenCalled ( ) ;
152
+ expect ( unbindEventsSpy ) . toHaveBeenCalled ( ) ;
153
+ } ) ;
154
+ } ) ;
140
155
} ) ;
141
156
} ) ;
You can’t perform that action at this time.
0 commit comments