-
Notifications
You must be signed in to change notification settings - Fork 113
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: adding check for reserved key words
- Loading branch information
1 parent
007009f
commit bc0c5fa
Showing
2 changed files
with
68 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -506,3 +506,50 @@ describe('validateEventAndLowerCaseConversion Tests', () => { | |
}).toThrow(InstrumentationError); | ||
}); | ||
}); | ||
|
||
describe('extractCustomFields', () => { | ||
// Handle reserved words in message keys | ||
it('should handle reserved words in message keys when keys are provided', () => { | ||
const message = { | ||
traits: { | ||
firstName: 'John', | ||
lastName: 'Doe', | ||
email: '[email protected]', | ||
}, | ||
context: { | ||
traits: { | ||
phone: '1234567890', | ||
city: 'New York', | ||
country: 'USA', | ||
}, | ||
}, | ||
properties: { | ||
title: 'Developer', | ||
organization: 'ABC Company', | ||
zip: '12345', | ||
prototype: 'reserved', | ||
}, | ||
}; | ||
|
||
const payload = {}; | ||
|
||
const keys = ['properties', 'context.traits', 'traits']; | ||
|
||
const exclusionFields = [ | ||
'firstName', | ||
'lastName', | ||
'phone', | ||
'title', | ||
'organization', | ||
'city', | ||
'region', | ||
'country', | ||
'zip', | ||
'image', | ||
'timezone', | ||
]; | ||
expect(() => { | ||
utilities.extractCustomFields(message, payload, keys, exclusionFields); | ||
}).toThrow(InstrumentationError); | ||
}); | ||
}); |