import * as assert from 'assert' ; import { Settings } from '../src/settings' ; suite ( 'Settings' , ( ) => { setup ( ( ) => { } ) ; suite ( 'CheckSettings' , ( ) => { test ( 'CheckSettings - remoteType none' , ( ) => { const cfgEmpty = { } ; Settings . launch = Settings . Init ( cfgEmpty ) ; assert . throws ( ( ) => { Settings . CheckSettings ( ) ; } , "Should fail without remoteType." ) ; const cfg = { remoteType : 'something' } ; Settings . launch = Settings . Init ( cfg ) ; assert . throws ( ( ) => { Settings . CheckSettings ( ) ; } , "Should fail with wrong remoteType." ) ; } ) ; test ( 'CheckSettings - remoteType=zesarux' , ( ) => { const cfg = { remoteType : 'zrcp' , rootFolder : './tests/data' , } ; Settings . launch = Settings . Init ( cfg ) ; assert . doesNotThrow ( ( ) => { Settings . CheckSettings ( ) ; } , "Should not fail with remoteType=zesarux." ) ; } ) ; test ( 'CheckSettings - remoteType=zxnext' , ( ) => { const cfg = { remoteType : 'zxnext' , rootFolder : './tests/data' , } ; Settings . launch = Settings . Init ( cfg ) ; assert . doesNotThrow ( ( ) => { Settings . CheckSettings ( ) ; } , "Should not fail with remoteType=zxnext." ) ; } ) ; test ( 'CheckSettings - remoteType=zsim' , ( ) => { const cfg = { remoteType : 'zsim' , rootFolder : './tests/data' , } ; Settings . launch = Settings . Init ( cfg ) ; assert . doesNotThrow ( ( ) => { Settings . CheckSettings ( ) ; } , "Should not fail with remoteType=zsim." ) ; } ) ; test ( 'CheckSettings - Default' , ( ) => { const cfg = { remoteType : 'zrcp' , rootFolder : './tests/data' , } ; Settings . launch = Settings . Init ( cfg ) ; assert . doesNotThrow ( ( ) => { Settings . CheckSettings ( ) ; } , "Should not fail with default config." ) ; } ) ; test ( 'CheckSettings - No rootFolder' , ( ) => { const cfg = { remoteType : 'zrcp' , sjasmplus : [ { path : "./tests/data/settings/file.list" } ] } ; Settings . launch = Settings . Init ( cfg ) ; assert . throws ( ( ) => { Settings . CheckSettings ( ) ; } , "Exception expected (because no rootFolder given)." ) ; } ) ; test ( 'CheckSettings - listFiles 1' , ( ) => { const cfg = { remoteType : 'zrcp' , rootFolder : './tests/data' , sjasmplus : [ { path : "./settings/filenotexists.list" } ] } ; Settings . launch = Settings . Init ( cfg ) ; assert . throws ( ( ) => { Settings . CheckSettings ( ) ; } , "Check failed: file does not exist." ) ; } ) ; test ( 'CheckSettings - listFiles 2' , ( ) => { const cfg = { remoteType : 'zrcp' , rootFolder : './tests/data' , sjasmplus : [ { path : "./settings/file.list" } ] } ; Settings . launch = Settings . Init ( cfg ) ; assert . doesNotThrow ( ( ) => { Settings . CheckSettings ( ) ; } , "Check failed: file does exist." ) ; } ) ; test ( 'CheckSettings - load 1' , ( ) => { const cfg = { remoteType : 'zrcp' , rootFolder : './tests/data' , load : "./settings/filenotexists.sna" } ; Settings . launch = Settings . Init ( cfg ) ; assert . throws ( ( ) => { Settings . CheckSettings ( ) ; } , "Check failed: file does not exist." ) ; } ) ; test ( 'CheckSettings - load 2' , ( ) => { const cfg = { remoteType : 'zrcp' , rootFolder : './tests/data' , load : "./settings/file.sna" } ; Settings . launch = Settings . Init ( cfg ) ; assert . doesNotThrow ( ( ) => { Settings . CheckSettings ( ) ; } , "Check failed: file does exist." ) ; } ) ; test ( 'CheckSettings - load and execAddress' , ( ) => { const cfg = { remoteType : 'zrcp' , rootFolder : './tests/data' , load : "./settings/file.sna" , execAddress : "1234" } ; Settings . launch = Settings . Init ( cfg ) ; assert . throws ( ( ) => { Settings . CheckSettings ( ) ; } , "Check failed: There should be an exception if 'load' and 'execAddress' are used together." ) ; } ) ; test ( 'CheckSettings - loadObj 1' , ( ) => { const cfg = { remoteType : 'zrcp' , rootFolder : './tests/data' , loadObjs : [ { path : "./settings/file1.obj" , start : "1234" } , { path : "./settings/file2notexists.obj" , start : "1234" } ] } ; Settings . launch = Settings . Init ( cfg ) ; assert . throws ( ( ) => { Settings . CheckSettings ( ) ; } , "Check failed: file does not exist." ) ; } ) ; test ( 'CheckSettings - loadObj 2' , ( ) => { const cfg = { remoteType : 'zrcp' , rootFolder : './tests/data' , loadObjs : [ { path : "./settings/file1.obj" , start : "1234" } , { path : "./settings/file2.obj" , start : "1234" } ] } ; Settings . launch = Settings . Init ( cfg ) ; assert . doesNotThrow ( ( ) => { Settings . CheckSettings ( ) ; } , "Check failed: files do exist." ) ; } ) ; test ( 'CheckSettings - loadObj start' , ( ) => { const cfg = { remoteType : 'zrcp' , rootFolder : './tests/data' , loadObjs : [ { path : "./settings/file1.obj" , start : "1234" } , { path : "./settings/file2.obj" } ] } ; Settings . launch = Settings . Init ( cfg ) ; assert . throws ( ( ) => { Settings . CheckSettings ( ) ; } , "Check failed: 'start' should be defined." ) ; } ) ; } ) ; } ) ;