@@ -8,11 +8,29 @@ if (exports) {
88}
99
1010var doc = window . document ;
11+ var beforeopenEvent = false ;
12+ var openEvent = false ;
13+ var beforecloseEvent = false ;
14+ var closeEvent = false ;
1115var slideout = new Slideout ( {
1216 'panel' : doc . getElementById ( 'panel' ) ,
1317 'menu' : doc . getElementById ( 'menu' )
1418} ) ;
1519
20+ slideout
21+ . on ( 'beforeopen' , function ( ) {
22+ beforeopenEvent = true ;
23+ } )
24+ . on ( 'open' , function ( ) {
25+ openEvent = true ;
26+ } )
27+ . on ( 'beforeclose' , function ( ) {
28+ beforecloseEvent = true ;
29+ } )
30+ . on ( 'close' , function ( ) {
31+ closeEvent = true ;
32+ } ) ;
33+
1634describe ( 'Slideout' , function ( ) {
1735
1836 it ( 'should be defined.' , function ( ) {
@@ -28,7 +46,19 @@ describe('Slideout', function () {
2846 } ) ;
2947
3048 describe ( 'should have the following methods:' , function ( ) {
31- var methods = [ 'open' , 'close' , 'toggle' , 'isOpen' , '_initTouchEvents' , '_translateXTo' , '_setTransition' ] ;
49+ var methods = [
50+ 'open' ,
51+ 'close' ,
52+ 'toggle' ,
53+ 'isOpen' ,
54+ '_initTouchEvents' ,
55+ '_translateXTo' ,
56+ '_setTransition' ,
57+ 'on' ,
58+ 'once' ,
59+ 'off' ,
60+ 'emit'
61+ ] ;
3262 var i = 0 ;
3363 var len = methods . length ;
3464 for ( i ; i < len ; i += 1 ) {
@@ -89,6 +119,18 @@ describe('Slideout', function () {
89119 it ( 'should set _opened to true.' , function ( ) {
90120 assert ( slideout . _opened === true ) ;
91121 } ) ;
122+
123+ it ( 'should emit "beforeopen" event.' , function ( ) {
124+ assert ( beforeopenEvent === true ) ;
125+ } ) ;
126+
127+ it ( 'should emit "open" event.' , function ( done ) {
128+ setTimeout ( function ( ) {
129+ assert ( openEvent === true ) ;
130+ done ( ) ;
131+ } , 400 ) ;
132+
133+ } ) ;
92134 } ) ;
93135
94136 describe ( '.isOpen()' , function ( ) {
@@ -109,14 +151,21 @@ describe('Slideout', function () {
109151 } ) ;
110152
111153 it ( 'should translateX the panel to 0.' , function ( ) {
112- var translate3d = exports ? 'translate3d(0px, 0, 0)' : 'translate3d(0px, 0px, 0px)' ;
113- assert ( slideout . panel . style . transform === translate3d ) ;
154+ assert ( slideout . panel . style . transform === '' ) ;
114155 assert ( slideout . panel . style . transition === '' ) ;
115156 } ) ;
116157
117158 it ( 'should set _opened to false.' , function ( ) {
118159 assert ( slideout . _opened === false ) ;
119160 } ) ;
161+
162+ it ( 'should emit "beforeclose" event.' , function ( ) {
163+ assert ( beforecloseEvent === true ) ;
164+ } ) ;
165+
166+ it ( 'should emit "close" event.' , function ( ) {
167+ assert ( closeEvent === true ) ;
168+ } ) ;
120169 } ) ;
121170
122171 describe ( '.toggle()' , function ( ) {
0 commit comments