diff options
author | Fabio Berger <me@fabioberger.com> | 2018-07-04 14:55:16 +0800 |
---|---|---|
committer | Fabio Berger <me@fabioberger.com> | 2018-07-04 14:55:16 +0800 |
commit | 2bec5cb7fd2383a415c04ed67e9cf4cd2ce1d87e (patch) | |
tree | 67c2811cc35fb446bbad6b6e964dc596c901be2a /packages/assert/src/index.ts | |
parent | cd766ea2a1fb56282fc45a1a19d991bbcae8db99 (diff) | |
download | dexon-sol-tools-2bec5cb7fd2383a415c04ed67e9cf4cd2ce1d87e.tar dexon-sol-tools-2bec5cb7fd2383a415c04ed67e9cf4cd2ce1d87e.tar.gz dexon-sol-tools-2bec5cb7fd2383a415c04ed67e9cf4cd2ce1d87e.tar.bz2 dexon-sol-tools-2bec5cb7fd2383a415c04ed67e9cf4cd2ce1d87e.tar.lz dexon-sol-tools-2bec5cb7fd2383a415c04ed67e9cf4cd2ce1d87e.tar.xz dexon-sol-tools-2bec5cb7fd2383a415c04ed67e9cf4cd2ce1d87e.tar.zst dexon-sol-tools-2bec5cb7fd2383a415c04ed67e9cf4cd2ce1d87e.zip |
Fix bug in string enum assertion so that we check enum values not keys
Diffstat (limited to 'packages/assert/src/index.ts')
-rw-r--r-- | packages/assert/src/index.ts | 4 |
1 files changed, 2 insertions, 2 deletions
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( |