11var Tunnel = require ( '../' ) ,
22 _ = require ( 'lodash' ) ,
3- q = require ( 'q ' ) ,
3+ Promise = require ( 'bluebird ' ) ,
44 childProcess = require ( 'child_process' ) ,
55 events = require ( 'events' ) ,
66 util = require ( 'util' ) ;
@@ -44,7 +44,7 @@ describe('Tunnel', function () {
4444
4545 it ( 'should set default timeout as 10 seconds' , function ( ) {
4646 var tunnel = createTunnel ( ) ,
47- timeout = sandbox . stub ( q . makePromise . prototype , 'timeout' ) ; // promise constructor available like this?!
47+ timeout = sandbox . stub ( Promise . prototype , 'timeout' ) ;
4848
4949 tunnel . open ( ) ;
5050
@@ -59,7 +59,7 @@ describe('Tunnel', function () {
5959
6060 var result = tunnel . open ( ) ;
6161
62- expect ( q . isPromise ( result ) ) . to . be . true ;
62+ expect ( result ) . to . be . an . instanceof ( Promise ) ;
6363 } ) ;
6464
6565 describe ( 'tunnel spawn and events' , function ( ) {
@@ -215,7 +215,7 @@ describe('Tunnel', function () {
215215 tunnel = createTunnel ( ) ;
216216 tunnel . open ( ) ;
217217
218- expect ( q . isPromise ( tunnel . close ( ) ) ) . to . be . true ;
218+ expect ( tunnel . close ( ) ) . to . be . an . instanceof ( Promise ) ;
219219 } ) ;
220220
221221 it ( 'should try to kill tunnel using SIGTERM' , function ( ) {
@@ -252,14 +252,14 @@ describe('Tunnel', function () {
252252 describe ( 'openWithRetries' , function ( ) {
253253 beforeEach ( function ( ) {
254254 sandbox . stub ( Tunnel . prototype ) ;
255- Tunnel . prototype . open . returns ( q ( ) ) ;
256- Tunnel . prototype . close . returns ( q ( ) ) ;
255+ Tunnel . prototype . open . returns ( Promise . resolve ( ) ) ;
256+ Tunnel . prototype . close . returns ( Promise . resolve ( ) ) ;
257257 } ) ;
258258
259259 it ( 'should return promise' , function ( ) {
260260 var result = Tunnel . openWithRetries ( defaultOpts ( ) ) ;
261261
262- expect ( q . isPromise ( result ) ) . to . be . true ;
262+ expect ( result ) . to . be . an . instanceof ( Promise ) ;
263263 } ) ;
264264
265265 it ( 'should try to open tunnel with passed opts' , function ( ) {
@@ -271,37 +271,37 @@ describe('Tunnel', function () {
271271 } ) ;
272272
273273 it ( 'should resolve promise if tunnel opened successfully' , function ( ) {
274- Tunnel . prototype . open . returns ( q ( ) ) ;
274+ Tunnel . prototype . open . returns ( Promise . resolve ( ) ) ;
275275
276276 return expect ( Tunnel . openWithRetries ( defaultOpts ( ) ) ) . to . be . eventually . resolved ;
277277 } ) ;
278278
279279 it ( 'should resolve promise with tunnel instance' , function ( ) {
280- Tunnel . prototype . open . returns ( q ( ) ) ;
280+ Tunnel . prototype . open . returns ( Promise . resolve ( ) ) ;
281281
282282 return Tunnel . openWithRetries ( defaultOpts ( ) ) . then ( function ( tunnel ) {
283283 expect ( tunnel ) . to . be . instanceOf ( Tunnel ) ;
284284 } ) ;
285285 } ) ;
286286
287287 it ( 'should reject tunnel if failed to open tunnel after retries' , function ( ) {
288- Tunnel . prototype . open . returns ( q . reject ( ) ) ;
288+ Tunnel . prototype . open . returns ( Promise . reject ( ) ) ;
289289
290290 return expect ( Tunnel . openWithRetries ( defaultOpts ) ) . to . be . eventually . rejected ;
291291 } ) ;
292292
293293 it ( 'should retry to create tunnel 5 times by default' , function ( ) {
294- Tunnel . prototype . open . returns ( q . reject ( ) ) ;
294+ Tunnel . prototype . open . returns ( Promise . reject ( ) ) ;
295295
296- return Tunnel . openWithRetries ( defaultOpts ( ) ) . fail ( function ( ) {
296+ return Tunnel . openWithRetries ( defaultOpts ( ) ) . catch ( function ( ) {
297297 expect ( Tunnel . prototype . open . callCount ) . to . be . equal ( 5 ) ;
298298 } ) ;
299299 } ) ;
300300
301301 it ( 'should retry create tunnel retries times' , function ( ) {
302- Tunnel . prototype . open . returns ( q . reject ( ) ) ;
302+ Tunnel . prototype . open . returns ( Promise . reject ( ) ) ;
303303
304- return Tunnel . openWithRetries ( defaultOpts ( ) , 10 ) . fail ( function ( ) {
304+ return Tunnel . openWithRetries ( defaultOpts ( ) , 10 ) . catch ( function ( ) {
305305 expect ( Tunnel . prototype . open . callCount ) . to . be . equal ( 10 ) ;
306306 } ) ;
307307 } ) ;
0 commit comments