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 v1.2.3 From 75babed69317ab1da02a10706871ab0bb2293883 Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Thu, 5 Jul 2018 12:07:17 +0200 Subject: Update assert changelog --- packages/assert/CHANGELOG.json | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'packages/assert') diff --git a/packages/assert/CHANGELOG.json b/packages/assert/CHANGELOG.json index 883d55f5b..26f3d0d66 100644 --- a/packages/assert/CHANGELOG.json +++ b/packages/assert/CHANGELOG.json @@ -1,4 +1,13 @@ [ + { + "version": "0.2.13", + "changes": [ + { + "note": "Fix bug in string enum assertion. We erroneously were checking against the enum keys, not values", + "pr": 821 + } + ] + }, { "timestamp": 1529397769, "version": "0.2.12", -- cgit v1.2.3 From a1fb438a8c8722d14c7a1e52e844898ff5451e66 Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Thu, 5 Jul 2018 13:03:33 +0200 Subject: Prettier fixes --- packages/assert/CHANGELOG.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'packages/assert') diff --git a/packages/assert/CHANGELOG.json b/packages/assert/CHANGELOG.json index 26f3d0d66..b44cac4a1 100644 --- a/packages/assert/CHANGELOG.json +++ b/packages/assert/CHANGELOG.json @@ -3,8 +3,9 @@ "version": "0.2.13", "changes": [ { - "note": "Fix bug in string enum assertion. We erroneously were checking against the enum keys, not values", - "pr": 821 + "note": + "Fix bug in string enum assertion. We erroneously were checking against the enum keys, not values", + "pr": 821 } ] }, -- cgit v1.2.3