@@ -8,6 +8,11 @@ describe('FieldStringifier', () => {
88 expect ( stringifier . stringify ( 'VALUE' ) ) . to . eql ( 'VALUE' ) ;
99 } ) ;
1010
11+ it ( 'preserves the whitespace characters' , ( ) => {
12+ const stringifier = new FieldStringifier ( ) ;
13+ expect ( stringifier . stringify ( ' VALUE\tA ' ) ) . to . eql ( ' VALUE\tA ' ) ;
14+ } ) ;
15+
1116 it ( 'wraps a field value with double quotes if the field contains comma' , ( ) => {
1217 const stringifier = new FieldStringifier ( ) ;
1318 expect ( stringifier . stringify ( 'VALUE,A' ) ) . to . eql ( '"VALUE,A"' ) ;
@@ -18,14 +23,14 @@ describe('FieldStringifier', () => {
1823 expect ( stringifier . stringify ( 'VALUE\nA' ) ) . to . eql ( '"VALUE\nA"' ) ;
1924 } ) ;
2025
21- it ( 'escapes double quotes if it is used on the edge of the field value ' , ( ) => {
26+ it ( 'wraps a field value with double quotes and escape the double quotes if they are used in the field' , ( ) => {
2227 const stringifier = new FieldStringifier ( ) ;
23- expect ( stringifier . stringify ( '" VALUE' ) ) . to . eql ( '"""VALUE "' ) ;
28+ expect ( stringifier . stringify ( 'VALUE"A ' ) ) . to . eql ( '"VALUE""A "' ) ;
2429 } ) ;
2530
26- it ( 'does not double quote or escape double quotes if it is used not on the edge of the field value ' , ( ) => {
31+ it ( 'escapes double quotes even if double quotes are only on the both edges of the field' , ( ) => {
2732 const stringifier = new FieldStringifier ( ) ;
28- expect ( stringifier . stringify ( 'VALUE"A ' ) ) . to . eql ( 'VALUE"A ' ) ;
33+ expect ( stringifier . stringify ( '" VALUE"' ) ) . to . eql ( '""" VALUE""" ' ) ;
2934 } ) ;
3035
3136 it ( 'converts a number into a string' , ( ) => {
@@ -61,7 +66,7 @@ describe('FieldStringifier', () => {
6166 expect ( stringifier . stringify ( obj ) ) . to . eql ( '"Name: OBJECT,NAME"' ) ;
6267 } ) ;
6368
64- it ( 'escapes double quotes in a toString-ed field value if the value has double quotes on the edge ' , ( ) => {
69+ it ( 'escapes double quotes in a toString-ed field value if the value has double quotes' , ( ) => {
6570 const stringifier = new FieldStringifier ( ) ;
6671 const obj = {
6772 name : 'OBJECT_NAME"' ,
0 commit comments