source: Dev/trunk/src/node_modules/ya-csv/test/empty-quote.js @ 489

Last change on this file since 489 was 489, checked in by hendrikvanantwerpen, 11 years ago

Update node modules

File size: 929 bytes
Line 
1var csv = require('../lib/ya-csv'),
2    stream = require('stream'),
3    assert = require('assert');
4   
5// create a really simple writable stream
6var writeStream = new stream.Stream();
7writeStream.writable = true;
8writeStream.data = '';
9writeStream.write = function(data) {
10  // this csv writer doesn't allow commas since there is no
11  // quote or escape character. We're writing this for a really
12  // piss-poor csv implementation.
13  this.data += data.replace(/,/g, '');
14};
15writeStream.end = function() {
16  // nothing to do
17};
18
19// create csv writer with empty string options
20var csvWriter = csv.createCsvStreamWriter(writeStream, {
21  separator: ',', // must remove in writeStream.write()
22  quote: '',
23  escape: ''
24});
25
26var csvRecord = ['John Smith', 'Customer 999', 'United States'];
27csvWriter.writeRecord(csvRecord);
28
29var expected = "John Smith,Customer 999,United States\r\n";
30assert.strictEqual(writeStream.data, expected);
Note: See TracBrowser for help on using the repository browser.