launchdarkly / jest-launchdarkly-mock

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

Mock with useCamelCaseFlagKeys = false #6

Closed tboulis closed 2 years ago

tboulis commented 3 years ago

I've noticed in your code that you automatically convert the flags to kebab case and camelcase:

exports.mockFlags = function (flags) {
    mockUseFlags.mockImplementation(function () {
        var result = {};
        Object.keys(flags).forEach(function (k) {
            var kebab = lodash_kebabcase_1.default(k);
            var camel = lodash_camelcase_1.default(k);
            result[kebab] = flags[k];
            result[camel] = flags[k];
        });
        return result;
    });
};

We use flags with snake case. Is it possible to either configure this by passing a config object to mockFlags or by mocking the Provider that is returned from asyncWithLDProvider?

yusinto commented 2 years ago

Hi @tboulis we have an upcoming release to support snake case so it's coming. I'll update this issue when the release is published. Thank you for your patience.

yusinto commented 2 years ago

This is now fixed in v1.0.0.