Skip to content

Commit

Permalink
Add test for REG_EXPAND_SZ type
Browse files Browse the repository at this point in the history
  • Loading branch information
sergiou87 committed Mar 1, 2024
1 parent 3c576d7 commit c8ceab3
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion test/registry-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -130,6 +130,33 @@ if (process.platform === 'win32') {
expect(programFilesDir!.type).toBe('REG_SZ')
expect(programFilesDir!.data).toBe('Value 123 ! [email protected] (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 ! [email protected] (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 ! [email protected] (456);%NVM_HOME%;%NVM_SYMLINK%'
)
})
})

describe('createKey', () => {
Expand Down

0 comments on commit c8ceab3

Please sign in to comment.