1- var chai = require ( "chai" ) ;
1+ var chai = require ( 'chai' ) ;
2+ var Promise = require ( 'bluebird' ) ;
23var nodeRestPromised = require ( '../index' ) ;
3- var it = require ( " mocha" ) . it ;
4- var describe = require ( " mocha" ) . describe ;
4+ var it = require ( ' mocha' ) . it ;
5+ var describe = require ( ' mocha' ) . describe ;
56
67var should = chai . should ( ) ;
78describe ( 'node-rest-client-promise' , function ( ) {
89 describe ( 'client' , function ( ) {
910 it ( 'should generate the promisified methods' , function ( ) {
11+ // eslint-disable-next-line new-cap
1012 var client = nodeRestPromised . Client ( { } ) ;
1113
1214 client . should . hasOwnProperty (
@@ -36,21 +38,14 @@ describe('node-rest-client-promise', function () {
3638
3739 } ) ;
3840
39- it ( 'should provide working promises' , function ( done ) {
41+ it ( 'should provide working promises' , function ( ) {
4042
43+ // eslint-disable-next-line new-cap
4144 var client = nodeRestPromised . Client ( { } ) ;
4245
43- client . getPromise (
46+ return client . getPromise (
4447 'https://www.google.de'
4548 )
46- . catch (
47- function ( error ) {
48- should . not . exist (
49- error ,
50- 'Got error: ' + error . message
51- ) ;
52- }
53- )
5449 . then (
5550 function ( result ) {
5651 result . response . statusCode
@@ -65,4 +60,24 @@ describe('node-rest-client-promise', function () {
6560
6661 } ) ;
6762 } ) ;
63+ describe ( 'client#registerMethod' , function ( ) {
64+ it ( 'should add a promise' , function ( ) {
65+ // eslint-disable-next-line new-cap
66+ var client = nodeRestPromised . Client ( { } ) ;
67+
68+ client . registerMethodPromise (
69+ 'testMethod' , 'https://somedomain' , 'GET'
70+ ) ;
71+
72+ return client . methods . testMethod ( )
73+ . catch (
74+ function ( e ) {
75+ return e . code === 'ENOTFOUND' ;
76+ } ,
77+ function ( ) {
78+ return Promise . resolve ( ) ;
79+ }
80+ ) ;
81+ } ) ;
82+ } ) ;
6883} ) ;
0 commit comments