From fb1b21cb4fceded79e6e909a5972965014b86ce2 Mon Sep 17 00:00:00 2001 From: David Worms Date: Tue, 7 Jun 2022 22:11:28 +0200 Subject: [PATCH] test(csv-parse): check cast_date with string ending with space and number --- packages/csv-parse/test/option.cast_date.coffee | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/packages/csv-parse/test/option.cast_date.coffee b/packages/csv-parse/test/option.cast_date.coffee index 03e872f4a..c57a97c39 100644 --- a/packages/csv-parse/test/option.cast_date.coffee +++ b/packages/csv-parse/test/option.cast_date.coffee @@ -24,3 +24,16 @@ describe 'Option `cast_date`', -> [ new Date('2050-11-27T00:00:00.000Z'), 'date2' ] ] next err + + it 'value end with space and number (issue #342)', (next) -> + # Current implementation rely on `isNaN(Date.parse(value))` + # While it return `NaN` in Firefox, Node.js return a timestamp for + # `node -e 'console.info(Date.parse("Test 1"))'` + parser = parse """ + Test 1 + """, + cast: true + cast_date: true + , (err, [[record]]) -> + record.toISOString().should.match /^\d{4}-\d{2}-\d{2}/ + next err