@@ -515,7 +515,7 @@ describe('GrpcService', function() {
515515
516516 describe ( 'request' , function ( ) {
517517 var PROTO_OPTS = { service : 'service' , method : 'method' , timeout : 3000 } ;
518- var REQ_OPTS = { } ;
518+ var REQ_OPTS = { reqOpts : true } ;
519519 var GRPC_CREDENTIALS = { } ;
520520
521521 function ProtoService ( ) { }
@@ -747,9 +747,8 @@ describe('GrpcService', function() {
747747 it ( 'should decorate the request' , function ( done ) {
748748 var decoratedRequest = { } ;
749749
750- fakeUtil . decorateRequest = function ( reqOpts , config ) {
751- assert . strictEqual ( reqOpts , REQ_OPTS ) ;
752- assert . deepEqual ( config , { projectId : grpcService . projectId } ) ;
750+ grpcService . decorateRequest_ = function ( reqOpts ) {
751+ assert . deepEqual ( reqOpts , REQ_OPTS ) ;
753752 return decoratedRequest ;
754753 } ;
755754
@@ -770,7 +769,7 @@ describe('GrpcService', function() {
770769 var error = new Error ( 'Error.' ) ;
771770
772771 it ( 'should return a thrown error to the callback' , function ( done ) {
773- fakeUtil . decorateRequest = function ( ) {
772+ grpcService . decorateRequest_ = function ( ) {
774773 throw error ;
775774 } ;
776775
@@ -787,7 +786,7 @@ describe('GrpcService', function() {
787786 grpcService . getService_ = function ( ) {
788787 return {
789788 method : function ( reqOpts ) {
790- assert . strictEqual ( reqOpts , REQ_OPTS ) ;
789+ assert . deepEqual ( reqOpts , REQ_OPTS ) ;
791790 done ( ) ;
792791 }
793792 } ;
@@ -1063,9 +1062,8 @@ describe('GrpcService', function() {
10631062 it ( 'should decorate the request' , function ( done ) {
10641063 var decoratedRequest = { } ;
10651064
1066- fakeUtil . decorateRequest = function ( reqOpts , config ) {
1065+ grpcService . decorateRequest_ = function ( reqOpts ) {
10671066 assert . strictEqual ( reqOpts , REQ_OPTS ) ;
1068- assert . deepEqual ( config , { projectId : grpcService . projectId } ) ;
10691067 return decoratedRequest ;
10701068 } ;
10711069
@@ -1084,7 +1082,7 @@ describe('GrpcService', function() {
10841082 it ( 'should end stream with a thrown error' , function ( done ) {
10851083 var error = new Error ( 'Error.' ) ;
10861084
1087- fakeUtil . decorateRequest = function ( ) {
1085+ grpcService . decorateRequest_ = function ( ) {
10881086 throw error ;
10891087 } ;
10901088
@@ -1340,9 +1338,8 @@ describe('GrpcService', function() {
13401338 it ( 'should decorate the request' , function ( done ) {
13411339 var decoratedRequest = { } ;
13421340
1343- fakeUtil . decorateRequest = function ( reqOpts , config ) {
1341+ grpcService . decorateRequest_ = function ( reqOpts ) {
13441342 assert . strictEqual ( reqOpts , REQ_OPTS ) ;
1345- assert . deepEqual ( config , { projectId : grpcService . projectId } ) ;
13461343 return decoratedRequest ;
13471344 } ;
13481345
@@ -1360,7 +1357,7 @@ describe('GrpcService', function() {
13601357 var error = new Error ( 'Error.' ) ;
13611358
13621359 it ( 'should end stream with a thrown error' , function ( done ) {
1363- fakeUtil . decorateRequest = function ( ) {
1360+ grpcService . decorateRequest_ = function ( ) {
13641361 throw error ;
13651362 } ;
13661363
@@ -1660,6 +1657,41 @@ describe('GrpcService', function() {
16601657 } ) ;
16611658 } ) ;
16621659
1660+ describe ( 'decorateRequest_' , function ( ) {
1661+ it ( 'should delete custom API values without modifying object' , function ( ) {
1662+ var reqOpts = {
1663+ autoPaginate : true ,
1664+ autoPaginateVal : true ,
1665+ objectMode : true
1666+ } ;
1667+
1668+ var originalReqOpts = extend ( { } , reqOpts ) ;
1669+
1670+ assert . deepEqual ( grpcService . decorateRequest_ ( reqOpts ) , { } ) ;
1671+ assert . deepEqual ( reqOpts , originalReqOpts ) ;
1672+ } ) ;
1673+
1674+ it ( 'should execute and return replaceProjectIdToken' , function ( ) {
1675+ var reqOpts = {
1676+ a : 'b' ,
1677+ c : 'd'
1678+ } ;
1679+
1680+ var replacedReqOpts = { } ;
1681+
1682+ fakeUtil . replaceProjectIdToken = function ( reqOpts_ , projectId ) {
1683+ assert . deepEqual ( reqOpts_ , reqOpts ) ;
1684+ assert . strictEqual ( projectId , grpcService . projectId ) ;
1685+ return replacedReqOpts ;
1686+ } ;
1687+
1688+ assert . strictEqual (
1689+ grpcService . decorateRequest_ ( reqOpts ) ,
1690+ replacedReqOpts
1691+ ) ;
1692+ } ) ;
1693+ } ) ;
1694+
16631695 describe ( 'getGrpcCredentials_' , function ( ) {
16641696 it ( 'should get credentials from the auth client' , function ( done ) {
16651697 grpcService . authClient = {
@@ -1698,6 +1730,7 @@ describe('GrpcService', function() {
16981730 beforeEach ( function ( ) {
16991731 grpcService . authClient = {
17001732 getAuthClient : function ( callback ) {
1733+ grpcService . authClient = AUTH_CLIENT ;
17011734 callback ( null , AUTH_CLIENT ) ;
17021735 }
17031736 } ;
0 commit comments