-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[issue-#6] Include flag as is (no case formatting) #7
[issue-#6] Include flag as is (no case formatting) #7
Conversation
const kebab = kebabCase(k) | ||
const camel = camelCase(k) | ||
result[kebab] = flags[k] | ||
result[camel] = flags[k] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the PR and apologies for the long wait. Instead of skipping formatting (or aliasing) we can add the original flag key as-is so the pristine value is returned in this function. This way we can support all cases without having to set any extra options:
export const mockFlags = (flags: LDFlagSet) => {
mockUseFlags.mockImplementation(() => {
const result: LDFlagSet = {}
Object.keys(flags).forEach((k) => {
const kebab = kebabCase(k)
const camel = camelCase(k)
result[kebab] = flags[k]
result[camel] = flags[k]
result[k] = flags[k] // Add the original flag key and value here
})
return result
})
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's ok @yusinto , I've made the changes you suggested
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @tboulis ! I'll go ahead and merge this now. I will make a release soon. Thanks again.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure @yusinto !
Co-authored-by: Yusinto Ngadiman <[email protected]>
Added optional second parameter to
mockFlags()
function that is of type:If skipFormatting is true, the flags will be mocked without formatting them to camelCase and kebab-case.
Related to #6
EDIT #1:
Based on code review comment, the original flag is added as-is so the pristine value is returned