@@ -81,6 +81,40 @@ describe('tricks', function() {
8181 expect ( tui . util . debounce ) . toHaveBeenCalled ( ) ;
8282 } ) ;
8383
84+ it ( 'debounced method must invoke with additional parameter' , function ( ) {
85+ var magazine = [ 1 , 3 , 6 , 8 , 9 ] ,
86+ fireGun = reload ( magazine ) ,
87+ fn ;
88+
89+ spyOn ( tui . util , 'timestamp' ) . and . callFake ( function ( ) {
90+ return fireGun ( ) ;
91+ } ) ;
92+
93+ var debounced = jasmine . createSpy ( 'debounced' ) ;
94+ spyOn ( tui . util , 'debounce' ) . and . returnValue ( debounced ) ;
95+
96+ fn = tui . util . throttle ( spy , 7 ) ;
97+
98+ fn ( 'hello' ) ;
99+ fn ( 'hello' ) ;
100+ fn ( 'hello' ) ;
101+ fn ( 'hello' ) ;
102+ fn ( 'hello' ) ;
103+
104+ expect ( spy . calls . count ( ) ) . toBe ( 2 ) ;
105+ expect ( tui . util . debounce ) . toHaveBeenCalled ( ) ;
106+
107+ expect ( debounced . calls . count ( ) ) . toBe ( 4 ) ;
108+ // debounce가 이미 콜백을 apply 처리하고 있는데, Mock을 했기 때문에
109+ // args 를 그냥 넘겨준다 따라서 TC에서만은 각 debounce의 파라미터가 배열 형태임.
110+ expect ( debounced . calls . allArgs ( ) ) . toEqual ( [
111+ [ [ 'hello' ] ] ,
112+ [ [ 'hello' ] ] ,
113+ [ [ 'hello' ] ] ,
114+ [ [ 'hello' ] ]
115+ ] ) ;
116+ } ) ;
117+
84118 it ( 'reset can remove slugs related with throttling.' , function ( ) {
85119 var magazine = [ 1 , 3 , 6 , 8 , 9 ] ,
86120 fireGun = reload ( magazine ) ,
0 commit comments