@@ -69,7 +69,7 @@ describe(__filename, function(){
6969 . reply ( 404 ) ;
7070
7171 debuglet . once ( 'initError' , function ( err ) {
72- assert ( err ) ;
72+ assert . ok ( err ) ;
7373 scope . done ( ) ;
7474 done ( ) ;
7575 } ) ;
@@ -111,7 +111,7 @@ describe(__filename, function(){
111111 } ) ;
112112
113113 debuglet . once ( 'registered' , function ( id ) {
114- assert ( id === DEBUGGEE_ID ) ;
114+ assert . equal ( id , DEBUGGEE_ID ) ;
115115 scope . done ( ) ;
116116 done ( ) ;
117117 } ) ;
@@ -137,15 +137,26 @@ describe(__filename, function(){
137137 } ) ;
138138
139139 debuglet . once ( 'registered' , function ( id ) {
140- assert ( id === DEBUGGEE_ID ) ;
140+ assert . equal ( id , DEBUGGEE_ID ) ;
141141 scope . done ( ) ;
142142 done ( ) ;
143143 } ) ;
144144
145145 debuglet . start ( ) ;
146146 } ) ;
147147
148- it ( 'should error if a package.json doesn\'t exist' ) ;
148+ it ( 'should error if a package.json doesn\'t exist' , function ( done ) {
149+ var config = extend ( { } , defaultConfig ,
150+ { projectId : 'fake-project' , workingDirectory : __dirname } ) ;
151+ debuglet = new Debuglet ( fakeDebug , config , logger ) ;
152+
153+ debuglet . once ( 'initError' , function ( err ) {
154+ assert ( err ) ;
155+ done ( ) ;
156+ } ) ;
157+
158+ debuglet . start ( ) ;
159+ } ) ;
149160
150161 it ( 'should register successfully otherwise' , function ( done ) {
151162 var config = extend ( { } , defaultConfig , { projectId : 'fake-project' } ) ;
@@ -160,7 +171,7 @@ describe(__filename, function(){
160171 } ) ;
161172
162173 debuglet . once ( 'registered' , function ( id ) {
163- assert ( id === DEBUGGEE_ID ) ;
174+ assert . equal ( id , DEBUGGEE_ID ) ;
164175 scope . done ( ) ;
165176 done ( ) ;
166177 } ) ;
@@ -186,7 +197,7 @@ describe(__filename, function(){
186197 } ) ;
187198
188199 debuglet . once ( 'registered' , function ( id ) {
189- assert ( id === DEBUGGEE_ID ) ;
200+ assert . equal ( id , DEBUGGEE_ID ) ;
190201 scope . done ( ) ;
191202 process . chdir ( '../..' ) ;
192203 done ( ) ;
@@ -195,11 +206,103 @@ describe(__filename, function(){
195206 debuglet . start ( ) ;
196207 } ) ;
197208
198- it ( 'should de-activate when the server responds with isDisabled' ) ;
209+ it ( 'should de-activate when the server responds with isDisabled' , function ( done ) {
210+ this . timeout ( 4000 ) ;
211+ var config = extend ( { } , defaultConfig , { projectId : 'fake-project' } ) ;
212+ debuglet = new Debuglet ( fakeDebug , config , logger ) ;
213+
214+ var scope = nock ( API )
215+ . post ( REGISTER_PATH )
216+ . reply ( 200 , {
217+ debuggee : {
218+ id : DEBUGGEE_ID ,
219+ isDisabled : true
220+ }
221+ } )
222+ . post ( REGISTER_PATH )
223+ . reply ( 200 , {
224+ debuggee : {
225+ id : DEBUGGEE_ID
226+ }
227+ } ) ;
228+
229+ debuglet . once ( 'registered' , function ( id ) {
230+ assert . equal ( id , DEBUGGEE_ID ) ;
231+ setImmediate ( function ( ) {
232+ assert . ok ( debuglet . fetcherActive_ ) ;
233+ scope . done ( ) ;
234+ done ( ) ;
235+ } ) ;
236+ } ) ;
237+
238+ setTimeout ( function ( ) {
239+ assert . ok ( ! debuglet . fetcherActive_ ) ;
240+ } , 1000 ) ;
241+
242+ debuglet . start ( ) ;
243+ } ) ;
244+
245+ it ( 'should re-register when registration expires' , function ( done ) {
246+ var config = extend ( { } , defaultConfig , { projectId : 'fake-project' } ) ;
247+ debuglet = new Debuglet ( fakeDebug , config , logger ) ;
248+
249+ var scope = nock ( API )
250+ . post ( REGISTER_PATH )
251+ . reply ( 200 , {
252+ debuggee : {
253+ id : DEBUGGEE_ID
254+ }
255+ } )
256+ . get ( BPS_PATH + '?success_on_timeout=true' )
257+ . reply ( 404 )
258+ . post ( REGISTER_PATH )
259+ . reply ( 200 , {
260+ debuggee : {
261+ id : DEBUGGEE_ID
262+ }
263+ } ) ;
264+
265+ debuglet . once ( 'registered' , function ( id ) {
266+ assert . equal ( id , DEBUGGEE_ID ) ;
267+ debuglet . once ( 'registered' , function ( id ) {
268+ assert . equal ( id , DEBUGGEE_ID ) ;
269+ scope . done ( ) ;
270+ done ( ) ;
271+ } ) ;
272+ } ) ;
273+
274+ debuglet . start ( ) ;
275+ } ) ;
276+
277+ it ( 'should fetch and add breakpoints' , function ( done ) {
278+ this . timeout ( 2000 ) ;
199279
200- it ( 'should re-register when registration expires' ) ;
280+ var config = extend ( { } , defaultConfig , { projectId : 'fake-project' } ) ;
281+ debuglet = new Debuglet ( fakeDebug , config , logger ) ;
201282
202- it ( 'should fetch breakpoints' ) ;
283+ var scope = nock ( API )
284+ . post ( REGISTER_PATH )
285+ . reply ( 200 , {
286+ debuggee : {
287+ id : DEBUGGEE_ID
288+ }
289+ } )
290+ . get ( BPS_PATH + '?success_on_timeout=true' )
291+ . reply ( 200 , {
292+ breakpoints : [ bp ]
293+ } ) ;
294+
295+ debuglet . once ( 'registered' , function reg ( id ) {
296+ assert . equal ( id , DEBUGGEE_ID ) ;
297+ setTimeout ( function ( ) {
298+ assert . deepEqual ( debuglet . activeBreakpointMap_ . test , bp ) ;
299+ scope . done ( ) ;
300+ done ( ) ;
301+ } , 1000 ) ;
302+ } ) ;
303+
304+ debuglet . start ( ) ;
305+ } ) ;
203306
204307 it ( 'should re-fetch breakpoints on error' , function ( done ) {
205308 this . timeout ( 6000 ) ;
@@ -238,7 +341,7 @@ describe(__filename, function(){
238341 . reply ( 200 ) ;
239342
240343 debuglet . once ( 'registered' , function reg ( id ) {
241- assert ( id === DEBUGGEE_ID ) ;
344+ assert . equal ( id , DEBUGGEE_ID ) ;
242345 setTimeout ( function ( ) {
243346 assert . deepEqual ( debuglet . activeBreakpointMap_ . test , bp ) ;
244347 assert ( ! debuglet . activeBreakpointMap_ . testLog ) ;
@@ -250,8 +353,6 @@ describe(__filename, function(){
250353 debuglet . start ( ) ;
251354 } ) ;
252355
253- it ( 'should add a breakpoint' ) ;
254-
255356 it ( 'should expire stale breakpoints' , function ( done ) {
256357 var config = extend ( { } , defaultConfig , {
257358 projectId : 'fake-project' ,
@@ -278,7 +379,7 @@ describe(__filename, function(){
278379
279380 debuglet = new Debuglet ( fakeDebug , config , logger ) ;
280381 debuglet . once ( 'registered' , function ( id ) {
281- assert ( id === DEBUGGEE_ID ) ;
382+ assert . equal ( id , DEBUGGEE_ID ) ;
282383 setTimeout ( function ( ) {
283384 assert . deepEqual ( debuglet . activeBreakpointMap_ . test , bp ) ;
284385 setTimeout ( function ( ) {
@@ -330,7 +431,7 @@ describe(__filename, function(){
330431
331432 debuglet = new Debuglet ( fakeDebug , config , logger ) ;
332433 debuglet . once ( 'registered' , function ( id ) {
333- assert ( id === DEBUGGEE_ID ) ;
434+ assert . equal ( id , DEBUGGEE_ID ) ;
334435 setTimeout ( function ( ) {
335436 assert . deepEqual ( debuglet . activeBreakpointMap_ . test , bp ) ;
336437 setTimeout ( function ( ) {
0 commit comments