diff --git a/package.json b/package.json index 1a04470..128d346 100644 --- a/package.json +++ b/package.json @@ -40,6 +40,7 @@ "pascal-case" ], "devDependencies": { + "@fast-check/ava": "^2.0.2", "ava": "^5.3.1", "tsd": "^0.28.1", "xo": "^0.55.1" diff --git a/test.js b/test.js index 4a013f8..8c6b9bd 100644 --- a/test.js +++ b/test.js @@ -1,4 +1,5 @@ import test from 'ava'; +import {fc, testProp} from '@fast-check/ava'; import camelCase from './index.js'; test('camelCase', t => { @@ -236,6 +237,21 @@ test('invalid input', t => { }); }); +const localeArb = fc.constantFrom('tr-TR', 'en-EN', 'en-GB'); +testProp.failing('camelCase idempotence', [ + fc.string(), + fc.record({ + locale: fc.oneof(fc.boolean(), localeArb, fc.uniqueArray(localeArb)), + pascalCase: fc.boolean(), + preserveConsecutiveUppercase: fc.boolean(), + }), +], (t, string, options) => { + const camelCased = camelCase(string, options); + const doubleCamelCased = camelCase(camelCased, options); + + t.is(doubleCamelCased, camelCased); +}); + /* eslint-disable no-extend-native */ const withLocaleCaseFunctionsMocked = fn => { const throwWhenBeingCalled = () => {