|
|
@ -35,25 +35,25 @@ $(function() |
|
|
|
$('.expanded .rvl', $testGroup).click(); |
|
|
|
$('.expanded .rvl', $testGroup).click(); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function asyncDone() { |
|
|
|
// Next, run tests and render results!
|
|
|
|
|
|
|
|
runParseTests(); |
|
|
|
|
|
|
|
runUnparseTests(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Finally, show the overall status.
|
|
|
|
// Finally, show the overall status.
|
|
|
|
if (failCount == 0) |
|
|
|
if (failCount == 0) |
|
|
|
$('#status').addClass('status-pass').html("All <b>" + passCount + "</b> test" + (passCount == 1 ? "" : "s") + " passed"); |
|
|
|
$('#status').addClass('status-pass').html("All <b>" + passCount + "</b> test" + (passCount == 1 ? "" : "s") + " passed"); |
|
|
|
else |
|
|
|
else |
|
|
|
$('#status').addClass('status-fail').html("<b>" + failCount + "</b> test" + (failCount == 1 ? "" : "s") + " failed; <b>" + passCount + "</b> passed"); |
|
|
|
$('#status').addClass('status-fail').html("<b>" + failCount + "</b> test" + (failCount == 1 ? "" : "s") + " failed; <b>" + passCount + "</b> passed"); |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Next, run tests and render results!
|
|
|
|
|
|
|
|
runParseTests(asyncDone); |
|
|
|
|
|
|
|
runUnparseTests(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Executes all tests in PARSE_TESTS from test-cases.js
|
|
|
|
// Executes all tests in PARSE_TESTS from test-cases.js
|
|
|
|
// and renders results in the table.
|
|
|
|
// and renders results in the table.
|
|
|
|
function runParseTests() |
|
|
|
function runParseTests(asyncDone) |
|
|
|
{ |
|
|
|
{ |
|
|
|
for (var i = 0; i < PARSE_TESTS.length; i++) |
|
|
|
for (var i = 0; i < PARSE_TESTS.length; i++) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -65,24 +65,60 @@ function runParseTests() |
|
|
|
failCount++; |
|
|
|
failCount++; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var asyncRemaining = PARSE_ASYNC_TESTS.length; |
|
|
|
|
|
|
|
|
|
|
|
function runTest(test) |
|
|
|
PARSE_ASYNC_TESTS.forEach(function(test) { |
|
|
|
{ |
|
|
|
var config = test.config; |
|
|
|
|
|
|
|
config.complete = function(actual) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var results = compare(actual.data, actual.errors, test.expected); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
displayResults(test, actual, results); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (results.data.passed && results.errors.passed) { |
|
|
|
|
|
|
|
passCount++; |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
failCount++; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (--asyncRemaining === 0) { |
|
|
|
|
|
|
|
asyncDone(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
config.error = function(err) { |
|
|
|
|
|
|
|
failCount++; |
|
|
|
|
|
|
|
displayResults(test, {data:[],errors:err}, test.expected); |
|
|
|
|
|
|
|
if (--asyncRemaining === 0) { |
|
|
|
|
|
|
|
asyncDone(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Papa.parse(test.input, test.config); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function runTest(test) { |
|
|
|
var actual; |
|
|
|
var actual; |
|
|
|
|
|
|
|
|
|
|
|
try |
|
|
|
try { |
|
|
|
{ |
|
|
|
|
|
|
|
actual = Papa.parse(test.input, test.config); |
|
|
|
actual = Papa.parse(test.input, test.config); |
|
|
|
|
|
|
|
} catch (e) { |
|
|
|
|
|
|
|
if (e instanceof Error) { |
|
|
|
|
|
|
|
throw e; |
|
|
|
} |
|
|
|
} |
|
|
|
catch (e) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
actual.data = []; |
|
|
|
actual.data = []; |
|
|
|
actual.errors = [e]; |
|
|
|
actual.errors = [e]; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var testId = testCount++; |
|
|
|
|
|
|
|
var results = compare(actual.data, actual.errors, test.expected); |
|
|
|
var results = compare(actual.data, actual.errors, test.expected); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
displayResults(test, actual, results); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return results.data.passed && results.errors.passed |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function displayResults(test, actual, results) { |
|
|
|
|
|
|
|
var testId = testCount++; |
|
|
|
|
|
|
|
|
|
|
|
var testDescription = (test.description || ""); |
|
|
|
var testDescription = (test.description || ""); |
|
|
|
if (testDescription.length > 0) |
|
|
|
if (testDescription.length > 0) |
|
|
|
testDescription += '<br>'; |
|
|
|
testDescription += '<br>'; |
|
|
@ -105,7 +141,6 @@ function runParseTests() |
|
|
|
if (!results.data.passed || !results.errors.passed) |
|
|
|
if (!results.data.passed || !results.errors.passed) |
|
|
|
$('#test-' + testId + ' td.rvl').click(); |
|
|
|
$('#test-' + testId + ' td.rvl').click(); |
|
|
|
|
|
|
|
|
|
|
|
return results.data.passed && results.errors.passed |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -124,13 +159,11 @@ function runParseTests() |
|
|
|
{ |
|
|
|
{ |
|
|
|
var passed = true; |
|
|
|
var passed = true; |
|
|
|
|
|
|
|
|
|
|
|
if (actual.length != expected.length) |
|
|
|
if (actual.length != expected.length) { |
|
|
|
passed = false; |
|
|
|
passed = false; |
|
|
|
|
|
|
|
} else { |
|
|
|
for (var row = 0; row < expected.length; row++) |
|
|
|
for (var row = 0; row < expected.length; row++) { |
|
|
|
{ |
|
|
|
if (actual[row].length != expected[row].length) { |
|
|
|
if (actual[row].length != expected[row].length) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
passed = false; |
|
|
|
passed = false; |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
@ -147,6 +180,7 @@ function runParseTests() |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// We pass back an object right now, even though it only contains
|
|
|
|
// We pass back an object right now, even though it only contains
|
|
|
|
// one value, because we might add details to the test results later
|
|
|
|
// one value, because we might add details to the test results later
|
|
|
@ -197,6 +231,9 @@ function runUnparseTests() |
|
|
|
} |
|
|
|
} |
|
|
|
catch (e) |
|
|
|
catch (e) |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
if (e instanceof Error) { |
|
|
|
|
|
|
|
throw e; |
|
|
|
|
|
|
|
} |
|
|
|
actual = e; |
|
|
|
actual = e; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|