1+ var should = require ( 'should' ) ;
2+ var apiToken = process . env . PIPEDRIVE_API_TOKEN || '' ;
3+
4+ //fixture — need deal with id 1
5+ describe ( 'client integration tests' , function ( ) {
6+
7+ it ( 'getting non-existant deal should return error' , function ( done ) {
8+ var Pipedrive = require ( './../..' ) ,
9+ pipedrive = new Pipedrive . Client ( apiToken , { strictMode : true } ) ;
10+
11+ pipedrive . Deals . get ( 99999 , function ( err , deal ) {
12+ should . notEqual ( err , null ) ;
13+ should . equal ( err . message , 'Pipedrive API error:Deal not found' ) ;
14+
15+ done ( ) ;
16+ } ) ;
17+
18+ should ( pipedrive . on ) . be . a . Function ( ) ;
19+ } ) ;
20+
21+ it ( 'adding non-existant product to existing deal (with id 1) should return error string in callback' , function ( done ) {
22+ var Pipedrive = require ( './../..' ) ,
23+ pipedrive = new Pipedrive . Client ( apiToken , { strictMode : true } ) ;
24+
25+ pipedrive . Deals . get ( 1 , function ( err , deal ) {
26+ should . equal ( err , null ) ;
27+
28+ deal . addProduct ( {
29+ product_id : 999999 ,
30+ quantity : 1 ,
31+ item_price : 0
32+ } , function ( addErr , addData ) {
33+
34+ should . notEqual ( addErr , null ) ;
35+ should . equal ( addErr . message , 'Pipedrive API error:Product(s) 1 not found.' ) ;
36+ done ( ) ;
37+ } ) ;
38+ } ) ;
39+
40+ should ( pipedrive . on ) . be . a . Function ( ) ;
41+ } ) ;
42+
43+ } ) ;
0 commit comments