From 23b709cee28a5926f1608e70e30703ba52011005 Mon Sep 17 00:00:00 2001 From: Nerivec <62446222+Nerivec@users.noreply.github.com> Date: Thu, 9 Jan 2025 20:37:01 +0100 Subject: [PATCH] fix(ignore): Ensure config example is never out of sync with settings (#25707) --- test/settings.test.ts | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/test/settings.test.ts b/test/settings.test.ts index 05ae80fc1c..8b159de1f1 100644 --- a/test/settings.test.ts +++ b/test/settings.test.ts @@ -52,6 +52,37 @@ describe('Settings', () => { clearEnvironmentVariables(); }); + it('Ensures configuration.example.yaml is never out of sync with settings', () => { + let path = './data/configuration.example.yaml'; + + // allow running in single-test mode + if (!fs.existsSync('./data')) { + path = '../data/configuration.example.yaml'; + } + + const exampleYaml = read(path) as Record; + + // force keeping an eye on example yaml whenever CURRENT_VERSION changes + expect(exampleYaml).toStrictEqual({ + version: settings.CURRENT_VERSION, + homeassistant: { + enabled: false, + }, + frontend: { + enabled: true, + }, + mqtt: { + base_topic: 'zigbee2mqtt', + server: 'mqtt://localhost', + }, + advanced: { + network_key: 'GENERATE', + pan_id: 'GENERATE', + ext_pan_id: 'GENERATE', + }, + }); + }); + it('Should return default settings', () => { write(configurationFile, {}); const s = settings.get();