@@ -73,6 +73,7 @@ describe('Bigtable', function() {
7373 } ) ;
7474
7575 beforeEach ( function ( ) {
76+ delete process . env . BIGTABLE_EMULATOR_HOST ;
7677 bigtable = new Bigtable ( { projectId : PROJECT_ID } ) ;
7778 } ) ;
7879
@@ -113,6 +114,7 @@ describe('Bigtable', function() {
113114 assert . strictEqual ( calledWith . baseUrl , 'bigtable.googleapis.com' ) ;
114115 assert . strictEqual ( calledWith . service , 'bigtable' ) ;
115116 assert . strictEqual ( calledWith . apiVersion , 'v2' ) ;
117+ assert . strictEqual ( calledWith . customEndpoint , false ) ;
116118
117119 assert . deepEqual ( calledWith . protoServices , {
118120 Bigtable : googleProtoFiles ( 'bigtable/v2/bigtable.proto' ) ,
@@ -146,6 +148,30 @@ describe('Bigtable', function() {
146148 assert . strictEqual ( calledWith . userAgent , PKG . name + '/' + PKG . version ) ;
147149 } ) ;
148150
151+ it ( 'should work with the emulator' , function ( ) {
152+ var endpoint = 'http://emulator:8288' ;
153+ process . env . BIGTABLE_EMULATOR_HOST = endpoint ;
154+
155+ var bigtable = new Bigtable ( { projectId : PROJECT_ID } ) ;
156+
157+ var calledWith = bigtable . calledWith_ [ 0 ] ;
158+ assert . strictEqual ( calledWith . baseUrl , endpoint ) ;
159+ assert . strictEqual ( calledWith . customEndpoint , true ) ;
160+ } ) ;
161+
162+ it ( 'should work with a custom apiEndpoint' , function ( ) {
163+ var options = {
164+ projectId : PROJECT_ID ,
165+ apiEndpoint : 'http://local:3888'
166+ } ;
167+
168+ var bigtable = new Bigtable ( options ) ;
169+
170+ var calledWith = bigtable . calledWith_ [ 0 ] ;
171+ assert . strictEqual ( calledWith . baseUrl , options . apiEndpoint ) ;
172+ assert . strictEqual ( calledWith . customEndpoint , true ) ;
173+ } ) ;
174+
149175 it ( 'should set the projectName' , function ( ) {
150176 assert . strictEqual ( bigtable . projectName , 'projects/' + PROJECT_ID ) ;
151177 } ) ;
0 commit comments