@@ -119,93 +119,6 @@ describe('Core base tests', function() {
119119 } ) ) . toEqual ( 'number=123' ) ;
120120 } ) ;
121121 } ) ;
122- describe ( 'Session heartbeat' , function ( ) {
123- var clock ,
124- oldConfig ,
125- counter ;
126-
127- beforeEach ( function ( ) {
128- clock = sinon . useFakeTimers ( ) ;
129- oldConfig = OC . config ;
130- counter = 0 ;
131-
132- fakeServer . autoRespond = true ;
133- fakeServer . autoRespondAfter = 0 ;
134- fakeServer . respondWith ( / \/ c s r f t o k e n / , function ( xhr ) {
135- counter ++ ;
136- xhr . respond ( 200 , { 'Content-Type' : 'application/json' } , '{"token": "pgBEsb3MzTb1ZPd2mfDZbQ6/0j3OrXHMEZrghHcOkg8=:3khw5PSa+wKQVo4f26exFD3nplud9ECjJ8/Y5zk5/k4="}' ) ;
137- } ) ;
138- $ ( document ) . off ( 'ajaxComplete' ) ; // ignore previously registered heartbeats
139- } ) ;
140- afterEach ( function ( ) {
141- clock . restore ( ) ;
142- /* jshint camelcase: false */
143- OC . config = oldConfig ;
144- $ ( document ) . off ( 'ajaxError' ) ;
145- $ ( document ) . off ( 'ajaxComplete' ) ;
146- } ) ;
147- it ( 'sends heartbeat half the session lifetime when heartbeat enabled' , function ( ) {
148- /* jshint camelcase: false */
149- OC . config = {
150- session_keepalive : true ,
151- session_lifetime : 300
152- } ;
153- window . initCore ( ) ;
154-
155- expect ( counter ) . toEqual ( 0 ) ;
156-
157- // less than half, still nothing
158- clock . tick ( 100 * 1000 ) ;
159- expect ( counter ) . toEqual ( 0 ) ;
160-
161- // reach past half (160), one call
162- clock . tick ( 55 * 1000 ) ;
163- expect ( counter ) . toEqual ( 1 ) ;
164-
165- // almost there to the next, still one
166- clock . tick ( 140 * 1000 ) ;
167- expect ( counter ) . toEqual ( 1 ) ;
168-
169- // past it, second call
170- clock . tick ( 20 * 1000 ) ;
171- expect ( counter ) . toEqual ( 2 ) ;
172- } ) ;
173- it ( 'does not send heartbeat when heartbeat disabled' , function ( ) {
174- /* jshint camelcase: false */
175- OC . config = {
176- session_keepalive : false ,
177- session_lifetime : 300
178- } ;
179- window . initCore ( ) ;
180-
181- expect ( counter ) . toEqual ( 0 ) ;
182-
183- clock . tick ( 1000000 ) ;
184-
185- // still nothing
186- expect ( counter ) . toEqual ( 0 ) ;
187- } ) ;
188- it ( 'limits the heartbeat between one minute and one day' , function ( ) {
189- /* jshint camelcase: false */
190- var setIntervalStub = sinon . stub ( window , 'setInterval' ) ;
191- OC . config = {
192- session_keepalive : true ,
193- session_lifetime : 5
194- } ;
195- window . initCore ( ) ;
196- expect ( setIntervalStub . getCall ( 0 ) . args [ 1 ] ) . toEqual ( 60 * 1000 ) ;
197- setIntervalStub . reset ( ) ;
198-
199- OC . config = {
200- session_keepalive : true ,
201- session_lifetime : 48 * 3600
202- } ;
203- window . initCore ( ) ;
204- expect ( setIntervalStub . getCall ( 0 ) . args [ 1 ] ) . toEqual ( 24 * 3600 * 1000 ) ;
205-
206- setIntervalStub . restore ( ) ;
207- } ) ;
208- } ) ;
209122 describe ( 'Parse query string' , function ( ) {
210123 it ( 'Parses query string from full URL' , function ( ) {
211124 var query = OC . parseQueryString ( 'http://localhost/stuff.php?q=a&b=x' ) ;
0 commit comments