Skip to content

Commit 326c64e

Browse files
author
Luke Sneeringer
committed
Shift the Spanner.date check to multiple arguments.
1 parent 96704fd commit 326c64e

2 files changed

Lines changed: 7 additions & 5 deletions

File tree

packages/spanner/src/codec.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,11 @@ var commonGrpc = require('@google-cloud/common-grpc');
2626
var is = require('is');
2727

2828
function SpannerDate(value) {
29-
if (is.number(value)) {
30-
throw new TypeError('The spanner.date function accepts a Date object, ' +
31-
'or a string parseable by Date\'s constructor.');
29+
if (arguments.length > 1) {
30+
throw new TypeError(
31+
'The spanner.date function accepts a Date object, ' +
32+
'or a single argument parseable by Date\'s constructor.'
33+
);
3234
}
3335
if (is.undefined(value)) {
3436
value = new Date();

packages/spanner/test/codec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,9 @@ describe('codec', function() {
5454
assert.strictEqual(spannerDate.value, date.toJSON().replace(/T.+/, ''));
5555
});
5656

57-
it('should choke on an integer', function() {
57+
it('should choke on multiple arguments', function() {
5858
assert.throws(function() {
59-
new codec.SpannerDate(2017);
59+
new codec.SpannerDate(2012, 3, 21);
6060
}, /The spanner\.date function accepts a Date object,/);
6161
});
6262
});

0 commit comments

Comments
 (0)