From 2bec5cb7fd2383a415c04ed67e9cf4cd2ce1d87e Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Wed, 4 Jul 2018 08:55:16 +0200 Subject: Fix bug in string enum assertion so that we check enum values not keys --- packages/assert/src/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'packages/assert') diff --git a/packages/assert/src/index.ts b/packages/assert/src/index.ts index 95c7b658b..8e18416c5 100644 --- a/packages/assert/src/index.ts +++ b/packages/assert/src/index.ts @@ -41,8 +41,8 @@ export const assert = { value: string, stringEnum: any /* There is no base type for every string enum */, ): void { - const doesBelongToStringEnum = !_.isUndefined(stringEnum[value]); - const enumValues = _.keys(stringEnum); + const enumValues = _.values(stringEnum); + const doesBelongToStringEnum = _.includes(enumValues, value); const enumValuesAsStrings = _.map(enumValues, enumValue => `'${enumValue}'`); const enumValuesAsString = enumValuesAsStrings.join(', '); assert.assert( -- cgit