@@ -199,6 +199,8 @@ describe('BaseView', () => {
199199 const realHrtimeFn = process . hrtime ;
200200 const realNowFn = Date . now ;
201201 const mockedTime : Timestamp = { seconds : 1450000100 , nanos : 1e7 } ;
202+ const mockStartTime = 1546540757282 ;
203+ const mockStartTimestamp : Timestamp = { seconds : 1546540757 , nanos : 282e6 } ;
202204 const measurementValues = [ 1.1 , 2.3 , 3.2 , 4.3 , 5.2 ] ;
203205 const buckets = [ 2 , 4 , 6 ] ;
204206 const tags : Tags = { testKey1 : 'testValue' , testKey2 : 'testValue' } ;
@@ -227,7 +229,7 @@ describe('BaseView', () => {
227229 TEST_ONLY . resetHrtimeFunctionCache ( ) ;
228230 } ) ;
229231
230- const { descriptor, timeseries} = view . getMetric ( ) ;
232+ const { descriptor, timeseries} = view . getMetric ( mockStartTime ) ;
231233
232234 describe (
233235 `Aggregation type: ${ aggregationTestCase . aggregationType } ` , ( ) => {
@@ -263,8 +265,7 @@ describe('BaseView', () => {
263265 assert . ok ( startTimestamp ) ;
264266 assert . equal ( typeof startTimestamp . nanos , 'number' ) ;
265267 assert . equal ( typeof startTimestamp . seconds , 'number' ) ;
266- assert . ok ( startTimestamp . seconds > 0 ) ;
267- assert . ok ( startTimestamp . nanos > 0 ) ;
268+ assert . deepStrictEqual ( startTimestamp , mockStartTimestamp ) ;
268269 } ) ;
269270 }
270271
@@ -288,8 +289,8 @@ describe('BaseView', () => {
288289 }
289290
290291 it ( 'should have point' , ( ) => {
291- const { timeseries} = view . getMetric ( ) ;
292- const [ { points} ] = timeseries ;
292+ const { timeseries} = view . getMetric ( mockStartTime ) ;
293+ const [ { points, startTimestamp } ] = timeseries ;
293294 assert . ok ( points ) ;
294295 const [ point ] = points ;
295296 const { timestamp, value} = point ;
@@ -306,6 +307,8 @@ describe('BaseView', () => {
306307 sum : total ,
307308 sumOfSquaredDeviation : 10.427999999999997
308309 } ) ;
310+
311+ assert . deepStrictEqual ( startTimestamp , mockStartTimestamp ) ;
309312 } ) ;
310313 } ) ;
311314
@@ -325,7 +328,7 @@ describe('BaseView', () => {
325328 }
326329
327330 it ( 'should have points' , ( ) => {
328- const { timeseries} = view . getMetric ( ) ;
331+ const { timeseries} = view . getMetric ( mockStartTime ) ;
329332 assert . equal ( timeseries . length , 2 ) ;
330333 const [ { labelValues : labelValues1 , points : points1 } , {
331334 labelValues : labelValues2 ,
@@ -383,8 +386,8 @@ describe('BaseView', () => {
383386 }
384387
385388 it ( 'should have point' , ( ) => {
386- const { timeseries} = view . getMetric ( ) ;
387- const [ { points} ] = timeseries ;
389+ const { timeseries} = view . getMetric ( mockStartTime ) ;
390+ const [ { points, startTimestamp } ] = timeseries ;
388391 assert . ok ( points ) ;
389392 const [ point ] = points ;
390393 const { timestamp, value} = point ;
@@ -395,6 +398,7 @@ describe('BaseView', () => {
395398 assert . equal ( timestamp . nanos , mockedTime . nanos ) ;
396399 assert . equal ( typeof value , 'number' ) ;
397400 assert . strictEqual ( value , 5 ) ;
401+ assert . deepStrictEqual ( startTimestamp , mockStartTimestamp ) ;
398402 } ) ;
399403 } ) ;
400404
@@ -410,8 +414,8 @@ describe('BaseView', () => {
410414 }
411415
412416 it ( 'should have point' , ( ) => {
413- const { timeseries} = view . getMetric ( ) ;
414- const [ { points} ] = timeseries ;
417+ const { timeseries} = view . getMetric ( mockStartTime ) ;
418+ const [ { points, startTimestamp } ] = timeseries ;
415419 assert . ok ( points ) ;
416420 const [ point ] = points ;
417421 const { timestamp, value} = point ;
@@ -422,6 +426,7 @@ describe('BaseView', () => {
422426 assert . equal ( timestamp . nanos , mockedTime . nanos ) ;
423427 assert . equal ( typeof value , 'number' ) ;
424428 assert . strictEqual ( value , total ) ;
429+ assert . deepStrictEqual ( startTimestamp , mockStartTimestamp ) ;
425430 } ) ;
426431 } ) ;
427432
@@ -435,8 +440,8 @@ describe('BaseView', () => {
435440 }
436441
437442 it ( 'should have point' , ( ) => {
438- const { timeseries} = view . getMetric ( ) ;
439- const [ { points} ] = timeseries ;
443+ const { timeseries} = view . getMetric ( mockStartTime ) ;
444+ const [ { points, startTimestamp } ] = timeseries ;
440445 assert . ok ( points ) ;
441446 const [ point ] = points ;
442447 const { timestamp, value} = point ;
@@ -445,6 +450,7 @@ describe('BaseView', () => {
445450 assert . equal ( typeof value , 'number' ) ;
446451 assert . strictEqual (
447452 value , measurementValues [ measurementValues . length - 1 ] ) ;
453+ assert . strictEqual ( startTimestamp , undefined ) ;
448454 } ) ;
449455 } ) ;
450456 } ) ;
0 commit comments