Browse Source

Changed intendation to tabs

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

80
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 = [
@ -602,7 +604,6 @@ describe('Core Parser Tests', function() { @@ -602,7 +604,6 @@ describe('Core Parser Tests', function() {
});
// Tests for Papa.parse() function -- high-level wrapped parser (CSV to JSON)
var PARSE_TESTS = [
{
@ -815,7 +816,11 @@ var PARSE_TESTS = [ @@ -815,7 +816,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: []
@ -883,7 +888,11 @@ var PARSE_TESTS = [ @@ -883,7 +888,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: []
@ -892,7 +901,11 @@ var PARSE_TESTS = [ @@ -892,7 +901,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: []
@ -1388,7 +1401,6 @@ describe('Parse Tests', function() { @@ -1388,7 +1401,6 @@ describe('Parse Tests', function() {
});
// Tests for Papa.parse() that involve asynchronous operation
var PARSE_ASYNC_TESTS = [
{
@ -1431,8 +1443,7 @@ var PARSE_ASYNC_TESTS = [ @@ -1431,8 +1443,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: []
@ -1477,7 +1488,6 @@ describe('Parse Async Tests', function() { @@ -1477,7 +1488,6 @@ describe('Parse Async Tests', function() {
});
// Tests for Papa.unparse() function (JSON to CSV)
var UNPARSE_TESTS = [
{
@ -1642,44 +1652,11 @@ var UNPARSE_TESTS = [ @@ -1642,44 +1652,11 @@ 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'
},
{
description: "Returns empty rows when empty rows are passed and skipEmptyLines is false",
input: [[null, ' '], [], ['1', '2']],
config: {skipEmptyLines: false},
expected: '," "\r\n\r\n1,2'
},
{
description: "Returns without empty rows when skipEmptyLines is true",
input: [[null, ' '], [], ['1', '2']],
config: {skipEmptyLines: true},
expected: '," "\r\n1,2'
},
{
description: "Returns without rows with no content when skipEmptyLines is 'greedy'",
input: [[null, ' '], [], ['1', '2']],
config: {skipEmptyLines: 'greedy'},
expected: '1,2'
},
{
description: "Returns empty rows when empty rows are passed and skipEmptyLines is false with headers",
input: [{a: null, b: ' '}, {}, {a: '1', b: '2'}],
config: {skipEmptyLines: false, header: true},
expected: 'a,b\r\n," "\r\n\r\n1,2'
},
{
description: "Returns without empty rows when skipEmptyLines is true with headers",
input: [{a: null, b: ' '}, {}, {a: '1', b: '2'}],
config: {skipEmptyLines: true, header: true},
expected: 'a,b\r\n," "\r\n1,2'
},
{
description: "Returns without rows with no content when skipEmptyLines is 'greedy' with headers",
input: [{a: null, b: ' '}, {}, {a: '1', b: '2'}],
config: {skipEmptyLines: 'greedy', header: true},
expected: 'a,b\r\n1,2'
}
];
@ -1707,7 +1684,6 @@ describe('Unparse Tests', function() { @@ -1707,7 +1684,6 @@ describe('Unparse Tests', function() {
});
var CUSTOM_TESTS = [
{
description: "Complete is called with all results if neither step nor chunk is defined",
@ -2117,12 +2093,16 @@ var CUSTOM_TESTS = [ @@ -2117,12 +2093,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