From af441ff7d694d17256706991d911fa5961c378ef Mon Sep 17 00:00:00 2001 From: Matthew Holt Date: Sun, 8 Dec 2013 15:31:47 -0700 Subject: [PATCH] More tests --- tests.html | 5 +- tests.js | 144 +++++++++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 144 insertions(+), 5 deletions(-) diff --git a/tests.html b/tests.html index c571fd2..23df8eb 100644 --- a/tests.html +++ b/tests.html @@ -27,6 +27,10 @@ border-bottom: 10px solid white; } + #results td div { + overflow-x: scroll; + } + .count { background: #333; color: #DDD; @@ -57,7 +61,6 @@ font: 12px/1.5em 'Menlo', 'Monaco', 'Courier New', monospace; display: block; white-space: pre; - overflow-x: auto; } .clr-green, diff --git a/tests.js b/tests.js index 9d08e87..cb26482 100644 --- a/tests.js +++ b/tests.js @@ -237,8 +237,144 @@ var tests = [ } ] }, + { + input: "F1,F2,F3\n,2,V3,V4\nV5,V6,V7", + cases: [ + { + config: { delimiter: ",", header: true, dynamicTyping: true }, + expected: { + "results": { + "fields": [ + "F1", + "F2", + "F3" + ], + "rows": [ + { + "F1": "", + "F2": 2, + "F3": "V3", + "__parsed_extra": [ + "V4" + ] + }, + { + "F1": "V5", + "F2": "V6", + "F3": "V7" + } + ] + }, + "errors": [ + { + "type": "FieldMismatch", + "code": "TooManyFields", + "message": "Too many fields: expected 3 fields but parsed 4", + "line": 2, + "row": 0, + "index": 17 + } + ] + } + } + ] + }, + { + input: "F1,F2,F3\nV1,2.0,-3.01, V4\n\rV5,\"V\n6\",V7", + cases: [ + { + config: { delimiter: ",", header: true, dynamicTyping: true }, + expected: { + "results": { + "fields": [ + "F1", + "F2", + "F3" + ], + "rows": [ + { + "F1": "V1", + "F2": 2, + "F3": -3.01, + "__parsed_extra": [ + " V4" + ] + }, + { + "F1": "\rV5", + "F2": "V\n6", + "F3": "V7" + } + ] + }, + "errors": [ + { + "type": "FieldMismatch", + "code": "TooManyFields", + "message": "Too many fields: expected 3 fields but parsed 4", + "line": 2, + "row": 0, + "index": 25 + } + ] + } + } + ] + }, + { + input: "F1,F2,F3\nV1,V2,V3\nV5,\"V6,V7", + cases: [ + { + config: { delimiter: ",", header: true, dynamicTyping: true }, + expected: { + "results": { + "fields": [ + "F1", + "F2", + "F3" + ], + "rows": [ + { + "F1": "V1", + "F2": "V2", + "F3": "V3" + }, + { + "F1": "V5", + "F2": "V6,V7" + } + ] + }, + "errors": [ + { + "type": "FieldMismatch", + "code": "TooFewFields", + "message": "Too few fields: expected 3 fields but parsed 2", + "line": 3, + "row": 1, + "index": 27 + }, + { + "type": "Quotes", + "code": "MissingQuotes", + "message": "Unescaped or mismatched quotes", + "line": 3, + "row": 1, + "index": 27 + } + ] + } + } + ] + } ]; + + + + + + $(function() { var counter = 0; @@ -274,10 +410,10 @@ function render(input, expected, actual, config, count, status) var html = '' + ''+count+'' + - ''+string(input)+'' + - ''+string(config)+'' + - ''+string(expected)+'' + - ''+string(actual)+'' + + '
'+string(input)+'
' + + '
'+string(config)+'
' + + '
'+string(expected)+'
' + + '
'+string(actual)+'
' + ''; $('#results').append(html); }