@@ -44,6 +44,32 @@ describe('Ini', function() {
4444 expect ( foo . stringify ( ) ) . toBe ( text ) ;
4545 } ) ;
4646 } ) ;
47+
48+ describe ( 'line break parameter' , function ( ) {
49+ it ( 'should use parameter if passed' , ( ) => {
50+ let newIni = new Ini ( '[x]\r\nb=3' , '\r\n' ) ;
51+ expect ( newIni . sections [ 0 ] . lines . length ) . toBe ( 2 ) ;
52+
53+ let newIni2 = new Ini ( '[x]\nb=3' , '\r\n' ) ;
54+ expect ( newIni2 . sections [ 0 ] . lines . length ) . toBe ( 1 ) ;
55+ } ) ;
56+
57+ describe ( 'not passed' , ( ) => {
58+ it ( 'should determine from text' , ( ) => {
59+ let newIni = new Ini ( '[x]\r\nb=3' ) ;
60+ expect ( newIni . sections [ 0 ] . lines . length ) . toBe ( 2 ) ;
61+
62+ let newIni2 = new Ini ( '[x]\nb=3' ) ;
63+ expect ( newIni2 . sections [ 0 ] . lines . length ) . toBe ( 2 ) ;
64+ } ) ;
65+
66+ it ( 'should determine by system if cannot determine by text' , ( ) => {
67+ let newIni = new Ini ( '[x]=3' ) ;
68+ let linebreak = process . platform === 'win32' ? '\r\n' : '\n' ;
69+ expect ( newIni . lineBreak ) . toBe ( linebreak ) ;
70+ } ) ;
71+ } ) ;
72+ } ) ;
4773 } ) ;
4874
4975 describe ( 'addSection' , function ( ) {
@@ -173,28 +199,4 @@ describe('Ini', function() {
173199 } ) ;
174200 } ) ;
175201 } ) ;
176-
177- describe ( 'linebreak' , function ( ) {
178- it ( 'should accept linebreak' , ( ) => {
179- const newIni = new Ini ( '[x]\r\nb=3' , '\r\n' )
180- expect ( newIni . sections [ 0 ] . lines . length ) . toBe ( 2 )
181-
182- const newIni2 = new Ini ( '[x]\nb=3' , '\r\n' )
183- expect ( newIni2 . sections [ 0 ] . lines . length ) . toBe ( 1 )
184- } )
185-
186- it ( 'should determind linebreak by text' , ( ) => {
187- const newIni = new Ini ( '[x]\r\nb=3' )
188- expect ( newIni . sections [ 0 ] . lines . length ) . toBe ( 2 )
189-
190- const newIni2 = new Ini ( '[x]\nb=3' )
191- expect ( newIni2 . sections [ 0 ] . lines . length ) . toBe ( 2 )
192- } )
193-
194- it ( 'should determind linebreak by system when by text fail' , ( ) => {
195- const newIni = new Ini ( '[x]=3' )
196- const linebreak = process . platform === 'win32' ? '\r\n' : '\n'
197- expect ( newIni . lineBreak ) . toBe ( linebreak )
198- } )
199- } )
200- } ) ;
202+ } ) ;
0 commit comments