@@ -14,6 +14,18 @@ const mockedKVs = [{
1414} , {
1515 key : "app.settings.fontSize" ,
1616 value : "40" ,
17+ } , {
18+ key : "app/settings/fontColor" ,
19+ value : "red" ,
20+ } , {
21+ key : "app/settings/fontSize" ,
22+ value : "40" ,
23+ } , {
24+ key : "app%settings%fontColor" ,
25+ value : "red" ,
26+ } , {
27+ key : "app%settings%fontSize" ,
28+ value : "40" ,
1729} , {
1830 key : "TestKey" ,
1931 label : "Test" ,
@@ -50,7 +62,7 @@ const mockedKVs = [{
5062} , {
5163 key : "app5.settings" ,
5264 value : "placeholder"
53- } ,
65+ }
5466] . map ( createMockedKeyValue ) ;
5567
5668describe ( "load" , function ( ) {
@@ -287,4 +299,36 @@ describe("load", function () {
287299 expect ( data . app4 . excludedFolders [ 0 ] ) . eq ( "node_modules" ) ;
288300 expect ( data . app4 . excludedFolders [ 1 ] ) . eq ( "dist" ) ;
289301 } ) ;
302+
303+ it ( "should construct configuration object with customized separator" , async ( ) => {
304+ const connectionString = createMockedConnectionString ( ) ;
305+ const settings = await load ( connectionString , {
306+ selectors : [ {
307+ keyFilter : "app/settings/*"
308+ } ]
309+ } ) ;
310+ expect ( settings ) . not . undefined ;
311+ const data = settings . constructConfigurationObject ( { separator : "/" } ) ;
312+ expect ( data ) . not . undefined ;
313+ expect ( data . app . settings . fontColor ) . eq ( "red" ) ;
314+ expect ( data . app . settings . fontSize ) . eq ( "40" ) ;
315+ } ) ;
316+
317+ it ( "should construct configuration object with customized separator" , async ( ) => {
318+ const connectionString = createMockedConnectionString ( ) ;
319+ const settings = await load ( connectionString , {
320+ selectors : [ {
321+ keyFilter : "app%settings%*"
322+ } ]
323+ } ) ;
324+ expect ( settings ) . not . undefined ;
325+
326+ expect ( ( ) => {
327+ // Below line will throw error because of type checking, i.e. Type '"%"' is not assignable to type '"/" | "." | "," | ";" | "-" | "_" | "__" | ":" | undefined'.ts(2322)
328+ // Here force to turn if off for testing purpose, as JavaScript does not have type checking.
329+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
330+ // @ts -ignore
331+ settings . constructConfigurationObject ( { separator : "%" } ) ;
332+ } ) . to . throw ( "Invalid separator '%'. Supported values: '.', ',', ';', '-', '_', '__', '/', ':'." ) ;
333+ } ) ;
290334} ) ;
0 commit comments