From b6218fa8c4480510dec0edd1f80f5819c93031c8 Mon Sep 17 00:00:00 2001 From: quintezkiller Date: Thu, 9 Mar 2017 08:26:40 -0500 Subject: [PATCH] Fixing some tests --- test/coreSpec.js | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/test/coreSpec.js b/test/coreSpec.js index 264d490..89a9ec1 100644 --- a/test/coreSpec.js +++ b/test/coreSpec.js @@ -146,7 +146,7 @@ describe(`core::arrays2csv`, () => { it(`converts Array of arrays to string in CSV format`, () => { const actual = arrays2csv(fixtures); expect(actual).toBeA('string'); - expect(actual.split(`\n`).join(`|`)).toEqual(`a,b|c,d`); + expect(actual.split(`\n`).join(`|`)).toEqual(`"a","b"|"c","d"`); }); it(`renders CSV headers whenever it was given `, () => { @@ -173,7 +173,7 @@ describe(`core::jsons2csv`, () => { const actual = jsons2csv(fixtures); const expectedHeaders = ['X', 'Y']; - const expected = `${expectedHeaders.join(`,`)}|88,97|77,99`; + const expected = `"X","Y"|"88","97"|"77","99"`; expect(actual).toBeA('string'); expect(actual.split(`\n`).join(`|`)).toEqual(expected); }); @@ -199,14 +199,27 @@ describe(`core::string2csv`, () =>{ it(`prepends headers at the top of input`, () => { const headers =[`X`, `Y`]; - expect(string2csv(fixtures, headers)).toEqual(`${headers.join(`,`)}\n${fixtures}`); + expect(string2csv(fixtures, headers)).toEqual(`"X","Y"\n${fixtures}`); }); }); describe(`core::toCSV`, () =>{ let fixtures; beforeEach(() => { - fixtures = {string:'Xy', arrays:[[],[]],jsons:[{}, {}]}; + fixtures = {string:' + + + + + + + + + + + + + y', arrays:[[],[]],jsons:[{}, {}]}; }); it(`requires one argument at least`, () => { expect(() => toCSV()).toThrow();