From 2caf0864aa94d3f80f5f352b86b49ff11c25663c Mon Sep 17 00:00:00 2001 From: Alvaro Viebrantz Date: Wed, 17 Apr 2024 11:41:41 -0400 Subject: [PATCH] test: add test for missing range input --- test/bigquery.ts | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/test/bigquery.ts b/test/bigquery.ts index 4fcf93e6..4d760931 100644 --- a/test/bigquery.ts +++ b/test/bigquery.ts @@ -1122,6 +1122,36 @@ describe('BigQuery', () => { ); assert.strictEqual(timestampRange.elementType, 'TIMESTAMP'); }); + + it('should accept a Range with start and/or end missing', () => { + const dateRange = bq.range( + { + start: '2020-01-01', + }, + 'DATE' + ); + assert.strictEqual( + dateRange.literalValue, + 'RANGE [2020-01-01, UNBOUNDED)' + ); + + const datetimeRange = bq.range( + { + end: '2020-12-31 12:00:00', + }, + 'DATETIME' + ); + assert.strictEqual( + datetimeRange.literalValue, + 'RANGE [UNBOUNDED, 2020-12-31 12:00:00)' + ); + + const timestampRange = bq.range({}, 'TIMESTAMP'); + assert.strictEqual( + timestampRange.literalValue, + 'RANGE [UNBOUNDED, UNBOUNDED)' + ); + }); }); describe('geography', () => {