8 lines
2.8 KiB
JavaScript
8 lines
2.8 KiB
JavaScript
//>>built
|
|
define("dstore/tests/Csv","intern!object intern/chai!assert dojo/_base/declare dstore/Csv dstore/Memory dojo/text!./data/noquote.csv dojo/text!./data/quote.csv dojo/text!./data/contributors.csv".split(" "),function(n,a,b,p,q,g,h,k){b=b([q,p]);require.toUrl("dstore/tests/data");var e,d,l,f,c,m;e=new b({data:g,newline:"\n",fieldNames:["id","last","first","born","died"]});d=new b({data:g,newline:"\n"});l=new b({data:g,newline:"\n",trim:!0});f=new b({data:h,newline:"\n",fieldNames:["id","name","quote"]});
|
|
c=new b({data:h,newline:"\n"});m=new b({data:k,newline:"\n"});n({name:"dstore CSV","no quote":function(){var b,c;a.strictEqual(4,e.data.length,"Store with fieldNames should have 4 items.");a.strictEqual(3,d.data.length,"Store using header row should have 3 items.");a.strictEqual(5,e.fieldNames.length,"Store with fieldNames should have 5 fields.");a.strictEqual(6,d.fieldNames.length,"Store using header row should have 6 fields.");a.strictEqual("id",e.getSync("id").id,"First line should be considered an item when fieldNames are set");
|
|
a.strictEqual("Albert",d.getSync("1").first,"Field names picked up from header row should be trimmed.");a.strictEqual(e.getSync("1").last,d.getSync("1").last,"Item with id of 1 should have the same data in both stores.");b=d.getSync("2");c=l.getSync("2");a.strictEqual(" Nikola ",b.first,"Leading/trailing spaces should be preserved if trim is false.");a.strictEqual("Nikola",c.first,"Leading/trailing spaces should be trimmed if trim is true.");a.strictEqual(" ",b.middle,"Strings containing only whitespace should remain intact if trim is false.");
|
|
a.strictEqual("",c.middle,"Strings containing only whitespace should be empty if trim is true.");b=d.getSync("1");a.isTrue(""===b.middle,"Test blank value.");a.strictEqual("1879-03-14",b.born,"Test value after blank value.");a.isTrue(""===d.getSync("3").died,"Test blank value at end of line.")},quote:function(){a.strictEqual(5,f.data.length,"Store with fieldNames should have 5 items.");a.strictEqual(4,c.data.length,"Store using header row should have 4 items.");a.strictEqual("id",f.getSync("id").id,
|
|
"First line should be considered an item when fieldNames are set");a.strictEqual(f.getSync("1").name,c.getSync("1").name,"Item with id of 1 should have the same data in both stores.");a.strictEqual('""',c.getSync("3").quote,"Value consisting of two double-quotes should pick up properly.");a.strictEqual(" S, P, ...ace! ",c.getSync("4").quote,"Leading/trailing spaces within quotes should be preserved.");a.isTrue(/^Then[\s\S]*"Nevermore\."$/.test(c.getSync("2").quote),"Multiline value should remain intact.");
|
|
a.isTrue(/smiling,\n/.test(c.getSync("2").quote),"Multiline value should use same newline format as input.")},"import export":function(){a.strictEqual(k,m.toCsv(),"toCsv() should generate data matching original if it is well-formed")}})});
|
|
//# sourceMappingURL=Csv.js.map
|