Fix Failing test: Jest Tests.x-pack/plugins/lens/common/expressions/time_scale - time_scale should work with relative time range (#142837)

Closes: #142820
This commit is contained in:
Alexey Antonov 2022-10-06 17:23:53 +03:00 committed by GitHub
parent a231f9c4fd
commit 42f0868a04
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -22,7 +22,11 @@ describe('time_scale', () => {
context?: ExecutionContext
) => Promise<Datatable>;
const timeScale = getTimeScale(createDatatableUtilitiesMock, () => 'UTC');
const timeScale = getTimeScale(
createDatatableUtilitiesMock,
() => 'UTC',
() => new Date('2010-01-04T06:30:30')
);
const emptyTable: Datatable = {
type: 'datatable',
@ -390,7 +394,6 @@ describe('time_scale', () => {
...emptyTable,
rows: [
{
date: moment('2010-01-01T00:00:00.000Z').valueOf(),
metric: 300,
},
],
@ -419,7 +422,6 @@ describe('time_scale', () => {
...emptyTable,
rows: [
{
date: moment().subtract('1d').valueOf(),
metric: 300,
},
],
@ -432,14 +434,14 @@ describe('time_scale', () => {
{
getSearchContext: () => ({
timeRange: {
from: 'now-10d',
from: 'now-2d',
to: 'now',
},
}),
} as unknown as ExecutionContext
);
expect(result.rows.map(({ scaledMetric }) => scaledMetric)).toEqual([30]);
expect(result.rows.map(({ scaledMetric }) => scaledMetric)).toEqual([150]);
});
it('should apply fn for non-histogram fields (with Reduced time range)', async () => {