Skip to content

Commit

Permalink
fix(datetimepicker): fix offset and tests updates
Browse files Browse the repository at this point in the history
  • Loading branch information
cgirani committed Sep 8, 2020
1 parent 86af52a commit 315f655
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/components/DateTimePicker/DateTimePicker.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,7 @@ const DateTimePicker = ({
// If value was changed reset when going back to Preset
if (absoluteValue.startDate !== '' || relativeValue.lastNumber > 0) {
if (selectedPreset) {
onPresetClick(presets.filter(x => x.offset === selectedPreset)[0]);
onPresetClick(presets.filter(x => x.id === selectedPreset)[0]);
resetAbsoluteValue();
resetRelativeValue();
} else {
Expand Down
5 changes: 5 additions & 0 deletions src/components/DateTimePicker/DateTimePicker.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -427,22 +427,27 @@ describe('DateTimePicker', () => {

const presets = [
{
id: 'item-01',
label: 'last-30-min',
offset: 30,
},
{
id: 'item-02',
label: 'last-1-hour',
offset: 60,
},
{
id: 'item-03',
label: 'last-6-hour',
offset: 360,
},
{
id: 'item-04',
label: 'last-12-hour',
offset: 720,
},
{
id: 'item-05',
label: 'last-24-hour',
offset: 1440,
},
Expand Down
9 changes: 9 additions & 0 deletions src/utils/__tests__/__snapshots__/publicAPI.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -5182,22 +5182,27 @@ Map {
"onCancel": null,
"presets": Array [
Object {
"id": "item-01",
"label": "Last 30 minutes",
"offset": 30,
},
Object {
"id": "item-02",
"label": "Last 1 hour",
"offset": 60,
},
Object {
"id": "item-03",
"label": "Last 6 hours",
"offset": 360,
},
Object {
"id": "item-04",
"label": "Last 12 hours",
"offset": 720,
},
Object {
"id": "item-05",
"label": "Last 24 hours",
"offset": 1440,
},
Expand Down Expand Up @@ -5237,6 +5242,10 @@ Map {
"timeRangeValue": Object {
"args": Array [
Object {
"id": Object {
"isRequired": true,
"type": "string",
},
"label": Object {
"isRequired": true,
"type": "string",
Expand Down

0 comments on commit 315f655

Please sign in to comment.