-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
99 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/** | ||
* A mock implementation of the Windows shell execute API. | ||
* This is used for our tests | ||
*/ | ||
'use strict'; | ||
require('ref'); | ||
var debug = require('debug')('windows-registry'), | ||
assert = require('assert'), | ||
struct = require('ref-struct'), | ||
uniontype = require('ref-union'), | ||
types = require('../../lib/types'); | ||
|
||
var DUMMYUNIONNAME = uniontype({ | ||
hIcon: types.HANDLE, | ||
hMonitor: types.HANDLE | ||
}); | ||
|
||
var SHELLEXECUTEINFO = struct({ | ||
cbSize: types.DWORD, | ||
fMask: types.ULONG, | ||
hwnd: types.HWND, | ||
lpVerb: types.STRING, | ||
lpFile: types.STRING, | ||
lpParameters: types.STRING, | ||
lpDirectory: types.STRING, | ||
nShow: types.INT, | ||
hInstApp: types.HINSTANCE, | ||
lpIDList: types.LPVOID, | ||
lpClass: types.STRING, | ||
hkeyClass: types.HKEY, | ||
dwHotKey: types.DWORD, | ||
DUMMYUNIONNAME: DUMMYUNIONNAME, | ||
hProcess: types.HANDLE | ||
}); | ||
|
||
var shell32Mock = { | ||
ShellExecuteExA: function () { | ||
} | ||
}; | ||
shell32Mock.ShellExecuteExA.async = function (type, cb) { | ||
debug('async'); | ||
debug(type.deref().lpFile); | ||
assert.deepEqual(type.type.fields.cbSize, SHELLEXECUTEINFO.fields.cbSize); | ||
cb(null, true); | ||
}; | ||
|
||
module.exports = shell32Mock; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* global describe, it */ | ||
'use strict'; | ||
if (process.env.TEST_MOCKS_ON) { | ||
require('./test_helper'); | ||
} | ||
|
||
var utils = require('../lib/utils'), | ||
assert = require('assert'); | ||
|
||
describe('File Association Test', () => { | ||
it('Should create a file association for *.zzz files', () => { | ||
utils.associateExeForFile('myTestHandler', 'A test handler for unit tests', '', 'C:\\Program Files\\nodejs\\node.exe %1', '.zzz'); | ||
assert(true); | ||
}); | ||
}); | ||
|
||
describe('UAC elevate tests', () => { | ||
it('Should get results for elevate for a given file', (done) => { | ||
utils.elevate('C:\\Program Files\\nodejs\\node.exe', 'index.js', function (err, result) { | ||
assert.equal(err, null); | ||
assert.equal(result, true); | ||
done(); | ||
}); | ||
}); | ||
|
||
it('Empty file path, should return with error', (done) => { | ||
utils.elevate('', null, function (err, result) { | ||
assert.equal(err, 'Missing filepath'); | ||
assert.equal(result, null); | ||
done(); | ||
}); | ||
}); | ||
|
||
it('Null file path, should return with error', (done) => { | ||
utils.elevate(null, null, function (err, result) { | ||
assert.equal(err, 'Missing filepath'); | ||
assert.equal(result, null); | ||
done(); | ||
}); | ||
}); | ||
}); |