From c8ceab3bba575eb3668d103a7d7fdeabf88c7982 Mon Sep 17 00:00:00 2001 From: Sergio Padrino Date: Fri, 1 Mar 2024 17:30:00 +0100 Subject: [PATCH] Add test for REG_EXPAND_SZ type --- test/registry-test.ts | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/test/registry-test.ts b/test/registry-test.ts index 2f2c614..3fef7e4 100644 --- a/test/registry-test.ts +++ b/test/registry-test.ts @@ -75,7 +75,7 @@ if (process.platform === 'win32') { HKEY.HKEY_CURRENT_USER, 'SOFTWARE\\Microsoft\\Windows\\CurrentVersion', 'ValueTest', - RegistryValueType.REG_EXPAND_SZ, + RegistryValueType.REG_MULTI_SZ, 'Value' ) expect(result).toBeFalsy() @@ -130,6 +130,33 @@ if (process.platform === 'win32') { expect(programFilesDir!.type).toBe('REG_SZ') expect(programFilesDir!.data).toBe('Value 123 ! test@test.com (456)') }) + + it('can set REG_EXPAND_SZ value for a registry key', () => { + let result = false + try { + result = setValue( + HKEY.HKEY_CURRENT_USER, + 'SOFTWARE\\Microsoft\\Windows\\CurrentVersion', + 'ValueTestExpandSz', + RegistryValueType.REG_EXPAND_SZ, + 'Value 123 ! test@test.com (456);%NVM_HOME%;%NVM_SYMLINK%' + ) + } catch (e) { + console.log(e) + } + expect(result).toBeTruthy() + + const values = enumerateValues( + HKEY.HKEY_CURRENT_USER, + 'SOFTWARE\\Microsoft\\Windows\\CurrentVersion' + ) + + const value = values.find(v => v.name == 'ValueTestExpandSz') + expect(value!.type).toBe('REG_EXPAND_SZ') + expect(value!.data).toBe( + 'Value 123 ! test@test.com (456);%NVM_HOME%;%NVM_SYMLINK%' + ) + }) }) describe('createKey', () => {