Skip to content

Commit

Permalink
Fix Failing test: Jest Tests.x-pack/plugins/lens/common/expressions/t…
Browse files Browse the repository at this point in the history
…ime_scale - time_scale should work with relative time range (#142837)

Closes: #142820
  • Loading branch information
alexwizp authored Oct 6, 2022
1 parent a231f9c commit 42f0868
Showing 1 changed file with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -390,7 +394,6 @@ describe('time_scale', () => {
...emptyTable,
rows: [
{
date: moment('2010-01-01T00:00:00.000Z').valueOf(),
metric: 300,
},
],
Expand Down Expand Up @@ -419,7 +422,6 @@ describe('time_scale', () => {
...emptyTable,
rows: [
{
date: moment().subtract('1d').valueOf(),
metric: 300,
},
],
Expand All @@ -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 () => {
Expand Down

0 comments on commit 42f0868

Please sign in to comment.