diff --git a/tests/config.spec.ts b/tests/config.spec.ts index d51297b..bfb6f3a 100644 --- a/tests/config.spec.ts +++ b/tests/config.spec.ts @@ -1,4 +1,3 @@ -/// import { Interceptable, MockAgent, setGlobalDispatcher } from 'undici'; import { commonDbPartialV1, commonS3PartialV1 } from '@map-colonies/schemas'; import { StatusCodes } from 'http-status-codes'; @@ -304,7 +303,7 @@ describe('config', () => { await expect(promise).rejects.toThrow(); }); - it('should returned on getAll() a full frozen configuration object ', async () => { + it('should not allow to modify the root object', async () => { const configInstance = await config({ configName: 'name', version: 1, @@ -315,10 +314,13 @@ describe('config', () => { }); const conf = configInstance.getAll(); - expect(conf).toBeFrozen(); + const action = () => { + conf.host = 'dummmy.host.check'; + }; + expect(action).toThrow(/Cannot assign to read only property/); }); - it('should returned on get(`ssl`) a frozen sub configuration object ', async () => { + it('should not allow to modify the child object', async () => { const configInstance = await config({ configName: 'name', version: 1, @@ -329,7 +331,28 @@ describe('config', () => { }); const conf = configInstance.get('ssl'); - expect(conf).toBeFrozen(); + const action = () => { + conf.enabled = true; // try to change ssl configuration + }; + expect(action).toThrow(/Cannot assign to read only property/); + }); + + it('should not allow to modify the extracted child object from root', async () => { + const configInstance = await config({ + configName: 'name', + version: 1, + schema: commonDbPartialV1, + configServerUrl: URL, + localConfigPath: './tests/config', + offlineMode: true, + }); + + const conf = configInstance.getAll(); + const sslConf = conf.ssl; + const action = () => { + sslConf.enabled = true; + }; + expect(action).toThrow(/Cannot assign to read only property/); }); }); });