@@ -369,6 +369,28 @@ describe('Tests for util functions', function () {
369369 var result = util . extendDeep ( { } , orig , { baz : undefined } ) ;
370370 assert . strictEqual ( Object . keys ( result ) . length , 3 ) ;
371371 } ) ;
372+
373+ describe ( 'arrays' , function ( ) {
374+ it ( 'An empty array replaced by a full array should be replaced' , function ( ) {
375+ var orig = { e1 : "val1" , e3 : [ ] } ;
376+ var extWith = { e2 : { elem1 : "val1" } , e3 : [ "val6" , "val7" ] } ;
377+ var shouldBe = { e1 : "val1" , e2 : { elem1 : "val1" } , e3 : [ "val6" , "val7" ] } ;
378+ var ext = util . extendDeep ( { } , orig , extWith ) ;
379+
380+ assert . deepEqual ( ext , shouldBe ) ;
381+ assert . deepEqual ( orig . e3 , [ ] ) ;
382+ } ) ;
383+
384+ it ( "An array replaced by an empty array should be replaced wholesale" , function ( ) {
385+ var orig = { e1 : "val1" , e3 : [ "val6" , "val7" ] } ;
386+ var extWith = { e2 : { elem1 : "val1" } , e3 : [ ] } ;
387+ var shouldBe = { e1 : "val1" , e2 : { elem1 : "val1" } , e3 : [ ] } ;
388+ var ext = util . extendDeep ( { } , orig , extWith ) ;
389+
390+ assert . deepEqual ( ext , shouldBe ) ;
391+ assert . deepEqual ( orig . e3 , [ "val6" , "val7" ] ) ;
392+ } ) ;
393+ } ) ;
372394 } ) ;
373395
374396 describe ( 'Util.toObject() tests' , function ( ) {
@@ -678,6 +700,12 @@ describe('Tests for util functions', function () {
678700 assert . deepEqual ( load . config . staticArray , [ 2 , 1 , 3 ] ) ;
679701 } ) ;
680702
703+ it ( 'can handle files with BOM Unicode characters' , function ( ) {
704+ assert . doesNotThrow ( function ( ) {
705+ load . loadFile ( Path . join ( __dirname , './7-config/defaultWithUnicodeBOM.json' ) ) ;
706+ } , 'config file with BOM has a parse error' ) ;
707+ } ) ;
708+
681709 it ( 'uses an optional transform on the data' , function ( ) {
682710 load . loadFile ( Path . join ( __dirname , './config/default-3.json' ) , ( ) => { return { foo : "bar" } } ) ;
683711
@@ -1311,6 +1339,14 @@ describe('Tests for util functions', function () {
13111339 assert . strictEqual ( config . AnotherModule . parm3 , 'value3' ) ;
13121340 } ) ;
13131341
1342+ it ( 'loading from transpiled ESM files is correct' , function ( ) {
1343+ let actual = util . loadFileConfigs ( {
1344+ configDir : Path . join ( __dirname , 'x-config-js-transpiled' )
1345+ } ) . config ;
1346+
1347+ assert . strictEqual ( actual . title , 'Hello config!' ) ;
1348+ } ) ;
1349+
13141350 it ( 'loading from a Hjson file is correct' , function ( ) {
13151351 assert . strictEqual ( config . AnotherModule . parm8 , 'value8' ) ;
13161352 } ) ;
@@ -1323,6 +1359,36 @@ describe('Tests for util functions', function () {
13231359 assert . strictEqual ( config . AnotherModule . parm10 , 'value10' ) ;
13241360 } ) ;
13251361
1362+ describe ( 'for .ts files' , function ( ) {
1363+ it ( 'loading from a TS file is correct' , function ( ) {
1364+ let actual = util . loadFileConfigs ( {
1365+ configDir : Path . join ( __dirname , 'x-config-ts' )
1366+ } ) . config ;
1367+
1368+ assert . strictEqual ( actual . siteTitle , 'New Instance!' ) ;
1369+ } ) ;
1370+
1371+ it ( 'reuses existing .ts file handler' , function ( ) {
1372+ let existingHandler = require . extensions [ '.ts' ] ;
1373+
1374+ assert . ok ( existingHandler , 'Existing handler is defined by the environment' ) ;
1375+
1376+ let actual = util . loadFileConfigs ( {
1377+ configDir : Path . join ( __dirname , 'x-config-ts' )
1378+ } ) . config ;
1379+
1380+ assert . strictEqual ( require . extensions [ '.ts' ] , existingHandler , 'Should not overwrite existing handler' ) ;
1381+ } ) ;
1382+
1383+ describe ( 'can process module exports' , function ( ) {
1384+ let actual = util . loadFileConfigs ( {
1385+ configDir : Path . join ( __dirname , 'x-config-ts-module-exports' )
1386+ } ) . config ;
1387+
1388+ assert . strictEqual ( actual . siteTitle , 'New Instance!' ) ;
1389+ } ) ;
1390+ } ) ;
1391+
13261392 describe ( 'for .toml files' , function ( ) {
13271393 it ( 'loading from a TOML file is correct' , function ( ) {
13281394 assert . strictEqual ( config . AnotherModule . parm7 , 'value7' ) ;
0 commit comments