@@ -227,29 +227,53 @@ describe('data access', () => {
227
227
expect ( config . lines ) . toEqual ( [ ] )
228
228
} )
229
229
230
- it ( 'should list all key-value pairs' , ( ) => {
231
- const result = [ ...properties . list ( sample ) ]
232
- const resultAsArrays = result . map ( ( { key, value} ) => [ key , value ] )
230
+ describe ( 'list' , ( ) => {
231
+ it ( 'should list all key-value pairs' , ( ) => {
232
+ const result = [ ...properties . list ( sample ) ]
233
+ const resultAsArrays = result . map ( ( { key, value} ) => [ key , value ] )
233
234
234
- expect ( resultAsArrays ) . toEqual ( samplePairs )
235
+ expect ( resultAsArrays ) . toEqual ( samplePairs )
236
+ } )
235
237
} )
236
238
237
- it ( 'should return all keys toMap' , ( ) => {
238
- const result = properties . toMap ( sample )
239
- expect ( [ ...result . entries ( ) ] ) . toEqual ( samplePairs )
239
+ describe ( 'toObject' , ( ) => {
240
+ it ( 'should return all pairs' , ( ) => {
241
+ const result = properties . toObject ( sample )
242
+ expect ( Object . entries ( result ) ) . toEqual ( samplePairs )
243
+ } )
244
+
245
+ it ( 'should return last value of duplicate key' , ( ) => {
246
+ const config : properties . Properties = {
247
+ lines : [ 'foo=bar1' , 'a=b' , 'foo=bar2' , 'foo=bar3' , 'c=d' ]
248
+ }
249
+
250
+ const result = properties . toObject ( config )
251
+ expect ( Object . entries ( result ) ) . toEqual ( [
252
+ [ 'foo' , 'bar3' ] ,
253
+ [ 'a' , 'b' ] ,
254
+ [ 'c' , 'd' ]
255
+ ] )
256
+ } )
240
257
} )
241
258
242
- it ( 'should return last value of duplicate key' , ( ) => {
243
- const config : properties . Properties = {
244
- lines : [ 'foo=bar1' , 'a=b' , 'foo=bar2' , 'foo=bar3' , 'c=d' ]
245
- }
259
+ describe ( 'toMap' , ( ) => {
260
+ it ( 'should return all pairs' , ( ) => {
261
+ const result = properties . toMap ( sample )
262
+ expect ( [ ...result . entries ( ) ] ) . toEqual ( samplePairs )
263
+ } )
246
264
247
- const result = properties . toMap ( config )
248
- expect ( [ ...result . entries ( ) ] ) . toEqual ( [
249
- [ 'foo' , 'bar3' ] ,
250
- [ 'a' , 'b' ] ,
251
- [ 'c' , 'd' ]
252
- ] )
265
+ it ( 'should return last value of duplicate key' , ( ) => {
266
+ const config : properties . Properties = {
267
+ lines : [ 'foo=bar1' , 'a=b' , 'foo=bar2' , 'foo=bar3' , 'c=d' ]
268
+ }
269
+
270
+ const result = properties . toMap ( config )
271
+ expect ( [ ...result . entries ( ) ] ) . toEqual ( [
272
+ [ 'foo' , 'bar3' ] ,
273
+ [ 'a' , 'b' ] ,
274
+ [ 'c' , 'd' ]
275
+ ] )
276
+ } )
253
277
} )
254
278
} )
255
279
@@ -270,7 +294,7 @@ describe('The property key escaping', () => {
270
294
[ '\\foo12\\' , '\\\\foo12\\\\' ] ,
271
295
[ '\0\u0001' , '\\u0000\\u0001' ] ,
272
296
[ '\u3053\u3093\u306B\u3061\u306F' , '\\u3053\\u3093\\u306b\\u3061\\u306f' ] ,
273
- [ 'こんにちは' , '\\u3053\\u3093\\u306b\\u3061\\u306f' ] ,
297
+ [ 'こんにちは' , '\\u3053\\u3093\\u306b\\u3061\\u306f' ]
274
298
] ) ( 'should escape key "%s" as "%s"' , ( key : string , expected : string ) => {
275
299
const result = properties . escapeKey ( key )
276
300
expect ( result ) . toEqual ( expected )
@@ -293,7 +317,7 @@ describe('The property value escaping', () => {
293
317
[ '\\foo12\\' , '\\\\foo12\\\\' ] ,
294
318
[ '\0\u0001' , '\\u0000\\u0001' ] ,
295
319
[ '\u3053\u3093\u306B\u3061\u306F' , '\\u3053\\u3093\\u306b\\u3061\\u306f' ] ,
296
- [ 'こんにちは' , '\\u3053\\u3093\\u306b\\u3061\\u306f' ] ,
320
+ [ 'こんにちは' , '\\u3053\\u3093\\u306b\\u3061\\u306f' ]
297
321
] ) ( 'should escape value "%s" as "%s"' , ( key : string , expected : string ) => {
298
322
const result = properties . escapeValue ( key )
299
323
expect ( result ) . toEqual ( expected )
0 commit comments