From 357edda229703b1f80dc5f7bc3d7154c48e87208 Mon Sep 17 00:00:00 2001 From: Manuel Alabor Date: Wed, 19 Apr 2017 00:33:18 +0200 Subject: [PATCH] fix(map): Allow null as value for Map entry The withMap parser failed when a map contained a key with value "null". This change fixes this an allows entries with null values. --- src/parsers/map.ts | 6 ++---- test/parsers/map.ts | 7 ++++++- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/parsers/map.ts b/src/parsers/map.ts index a4cb38b..446f950 100644 --- a/src/parsers/map.ts +++ b/src/parsers/map.ts @@ -10,11 +10,9 @@ export const fromMap = (map: ParserInput, key: string, valueParser: ParseFn { it('should throw a ParserError when given a string', () => { expect(() => fromMap('test', 'a', aBoolean)).to.throw(ParserError); }); + + it('should not throw ParserError when given key exists and has value "null"', () => { + const aNull: ParseFn = (): null => null; + expect(() => fromMap({ a: null }, 'a', aNull)).to.not.throw(); + }) }); });