Browse Source

Add files via upload

pull/593/head
Erik-HH 6 years ago committed by GitHub
parent
commit
8e00d8691a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 44
      tests/test-cases.js

44
tests/test-cases.js

@ -13,13 +13,15 @@ var FILES_ENABLED = false; @@ -13,13 +13,15 @@ var FILES_ENABLED = false;
try {
new File([""], ""); // eslint-disable-line no-new
FILES_ENABLED = true;
} catch (e) {} // safari, ie
} catch (e) {
} // safari, ie
var XHR_ENABLED = false;
try {
new XMLHttpRequest(); // eslint-disable-line no-new
XHR_ENABLED = true;
} catch (e) {} // safari, ie
} catch (e) {
} // safari, ie
// Tests for the core parser using new Papa.Parser().parse() (CSV to JSON)
var CORE_PARSER_TESTS = [
@ -594,7 +596,6 @@ describe('Core Parser Tests', function() { @@ -594,7 +596,6 @@ describe('Core Parser Tests', function() {
});
// Tests for Papa.parse() function -- high-level wrapped parser (CSV to JSON)
var PARSE_TESTS = [
{
@ -807,7 +808,11 @@ var PARSE_TESTS = [ @@ -807,7 +808,11 @@ var PARSE_TESTS = [
{
description: "Callback delimiter",
input: 'a$ b$ c',
config: { delimiter: function(input) { return input[1] + ' '; } },
config: {
delimiter: function (input) {
return input[1] + ' ';
}
},
expected: {
data: [['a', 'b', 'c']],
errors: []
@ -875,7 +880,11 @@ var PARSE_TESTS = [ @@ -875,7 +880,11 @@ var PARSE_TESTS = [
{
description: "Dynamic typing by indices can be determined by function",
input: '001,002,003',
config: { dynamicTyping: function(field) { return (field % 2) === 0; } },
config: {
dynamicTyping: function (field) {
return (field % 2) === 0;
}
},
expected: {
data: [[1, "002", 3]],
errors: []
@ -884,7 +893,11 @@ var PARSE_TESTS = [ @@ -884,7 +893,11 @@ var PARSE_TESTS = [
{
description: "Dynamic typing by headers can be determined by function",
input: 'A_as_int,B,C_as_int\r\n001,002,003',
config: { header: true, dynamicTyping: function(field) { return /_as_int$/.test(field); } },
config: {
header: true, dynamicTyping: function (field) {
return /_as_int$/.test(field);
}
},
expected: {
data: [{"A_as_int": 1, "B": "002", "C_as_int": 3}],
errors: []
@ -1380,7 +1393,6 @@ describe('Parse Tests', function() { @@ -1380,7 +1393,6 @@ describe('Parse Tests', function() {
});
// Tests for Papa.parse() that involve asynchronous operation
var PARSE_ASYNC_TESTS = [
{
@ -1423,8 +1435,7 @@ var PARSE_ASYNC_TESTS = [ @@ -1423,8 +1435,7 @@ var PARSE_ASYNC_TESTS = [
description: "Simple file",
disabled: !FILES_ENABLED,
input: FILES_ENABLED ? new File(["A,B,C\nX,Y,Z"], "sample.csv") : false,
config: {
},
config: {},
expected: {
data: [['A', 'B', 'C'], ['X', 'Y', 'Z']],
errors: []
@ -1469,7 +1480,6 @@ describe('Parse Async Tests', function() { @@ -1469,7 +1480,6 @@ describe('Parse Async Tests', function() {
});
// Tests for Papa.unparse() function (JSON to CSV)
var UNPARSE_TESTS = [
{
@ -1642,7 +1652,10 @@ var UNPARSE_TESTS = [ @@ -1642,7 +1652,10 @@ var UNPARSE_TESTS = [
},
{
description: "Date objects are exported in its ISO representation",
input: [{date: new Date("2018-05-04T21:08:03.269Z"), "not a date": 16}, {date: new Date("Tue May 08 2018 08:20:22 GMT-0700 (PDT)"), "not a date": 32}],
input: [{
date: new Date("2018-05-04T21:08:03.269Z"),
"not a date": 16
}, {date: new Date("Tue May 08 2018 08:20:22 GMT-0700 (PDT)"), "not a date": 32}],
expected: 'date,not a date\r\n2018-05-04T21:08:03.269Z,16\r\n2018-05-08T15:20:22.000Z,32'
},
{
@ -1707,7 +1720,6 @@ describe('Unparse Tests', function() { @@ -1707,7 +1720,6 @@ describe('Unparse Tests', function() {
});
var CUSTOM_TESTS = [
{
description: "Complete is called with all results if neither step nor chunk is defined",
@ -2117,12 +2129,16 @@ var CUSTOM_TESTS = [ @@ -2117,12 +2129,16 @@ var CUSTOM_TESTS = [
'?x=1&papaworker&y=1',
'?x=1&papaworker=1'
];
var results = searchStrings.map(function() { return false; });
var results = searchStrings.map(function () {
return false;
});
var workers = [];
// Give it .5s to do something
setTimeout(function () {
workers.forEach(function(w) { w.terminate(); });
workers.forEach(function (w) {
w.terminate();
});
callback(results);
}, 500);

Loading…
Cancel
Save