Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
VladLasitsa committed May 4, 2022
1 parent 2fc8a44 commit 1cdb5c0
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ const errors = {
}),
isInvalidIntervalError: () =>
i18n.translate('expressionXY.reusable.function.xyVis.errors.isInvalidIntervalError', {
defaultMessage: 'Provided x-axis interval is invalid',
defaultMessage:
'Provided x-axis interval is invalid. The interval should includes quantity and unit name like 1d, 24h, 1w.',
}),
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ export const strings = {
defaultMessage: 'Specifies the aria label of the xy chart',
}),
getXAxisIntervalHelp: () =>
i18n.translate('expressionXY.xyVis.ariaLabel.help', {
i18n.translate('expressionXY.xyVis.xAxisInterval.help', {
defaultMessage: 'Specifies the interval for x-axis',
}),
getDataLayerFnHelp: () =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,18 @@ describe('calculateMinInterval', () => {
const result = await calculateMinInterval(xyProps);
expect(result).toEqual(undefined);
});

it('should return specified interval if user provided it as `xAxisInterval`', async () => {
layer.table.columns[2].meta.source = 'esaggs';
layer.table.columns[2].meta.sourceParams = {
type: 'date_histogram',
params: {
used_interval: '5m',
},
};
xyProps.args.layers[0] = layer;
xyProps.args.xAxisInterval = '1h';
const result = await calculateMinInterval(xyProps);
expect(result).toEqual(60 * 60 * 1000);
});
});

0 comments on commit 1cdb5c0

Please sign in to comment.