launchdarkly / jest-launchdarkly-mock

Easily unit test LaunchDarkly feature flagged components with jest
Apache License 2.0
25 stars 19 forks source link

Allow `mockFlags` to take an unmodified string #14

Closed tylerwgrass closed 2 years ago

tylerwgrass commented 2 years ago

Problem

When passing a string to mockFlags, it converts the string using lodash.kebabcase and lodash.camelcase, but does not also store the original string: https://github.com/launchdarkly-labs/jest-launchdarkly-mock/blob/4a9f50510c6057f43a54cb1677f99f1b0fe402bf/src/index.ts#L44-L53

This causes issues where if the flag is not a "valid" kebab-case string or camelCase string, it is not included in the flags set. For example, the flag Client-MyCoolFlag gets converted to client-my-cool-flag and clientMyCoolFlag, neither of which are the original flag.

Recommendation

Also store the original string in the flags set to allow flags that don't conform exactly to camel or kebab casing to be mocked properly.

jermspeaks commented 2 years ago

Reviewing a similar issue, it would appear #7 solves this issue.

@bwoskow-ld any way we could expedite this?

yusinto commented 2 years ago

7 has been merged and will be released shortly. Apologies for the long wait.