Skip to content

Commit 7e92d2f

Browse files
common: add tests for index file
1 parent 77c83a1 commit 7e92d2f

5 files changed

Lines changed: 62 additions & 6 deletions

File tree

packages/common/test/grpc-service.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ var retryRequest = require('retry-request');
2727
var sinon = require('sinon').sandbox.create();
2828
var through = require('through2');
2929

30-
var util = require('../src/index.js').util;
30+
var util = require('../src/util.js');
3131

3232
function FakeService() {
3333
this.calledWith_ = arguments;

packages/common/test/index.js

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/**
2+
* Copyright 2016 Google Inc. All Rights Reserved.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
'use strict';
18+
19+
var assert = require('assert');
20+
var proxyquire = require('proxyquire');
21+
22+
var fakeGrpcOperation = {};
23+
var fakeGrpcService = {};
24+
var fakeGrpcServiceObject = {};
25+
var fakeService = {};
26+
var fakeServiceObject = {};
27+
var fakeStreamRouter = {};
28+
var fakeUtil = {};
29+
30+
describe('common', function() {
31+
var common;
32+
33+
before(function() {
34+
common = proxyquire('../src/index.js', {
35+
'./grpc-operation.js': fakeGrpcOperation,
36+
'./grpc-service.js': fakeGrpcService,
37+
'./grpc-service-object.js': fakeGrpcServiceObject,
38+
'./service.js': fakeService,
39+
'./service-object.js': fakeServiceObject,
40+
'./stream-router.js': fakeStreamRouter,
41+
'./util.js': fakeUtil
42+
});
43+
});
44+
45+
it('should correctly export the common modules', function() {
46+
assert.deepEqual(common, {
47+
GrpcOperation: fakeGrpcOperation,
48+
GrpcService: fakeGrpcService,
49+
GrpcServiceObject: fakeGrpcServiceObject,
50+
Service: fakeService,
51+
ServiceObject: fakeServiceObject,
52+
streamRouter: fakeStreamRouter,
53+
util: fakeUtil
54+
});
55+
});
56+
});

packages/common/test/service-object.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
var assert = require('assert');
2020
var extend = require('extend');
2121

22-
var ServiceObject = require('../src/index.js').ServiceObject;
23-
var util = require('../src/index.js').util;
22+
var ServiceObject = require('../src/service-object.js');
23+
var util = require('../src/util.js');
2424

2525
describe('ServiceObject', function() {
2626
var serviceObject;

packages/common/test/service.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ var assert = require('assert');
2020
var extend = require('extend');
2121
var proxyquire = require('proxyquire').noPreserveCache();
2222

23-
var util = require('../src/index.js').util;
23+
var util = require('../src/util.js');
2424

2525
var makeAuthenticatedRequestFactoryCache = util.makeAuthenticatedRequestFactory;
2626
var makeAuthenticatedRequestFactoryOverride;

packages/common/test/stream-router.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ var stream = require('stream');
2323
var through = require('through2');
2424
var uuid = require('node-uuid');
2525

26-
var streamRouter = require('../src/index.js').streamRouter;
27-
var util = require('../src/index.js').util;
26+
var streamRouter = require('../src/stream-router.js');
27+
var util = require('../src/util.js');
2828

2929
var overrides = {};
3030

0 commit comments

Comments
 (0)