Skip to content

Commit

Permalink
chore: addressed comments
Browse files Browse the repository at this point in the history
  • Loading branch information
aashishmalik committed Feb 29, 2024
1 parent a0493a0 commit 0582f0a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/v0/util/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2208,8 +2208,8 @@ const combineBatchRequestsWithSameJobIds = (inputBatches) => {
* @returns {string} Event name converted to string.
*/
const validateEventAndLowerCaseConversion = (event, isMandatory, convertToLowerCase) => {
if (typeof event === 'object' || !isDefined(event)) {
throw new InstrumentationError('Event should not be a object, function, NaN or undefined');
if (!isDefined(event) || typeof event === 'object' || typeof event === 'boolean') {
throw new InstrumentationError('Event should not be a object, NaN, boolean or undefined');

Check warning on line 2212 in src/v0/util/index.js

View check run for this annotation

Codecov / codecov/patch

src/v0/util/index.js#L2212

Added line #L2212 was not covered by tests
}

// handling 0 as it is a valid value
Expand Down
9 changes: 9 additions & 0 deletions src/v0/util/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -496,4 +496,13 @@ describe('validateEventAndLowerCaseConversion Tests', () => {
validateEventAndLowerCaseConversion(undefined, false, true);
}).toThrow(InstrumentationError);
});

it('should throw error for boolean values', () => {
expect(() => {
validateEventAndLowerCaseConversion(true, true, true);
}).toThrow(InstrumentationError);
expect(() => {
validateEventAndLowerCaseConversion(false, false, false);
}).toThrow(InstrumentationError);
});
});

0 comments on commit 0582f0a

Please sign in to comment.