Skip to content

Commit

Permalink
Address PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
afharo committed Apr 12, 2022
1 parent 8b22fb7 commit 92d4f92
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
* Side Public License, v 1.
*/

import moment from 'moment';
import { formatPayload } from './format_payload';

describe('formatPayload', () => {
Expand Down Expand Up @@ -70,18 +69,6 @@ describe('formatPayload', () => {
});
});

test('appends `_date` to moment values', () => {
const payload = {
foo: moment(),
baz: [moment()],
};

expect(formatPayload(payload)).toEqual({
foo_date: payload.foo,
baz_dates: payload.baz,
});
});

test('supports nested values', () => {
const payload = {
nested: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,10 @@ function getFullStoryType(value: unknown) {
// For arrays, make the decision based on the first element
const isArray = Array.isArray(value);
const v = isArray ? value[0] : value;
let type = '';
let type: string;
switch (typeof v) {
case 'string':
if (moment(v, moment.ISO_8601, true).isValid()) {
type = 'date';
break;
}
type = 'str';
type = moment(v, moment.ISO_8601, true).isValid() ? 'date' : 'str';
break;
case 'number':
type = Number.isInteger(v) ? 'int' : 'real';
Expand All @@ -84,5 +80,5 @@ function isRecord(value: unknown): value is Record<string, unknown> {
}

function isDate(value: unknown): value is Date {
return value instanceof Date || moment.isMoment(value);
return value instanceof Date;
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/

import { loggerMock } from '@kbn/logging-mocks';
import { fullStoryApiMock } from './fullstory_shipper.mocks';
import { fullStoryApiMock } from './fullstory_shipper.test.mocks';
import { FullStoryShipper } from './fullstory_shipper';

describe('FullStoryShipper', () => {
Expand Down

0 comments on commit 92d4f92

Please sign in to comment.