Browse Source

Test cases for fast mode; preview fix

pull/124/head
Matthew Holt 10 years ago
parent
commit
e31c231dd7
  1. 3
      papaparse.js
  2. 36
      tests/test-cases.js

3
papaparse.js

@ -1115,7 +1115,10 @@
else else
data.push(rows[i].split(delim)); data.push(rows[i].split(delim));
if (preview && i >= preview) if (preview && i >= preview)
{
data = data.slice(0, preview);
return returnable(true); return returnable(true);
}
} }
return returnable(); return returnable();
} }

36
tests/test-cases.js

@ -343,6 +343,42 @@ var CORE_PARSER_TESTS = [
data: [['a'], ['b'], [''], [''], ['c'], ['d'], ['e'], ['']], data: [['a'], ['b'], [''], [''], ['c'], ['d'], ['e'], ['']],
errors: [] errors: []
} }
},
{
description: "Fast mode, basic",
input: 'a,b,c\nd,e,f',
config: { fastMode: true },
expected: {
data: [['a', 'b', 'c'], ['d', 'e', 'f']],
errors: []
}
},
{
description: "Fast mode with comments",
input: '// Commented line\na,b,c',
config: { fastMode: true, comments: "//" },
expected: {
data: [['a', 'b', 'c']],
errors: []
}
},
{
description: "Fast mode with preview",
input: 'a,b,c\nd,e,f\nh,j,i\n',
config: { fastMode: true, preview: 2 },
expected: {
data: [['a', 'b', 'c'], ['d', 'e', 'f']],
errors: []
}
},
{
description: "Fast mode with blank line at end",
input: 'a,b,c\n',
config: { fastMode: true },
expected: {
data: [['a', 'b', 'c'], ['']],
errors: []
}
} }
]; ];

Loading…
Cancel
Save