-
Notifications
You must be signed in to change notification settings - Fork 4
/
test.js
48 lines (40 loc) · 1.57 KB
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
var assert = require('assert');
var mod = require('.');
describe('#windows-native-registry()', () => {
const K = "Software\\xx-test";
beforeEach(() => {
mod.deleteRegistryKey(mod.HK.CU, K);
mod.createRegistryKey(mod.HK.CU, K);
});
afterEach(() => {
mod.deleteRegistryKey(mod.HK.CU, K);
});
it('should create keys', () => {
mod.createRegistryKey(mod.HK.CU, K + '\\test');
assert.notEqual(mod.getRegistryKey(mod.HK.CU, K + '\\test'), null);
});
it('should list keys', () => {
mod.createRegistryKey(mod.HK.CU, K + '\\test');
assert.equal(mod.listRegistrySubkeys(mod.HK.CU, K).length, 1);
assert.equal(mod.listRegistrySubkeys(mod.HK.CU, K)[0], 'test');
});
it('should delete keys', () => {
mod.deleteRegistryKey(mod.HK.CU, K);
assert.equal(mod.getRegistryKey(mod.HK.CU, K), null);
});
it('should write & read DWORD values', () => {
mod.setRegistryValue(mod.HK.CU, K, 'value', mod.REG.DWORD, 123);
assert.equal(mod.getRegistryValue(mod.HK.CU, K, "value"), 123);
});
it('should write & read SZ values', () => {
mod.setRegistryValue(mod.HK.CU, K, 'value', mod.REG.SZ, "123");
assert.equal(mod.getRegistryValue(mod.HK.CU, K, "value"), "123");
});
it('should read complete keys', () => {
mod.setRegistryValue(mod.HK.CU, K, 'a', mod.REG.SZ, "1");
mod.setRegistryValue(mod.HK.CU, K, 'b', mod.REG.SZ, "2");
const ret = mod.getRegistryKey(mod.HK.CU, K)
assert.deepEqual(ret.a, { name: 'a', value: '1', type: mod.REG.SZ });
assert.deepEqual(ret.b, { name: 'b', value: '2', type: mod.REG.SZ });
});
});