From ba1a4b783aaaf1f6b119de488242af7809501d38 Mon Sep 17 00:00:00 2001 From: Nathan L Smith Date: Tue, 26 Jan 2021 14:07:40 -0600 Subject: [PATCH] test fix --- .../context/url_params_context/helpers.test.ts | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/x-pack/plugins/apm/public/context/url_params_context/helpers.test.ts b/x-pack/plugins/apm/public/context/url_params_context/helpers.test.ts index 1f5d87f2e55023..52df1e0054505e 100644 --- a/x-pack/plugins/apm/public/context/url_params_context/helpers.test.ts +++ b/x-pack/plugins/apm/public/context/url_params_context/helpers.test.ts @@ -10,6 +10,21 @@ import * as helpers from './helpers'; describe('url_params_context helpers', () => { describe('getDateRange', () => { + describe('with non-rounded dates', () => { + it('rounds the values', () => { + expect( + helpers.getDateRange({ + state: {}, + rangeFrom: '1970-01-05T01:22:33.234Z', + rangeTo: '1971-01-10T10:11:12.123Z', + }) + ).toEqual({ + start: '1970-01-01T00:00:00.000Z', + end: '1971-02-01T00:00:00.000Z', + }); + }); + }); + describe('when rangeFrom and rangeTo are not changed', () => { it('returns the previous state', () => { expect( @@ -32,7 +47,9 @@ describe('url_params_context helpers', () => { describe('when rangeFrom or rangeTo are falsy', () => { it('returns the previous state', () => { + // Disable console warning about not receiving a valid date for rangeFrom jest.spyOn(console, 'warn').mockImplementationOnce(() => {}); + expect( helpers.getDateRange({ state: {