Initial import from local backup (Documents-Playground/pakerpale)

This commit is contained in:
jeonghwa
2026-07-03 05:27:31 +09:00
commit 3a8de01ba0
1794 changed files with 137027 additions and 0 deletions

2
node_modules/mockery/.npmignore generated vendored Normal file
View File

@@ -0,0 +1,2 @@
coverage
node_modules

15
node_modules/mockery/.travis.yml generated vendored Normal file
View File

@@ -0,0 +1,15 @@
language: node_js
addons:
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- gcc-4.9
- g++-4.9
env: CXX=g++-4.9 CC=gcc-4.9
node_js:
- "0.10"
- "0.11"
- "0.12"
- "4"
- "6"

24
node_modules/mockery/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,24 @@
Copyrights for code authored by Yahoo! Inc. is licensed under the following
terms:
MIT License
Copyright (c) 2011 Yahoo! Inc. All Rights Reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to
deal in the Software without restriction, including without limitation the
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
sell copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.

247
node_modules/mockery/README.md generated vendored Normal file
View File

@@ -0,0 +1,247 @@
# Mockery - Simplifying the use of mocks with Node.js
[![Build Status](https://secure.travis-ci.org/mfncooper/mockery.png)](http://travis-ci.org/mfncooper/mockery)
If you've tried working with mocks in Node.js, you've no doubt discovered that
it's not so easy to get your mocks hooked up in the face of Node's module
loading system. When your source-under-test pulls in its dependencies through
`require`, you want your mocks provided, instead of the original module,
to enable true unit testing of your code.
This is exactly the problem Mockery is designed to solve. Mockery gives you a
simple and easy to use API with which you can hook in your mocks without having
to get your hands dirty with the `require` cache or other Node implementation
details.
Mockery is *not* a mocking framework. It lets you work more easily with your
framework of choice (or no framework) to get your mocks hooked in to all the
right places in the code you need to test.
* [Installation](#installation)
* [Enabling mockery](#enabling-mockery)
* [Registering mocks](#registering-mocks)
* [Registering substitutes](#registering-substitutes)
* [Registering allowable modules](#registering-allowable-modules)
* [Deregistering everything](#deregistering-everything)
* [Controlling the module cache](#controlling-the-module-cache)
* [Disabling warnings](#disabling-warnings)
* [The name](#the-name)
* [License](#license)
## Installation
Just use npm:
npm install mockery
## Enabling mockery
When enabled, Mockery intercepts *all* `require` calls, regardless of where
those calls are being made from. Thus it's almost always desirable to bracket
your usage as narrowly as possible.
If you're using a typical unit testing framework, you might enable and disable
Mockery in the test setup and teardown functions for your test cases. Something
like this:
setUp: function() {
mockery.enable();
},
tearDown: function() {
mockery.disable();
}
### Options
You can set up some initial configuration by passing an options object to
`enable`. Omitting the options object, or any of the defined keys, causes the
standard defaults to be used.
For example, to disable all warnings, you might use this:
mockery.enable({
warnOnReplace: false,
warnOnUnregistered: false
});
The available options are:
* _useCleanCache_ determines whether a temporary module cache should be used
while Mockery is enabled. See [Controlling the module cache](#controlling-the-module-cache)
below. [Default: false]
* _warnOnReplace_ determines whether or not warnings are issued when a mock or
substitute is replaced without being first deregistered. This has the same
effect as the `warnOnReplace` function. [Default: true]
* _warnOnUnregistered_ determines whether or not warnings are issued when a
module is not mocked, substituted or allowed. This has the same effect as the
`warnOnUnregistered` function. [Default: true]
## Registering mocks
You register your mocks with Mockery to tell it which mocks to provide for which
`require` calls. For example:
var fsMock = {
stat: function (path, cb) { /* your mock code */ }
};
mockery.registerMock('fs', fsMock);
The arguments to `registerMock` are as follows:
* _module_, the name or path of the module for which a mock is being
registered. This must exactly match the argument to `require`; there is no
"clever" matching.
* _mock_, the mock to be provided. Whatever is provided here is what will
become the result of subsequent `require` calls; that is, the `exports` of the
module.
If you no longer want your mock to be used, you can deregister it:
mockery.deregisterMock('fs');
Now the original module will be provided for any subsequent `require` calls.
## Registering substitutes
Sometimes you want to implement your mock itself as a module, especially if it's
more complicated and you'll be reusing it more widely. In that case, you can
tell Mockery to substitute that module for the original one. For example:
mockery.registerSubstitute('fs', 'fs-mock');
Now any `require` invocation for 'fs' will be satisfied by loading the 'fs-mock'
module instead.
The arguments to `registerSubstitute` are as follows:
* _module_, the name or path of the module for which a substitute is being
registered. This must exactly match the argument to `require`; there is no
"clever" matching.
* _substitute_, the name or path of the module to substitute for _module_.
If you no longer want your substitute to be used, you can deregister it:
mockery.deregisterSubstitute('fs');
Now the original module will be provided for any subsequent `require` calls.
## Registering allowable modules
If you enable Mockery and _don't_ mock or substitute a module that is later
loaded via `require`, Mockery will print a warning to the console to tell you
that. This is so that you don't inadvertently use downstream modules without
being aware of them. By registering a module as "allowable", you tell Mockery
that you know about its use, and then Mockery won't print the warning.
The most common use case for this is your source-under-test, which obviously
you'll want to load without warnings. For example:
mockery.registerAllowable('./my-source-under-test');
As with `registerMock` and `registerSubstitute`, the first argument, _module_,
is the name or path of the module as it would be provided to `require`. Once
again, you can deregister it if you need to:
mockery.deregisterAllowable('./my-source-under-test');
Sometimes you'll find that you need to register several modules at once. A
convenience function lets you do this with a single call:
mockery.registerAllowables(['async', 'path', 'util']);
and similarly to deregister several modules at once, as you would expect:
mockery.deregisterAllowables(['async', 'path', 'util']);
### Unhooking
By default, the Node module loader will load a given module only once, caching
the loaded module for the lifetime of the process. When you're using Mockery,
this is almost always what you want. _Almost_. In relatively rare situations,
you may find that you need to use different mocks for different test cases
for the same source-under-test. (This is not the same as supplying different
test data in the same mock; here we're talking about providing different
functions for a module's `exports`.)
To do this, your source-under-test must be unhooked from Node's module loading
system, such that it can be loaded again with new mocks. You do this by passing
a second argument, _unhook_, to `registerAllowable`, like this:
mockery.registerAllowable('./my-source-under-test', true);
When you subsequently deregister your source-under-test, Mockery will unhook it
from the Node module loading system as well as deregistering it.
## Deregistering everything
Since it's such a common use case, especially when you're using a unit test
framework and its setup and teardown functions, Mockery provides a convenience
function to deregister everything:
mockery.deregisterAll();
This will deregister all mocks, substitutes, and allowable modules, as well as
unhooking any hooked modules.
## Controlling the module cache
One of the common problems that people encounter when trying to use mocks in
Node is that modules and their exports are almost always cached. This makes it
difficult to plug in a mock for testing if the module being mocked has already
been loaded elsewhere.
Mockery provides a way for you to run your tests using a clean module cache, as
if no modules have been loaded. When this option is enabled, any previously
loaded modules will be "forgotten", and `require` calls will cause them to be
reloaded. This in turn allows your mocks to be picked up, and your tests to run
as expected.
You tell Mockery to use a clean cache when you enable it, like this:
mockery.enable({ useCleanCache: true });
Now all modules will be cached in this new clean cache, until you later disable
Mockery again. The new cache is temporary, and is discarded when Mockery is
disabled. The original cache is reinstated at that point, so you are back to
where you were before enabling the clean cache option.
While you are working with a temporary cache, it may occasionally be useful to
reset it to a clean state again, without disabling and re-enabling Mockery. You
can do this with:
mockery.resetCache();
This function has no effect if the clean cache option is not already in use.
## Disabling warnings
As mentioned above, if you enable Mockery and _don't_ mock, substitute, or
allow a module that is later loaded, Mockery will print a warning to the
console to tell you that. This is important when you're writing unit tests,
so that you don't end up using modules you weren't aware of.
In certain circumstances, such as when writing functional or integration tests,
you may find it irritating to have to allow each module or to have all the
warnings appear on the console. If you need to, you can tell Mockery to turn
off those warnings:
mockery.warnOnUnregistered(false);
Mockery will also print a warning to the console whenever you register a mock
or substitute for a module for which one is already registered. This is almost
always what you want, since you should be deregistering mocks and substitutes
that you no longer need. Occasionally, though, you may want to suppress these
warnings, which you can do like this:
mockery.warnOnReplace(false);
In either of these cases, if you later need to re-enable the warnings, then
passing `true` to the same functions will do that, as you might imagine.
## The name
Mockery is to mocks as rookery is to rooks.
## License
Mockery is licensed under the [MIT License](http://github.com/mfncooper/mockery/raw/master/LICENSE).

123
node_modules/mockery/examples/example1.js generated vendored Normal file
View File

@@ -0,0 +1,123 @@
/*
Copyrights for code authored by Yahoo! Inc. is licensed under the following
terms:
MIT License
Copyright (c) 2012 Yahoo! Inc. All Rights Reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to
deal in the Software without restriction, including without limitation the
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
sell copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
*/
/*
* This example demonstrates the use of Mockery to allow a mock to be used even
* when its requiring module has already been loaded and cached by Node. We do
* not use a test framework in this example, so that we control the sequence of
* calls to our "tests". This lets us show that tests using the original module
* dependencies can run before and / or after tests using our mock, without any
* interference in either direction.
*
* Notes:
* 1. If you change useCleanCache to 'false' in the mock test, that test will
* fail, because the module to be mocked was already cached by the previous
* test.
* 2. If, in addition to the above, you remove the call to the real test before
* the call to the mock test, the mock test will succeed but the second real
* test will fail, because the mock is now cached by Node.
* 3. If, in addition to both of the above, you amend the registration of the
* module under test to ask that it be unhooked, the remaining tests will
* pass, because Node will reload that module for the third test.
* 4. The 'useCleanCache' option is useful in particular because it avoids the
* complexities inherent in the above combinations, and lets your tests run
* in any order without the risk of cross-test interference.
*/
"use strict";
var assert = require('assert'),
mockery = require('../mockery'),
moduleUnderTest = '../test/fixtures/intermediary';
// This is the mock we will use to replace the functionality of 'fake_module',
// which is used by 'intermediary'.
var mock_fake_module = {
foo: function () {
return 'mocked foo';
}
};
/*
* Here we test 'intermediary' in its original state, without using any mocks.
* Thus the original 'fake_module' will be loaded and used by 'intermediary'.
*/
function testWithRealFoo() {
var intermediary = require(moduleUnderTest),
result = intermediary.bar();
console.log("testWithRealFoo: " + result);
assert.equal(result, "real foo");
}
/*
* Here we test 'intermediary' while mocking its dependency, 'fake_module'. Our
* mock provides different results, so that we can verify the test.
*
* Note that when a test framework is being used, it would be typical for (some
* of) the Mockery calls to be placed in setUp() and tearDown() functions.
*/
function testWithMockFoo() {
// Register the module under test (i.e. 'intermediary') as an allowable
// module, so that mockery won't complain about it being loaded.
mockery.registerAllowable(moduleUnderTest);
// Register our mock for 'fake_module', using the path that 'intermediary'
// will use to 'require' it. This tells mockery to provide our mock any
// time this path is passed to 'require'.
mockery.registerMock('./fake_module', mock_fake_module);
// Enable mockery and tell it to use a clean cache. By using a clean cache,
// Node will reload 'intermediary', causing it in turn to re-require its
// 'fake_module' dependency, at which point mockery will provide our mock.
// Without the clean cache, 'intermediary' will not be reloaded, because
// Node knows it is already loaded (and cached). This means that mockery
// has no opportunity to provide the mock, since 'fake_module' was already
// loaded by 'intermediary' and will not be re-required.
mockery.enable({ useCleanCache: true });
var intermediary = require(moduleUnderTest),
result = intermediary.bar();
console.log("testWithMockFoo: " + result);
assert.equal(result, "mocked foo");
// Now that we're done with our test, we need to disable mockery so that it
// doesn't continue intercepting 'require' calls from, for example, a test
// framework.
mockery.disable();
// Finally, we clean up by deregistering the mock and allowable that we
// registered at the beginning of the test.
mockery.deregisterAll();
}
// Mainline code
//
// We run a test using the original modules first, which causes Node to load
// and cache all of the modules. Then we run a test using a mock, showing that
// it is provided even though the original was cached. Finally, we re-run the
// test using the original modules, showing that everything was unhooked after
// the previous test.
testWithRealFoo();
testWithMockFoo();
testWithRealFoo();

347
node_modules/mockery/mockery.js generated vendored Normal file
View File

@@ -0,0 +1,347 @@
/*
Copyrights for code authored by Yahoo! Inc. is licensed under the following
terms:
MIT License
Copyright (c) 2011-2012 Yahoo! Inc. All Rights Reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to
deal in the Software without restriction, including without limitation the
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
sell copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
*/
/*
* A library that enables the hooking of the standard 'require' function, such
* that a (possibly partial) mock implementation can be provided instead. This
* is most useful for running unit tests, since any dependency obtained through
* 'require' can be mocked out.
*/
"use strict";
var m = require('module'),
registeredMocks = {},
registeredSubstitutes = {},
registeredAllowables = {},
originalLoader = null,
originalCache = null,
defaultOptions = {
useCleanCache: false,
warnOnReplace: true,
warnOnUnregistered: true
},
options = {};
/*
* Merge the supplied options in with a new copy of the default options to get
* the effective options, and return those.
*/
function getEffectiveOptions(opts) {
var options = {};
Object.keys(defaultOptions).forEach(function (key) {
options[key] = defaultOptions[key];
});
if (opts) {
Object.keys(opts).forEach(function (key) {
options[key] = opts[key];
});
}
return options;
}
/*
* The (private) loader replacement that is used when hooking is enabled. It
* does the work of returning a mock or substitute when configured, reporting
* non-allowed modules, and invoking the original loader when appropriate.
* The signature of this function *must* match that of Node's Module._load,
* since it will replace that when mockery is enabled.
*/
function hookedLoader(request, parent, isMain) {
var subst, allow, file;
if (!originalLoader) {
throw new Error("Loader has not been hooked");
}
if (registeredMocks.hasOwnProperty(request)) {
return registeredMocks[request];
}
if (registeredSubstitutes.hasOwnProperty(request)) {
subst = registeredSubstitutes[request];
if (!subst.module && subst.name) {
subst.module = originalLoader(subst.name, parent, isMain);
}
if (!subst.module) {
throw new Error("Misconfigured substitute for '" + request + "'");
}
return subst.module;
}
if (registeredAllowables.hasOwnProperty(request)) {
allow = registeredAllowables[request];
if (allow.unhook) {
file = m._resolveFilename(request, parent);
if ((file.indexOf('/') !== -1 || file.indexOf('\\') !== -1) && allow.paths.indexOf(file) === -1) {
allow.paths.push(file);
}
}
} else {
if (options.warnOnUnregistered) {
console.warn("WARNING: loading non-allowed module: " + request);
}
}
return originalLoader(request, parent, isMain);
}
/*
* Enables mockery by hooking subsequent 'require' invocations. Note that *all*
* 'require' invocations will be hooked until 'disable' is called. Calling this
* function more than once will have no ill effects.
*/
function enable(opts) {
if (originalLoader) {
// Already hooked
return;
}
options = getEffectiveOptions(opts);
if (options.useCleanCache) {
originalCache = m._cache;
m._cache = {};
repopulateNative();
}
originalLoader = m._load;
m._load = hookedLoader;
}
/*
* Disables mockery by unhooking from the Node loader. No subsequent 'require'
* invocations will be seen by mockery. Calling this function more than once
* will have no ill effects.
*/
function disable() {
if (!originalLoader) {
// Not hooked
return;
}
if (options.useCleanCache) {
// Previously this just set m._cache to originalCache. This would make
// node re-require native addons that were required while mockery was
// enabled, which breaks it in node@>=0.12. Instead populate
// originalCache with any native addons that were first required since
// mockery was enabled.
Object.keys(m._cache).forEach(function(k){
if (k.indexOf('\.node') > -1 && !originalCache[k]) {
originalCache[k] = m._cache[k];
}
});
m._cache = originalCache;
originalCache = null;
}
m._load = originalLoader;
originalLoader = null;
}
/*
* If the clean cache option is in effect, reset the module cache to an empty
* state. Calling this function when the clean cache option is not in effect
* will have no ill effects, but will do nothing.
*/
function resetCache() {
if (options.useCleanCache && originalCache) {
m._cache = {};
repopulateNative();
}
}
/*
* Starting in node 0.12 node won't reload native modules
* The reason is that native modules can register themselves to be loaded automatically
* This will re-populate the cache with the native modules that have not been mocked
*/
function repopulateNative() {
Object.keys(originalCache).forEach(function(k) {
if (k.indexOf('\.node') > -1 && !m._cache[k]) {
m._cache[k] = originalCache[k];
}
});
}
/*
* Enable or disable warnings to the console when previously registered mocks
* and subsitutes are replaced.
*/
function warnOnReplace(enable) {
options.warnOnReplace = enable;
}
/*
* Enable or disable warnings to the console when modules are loaded that have
* not been registered as a mock, a substitute, or allowed.
*/
function warnOnUnregistered(enable) {
options.warnOnUnregistered = enable;
}
/*
* Register a mock object for the specified module. While mockery is enabled,
* any subsequent 'require' for this module will return the mock object. The
* mock need not mock out all original exports, but no fallback is provided
* for anything not mocked and subsequently invoked.
*/
function registerMock(mod, mock) {
if (options.warnOnReplace && registeredMocks.hasOwnProperty(mod)) {
console.warn("WARNING: Replacing existing mock for module: " + mod);
}
registeredMocks[mod] = mock;
}
/*
* Deregister a mock object for the specified module. A subsequent 'require' for
* that module will revert to the previous behaviour (which, by default, means
* falling back to the original 'require' behaviour).
*/
function deregisterMock(mod) {
if (registeredMocks.hasOwnProperty(mod)) {
delete registeredMocks[mod];
}
}
/*
* Register a substitute module for the specified module. While mockery is
* enabled, any subsequent 'require' for this module will be effectively
* replaced by a 'require' for the substitute module. This is useful when
* a mock implementation is itself implemented as a module.
*/
function registerSubstitute(mod, subst) {
if (options.warnOnReplace && registeredSubstitutes.hasOwnProperty(mod)) {
console.warn("WARNING: Replacing existing substitute for module: " + mod);
}
registeredSubstitutes[mod] = {
name: subst
};
}
/*
* Deregister a substitute module for the specified module. A subsequent
* 'require' for that module will revert to the previous behaviour (which, by
* default, means falling back to the original 'require' behaviour).
*/
function deregisterSubstitute(mod) {
if (registeredSubstitutes.hasOwnProperty(mod)) {
delete registeredSubstitutes[mod];
}
}
/*
* Register a module as 'allowed', meaning that, even if a mock or substitute
* for it has not been registered, mockery will not complain when it is loaded
* via 'require'. This encourages the user to consciously declare the modules
* that will be loaded and used in the original form, thus avoiding warnings.
*
* If 'unhook' is true, the module will be removed from the module cache when
* it is deregistered.
*/
function registerAllowable(mod, unhook) {
registeredAllowables[mod] = {
unhook: !!unhook,
paths: []
};
}
/*
* Register an array of modules as 'allowed'. This is a convenience function
* that performs the same function as 'registerAllowable' but for an array of
* modules rather than a single module.
*/
function registerAllowables(mods, unhook) {
mods.forEach(function (mod) {
registerAllowable(mod, unhook);
});
}
/*
* Deregister a module as 'allowed'. A subsequent 'require' for that module
* will generate a warning that the module is not allowed, unless or until a
* mock or substitute is registered for that module.
*/
function deregisterAllowable(mod) {
if (registeredAllowables.hasOwnProperty(mod)) {
var allow = registeredAllowables[mod];
if (allow.unhook) {
allow.paths.forEach(function (p) {
delete m._cache[p];
});
}
delete registeredAllowables[mod];
}
}
/*
* Deregister an array of modules as 'allowed'. This is a convenience function
* that performs the same function as 'deregisterAllowable' but for an array of
* modules rather than a single module.
*/
function deregisterAllowables(mods) {
mods.forEach(function (mod) {
deregisterAllowable(mod);
});
}
/*
* Deregister all mocks, substitutes, and allowed modules, resetting the state
* to a clean slate. This does not affect the enabled / disabled state of
* mockery, though.
*/
function deregisterAll() {
Object.keys(registeredAllowables).forEach(function (mod) {
var allow = registeredAllowables[mod];
if (allow.unhook) {
allow.paths.forEach(function (p) {
delete m._cache[p];
});
}
});
registeredMocks = {};
registeredSubstitutes = {};
registeredAllowables = {};
}
// Exported functions
exports.enable = enable;
exports.disable = disable;
exports.resetCache = resetCache;
exports.warnOnReplace = warnOnReplace;
exports.warnOnUnregistered = warnOnUnregistered;
exports.registerMock = registerMock;
exports.registerSubstitute = registerSubstitute;
exports.registerAllowable = registerAllowable;
exports.registerAllowables = registerAllowables;
exports.deregisterMock = deregisterMock;
exports.deregisterSubstitute = deregisterSubstitute;
exports.deregisterAllowable = deregisterAllowable;
exports.deregisterAllowables = deregisterAllowables;
exports.deregisterAll = deregisterAll;

86
node_modules/mockery/package.json generated vendored Normal file
View File

@@ -0,0 +1,86 @@
{
"_from": "mockery@^1.4.0",
"_id": "mockery@1.7.0",
"_inBundle": false,
"_integrity": "sha1-9O3g2HUMHJcnwnLqLGBiniyaHE8=",
"_location": "/mockery",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "mockery@^1.4.0",
"name": "mockery",
"escapedName": "mockery",
"rawSpec": "^1.4.0",
"saveSpec": null,
"fetchSpec": "^1.4.0"
},
"_requiredBy": [
"/simple-oauth-server"
],
"_resolved": "https://registry.npmjs.org/mockery/-/mockery-1.7.0.tgz",
"_shasum": "f4ede0d8750c1c9727c272ea2c60629e2c9a1c4f",
"_spec": "mockery@^1.4.0",
"_where": "D:\\dev\\xmap\\cm-oauth\\node_modules\\simple-oauth-server",
"author": {
"name": "Martin Cooper",
"email": "mfncooper@gmail.com"
},
"bugs": {
"url": "http://github.com/mfncooper/mockery/issues"
},
"bundleDependencies": false,
"contributors": [
{
"name": "Bryan Donovan",
"email": "bdondo@gmail.com"
},
{
"name": "Dav Glass",
"email": "davglass@gmail.com"
}
],
"dependencies": {},
"deprecated": false,
"description": "Simplifying the use of mocks with Node.js",
"devDependencies": {
"istanbul": "~0.3.5",
"jshint": "~2.6.0",
"sinon": "1.2.x",
"unix-dgram": "^0.2.3",
"vows": "~0.8.1"
},
"homepage": "https://github.com/mfncooper/mockery#readme",
"jshintConfig": {
"node": true
},
"keywords": [
"mock",
"stub",
"require",
"module",
"cache",
"unit",
"test",
"unittest",
"testing",
"tdd"
],
"licenses": [
{
"type": "MIT",
"url": "http://github.com/mfncooper/mockery/raw/master/LICENSE"
}
],
"main": "mockery.js",
"name": "mockery",
"repository": {
"type": "git",
"url": "git://github.com/mfncooper/mockery.git"
},
"scripts": {
"pretest": "jshint mockery.js ./test/*.js",
"test": "istanbul cover --print both -- vows --spec ./test/*.js"
},
"version": "1.7.0"
}

41
node_modules/mockery/test/1-general.js generated vendored Normal file
View File

@@ -0,0 +1,41 @@
/*
This file named 1-general.js for a reason, it is so this
test is executed first so we can catch the "warmup" of the
module and test the dead code cases.
*/
var vows = require('vows'),
assert = require('assert'),
m = require('module'),
mockery = require('../mockery');
var tests = {
'disable before enable': {
topic: function() {
mockery.disable();
return null;
},
'should not throw and this passes': function() {
assert.ok(true);
},
'and without a module loader': {
topic: function() {
m.__load = m._load;
m._load = null;
return m;
},
'should throw on enable': function(m) {
assert.throws(function() {
mockery.enable();
mockery.registerMock('fs', {});
require('fs');
}, /Loader has not been hooked/);
},
teardown: function() {
m._load = m.__load;
delete m.__load;
}
}
}
};
vows.describe('mockery').addBatch(tests).export(module);

71
node_modules/mockery/test/allowable-unhook.js generated vendored Normal file
View File

@@ -0,0 +1,71 @@
var vows = require('vows'),
assert = require('assert'),
mockery = require('../mockery'),
sinon = require('sinon'),
m = require('module');
function isCached(name) {
var id;
// Super-simplistic, but good enough for the tests
for (id in m._cache) {
if (m._cache.hasOwnProperty(id) && id.indexOf(name) !== -1) {
return true;
}
}
return false;
}
var tests = {
"when an allowable is registered for unhooking": {
topic: function () {
mockery.registerAllowable('./fixtures/fake_module', true);
return null;
},
"and mockery is enabled": {
setup: function () {
if (!this.originalCache) {
// Initialise a clean cache
this.originalCache = m._cache;
m._cache = {};
}
mockery.enable();
},
teardown: function () {
if (this.originalCache) {
// Restore the original cache
m._cache = this.originalCache;
this.originalCache = null;
}
},
"the module is not cached": function () {
assert.ok(!isCached('fixtures/fake_module'));
},
"and the module is required": {
topic: function () {
require('./fixtures/fake_module');
return null;
},
"the module is cached": function () {
assert.ok(isCached('fixtures/fake_module'));
},
"and the module is deregistered": {
topic: function () {
mockery.deregisterAllowable('not-allowed-already');
mockery.deregisterAllowable('./fixtures/fake_module');
return null;
},
"the module is not cached": function () {
assert.ok(!isCached('fixtures/fake_module'));
}
}
}
}
}
};
vows.describe('allowable-unhook').addBatch(tests).export(module);

5
node_modules/mockery/test/fixtures/fake_module.js generated vendored Normal file
View File

@@ -0,0 +1,5 @@
var foo = function() {
return 'real foo';
};
exports.foo = foo;

5
node_modules/mockery/test/fixtures/fake_module_2.js generated vendored Normal file
View File

@@ -0,0 +1,5 @@
var bar = function() {
return 'real bar';
};
exports.bar = bar;

7
node_modules/mockery/test/fixtures/intermediary.js generated vendored Normal file
View File

@@ -0,0 +1,7 @@
var fake_module = require('./fake_module');
var bar = function () {
return fake_module.foo();
};
exports.bar = bar;

View File

@@ -0,0 +1,5 @@
var foo = function() {
return 'substitute foo';
};
exports.foo = foo;

61
node_modules/mockery/test/intermediary.js generated vendored Normal file
View File

@@ -0,0 +1,61 @@
var vows = require('vows'),
assert = require('assert'),
mockery = require('../mockery'),
sinon = require('sinon');
var mock_fake_module = {
foo: function () {
return 'mocked foo';
}
};
var tests = {
"when an intermediary module is involved": {
topic: function() {
return null;
},
"and mockery is not enabled requiring the intermediary causes the original to be used": function () {
var intermediary = require('./fixtures/intermediary');
assert.equal(intermediary.bar(), 'real foo');
},
"and mockery is enabled without the clean cache option": {
topic: function () {
mockery.registerMock('./fake_module', mock_fake_module);
mockery.registerAllowable('./fixtures/intermediary');
mockery.enable({ useCleanCache: false });
var i = require('./fixtures/intermediary');
mockery.resetCache();
mockery.disable();
return i;
},
"requiring the intermediary causes the original to be used": function (intermediary) {
assert.equal(intermediary.bar(), 'real foo');
},
"then mockery is enabled with the clean cache option": {
topic: function () {
mockery.registerMock('./fake_module', mock_fake_module);
mockery.registerAllowable('./fixtures/intermediary');
mockery.enable({ useCleanCache: true });
var i = require('./fixtures/intermediary');
mockery.resetCache();
return i;
},
"requiring the intermediary causes the mock to be used": function (intermediary) {
assert.equal(intermediary.bar(), 'mocked foo');
},
"then mockery is disabled": {
topic: function() {
mockery.disable();
return require('./fixtures/intermediary');
},
"requiring the intermediary causes the original to be used": function (intermediary) {
assert.equal(intermediary.bar(), 'real foo');
}
}
}
}
}
};
vows.describe('intermediary').addBatch(tests).export(module);

61
node_modules/mockery/test/logging-allow-array.js generated vendored Normal file
View File

@@ -0,0 +1,61 @@
var vows = require('vows'),
assert = require('assert'),
mockery = require('../mockery'),
sinon = require('sinon');
var tests = {
"when an array of allowables is registered": {
setup: function () {
mockery.registerAllowables(
['./fixtures/fake_module', './fixtures/fake_module_2']
);
},
"and mockery is enabled": {
topic: function () {
mockery.enable();
return null;
},
"requiring the modules causes no warning to be logged": function () {
var mock_console, fake_module, fake_module_2;
mock_console = sinon.mock(console);
mock_console.expects('warn').never();
fake_module = require('./fixtures/fake_module');
assert.equal(fake_module.foo(), 'real foo');
fake_module_2 = require('./fixtures/fake_module_2');
assert.equal(fake_module_2.bar(), 'real bar');
mock_console.verify();
mock_console.restore();
},
"and the allowables are deregistered": {
topic: function () {
mockery.deregisterAllowables(
['./fixtures/fake_module', './fixtures/fake_module_2']
);
return null;
},
"requiring the modules causes warnings to be logged": function () {
var mock_console, fake_module, fake_module_2;
mock_console = sinon.mock(console);
mock_console.expects('warn').twice();
fake_module = require('./fixtures/fake_module');
assert.equal(fake_module.foo(), 'real foo');
fake_module_2 = require('./fixtures/fake_module_2');
assert.equal(fake_module_2.bar(), 'real bar');
mock_console.verify();
mock_console.restore();
}
}
}
}
};
vows.describe('logging-allowable-array').addBatch(tests).export(module);

52
node_modules/mockery/test/logging-allowable.js generated vendored Normal file
View File

@@ -0,0 +1,52 @@
var vows = require('vows'),
assert = require('assert'),
mockery = require('../mockery'),
sinon = require('sinon');
var tests = {
"when an allowable is registered": {
setup: function () {
mockery.registerAllowable('./fixtures/fake_module');
},
"and mockery is enabled": {
topic: function () {
mockery.enable();
return null;
},
"requiring the module causes no warning to be logged": function () {
var mock_console, fake_module;
mock_console = sinon.mock(console);
mock_console.expects('warn').never();
fake_module = require('./fixtures/fake_module');
assert.equal(fake_module.foo(), 'real foo');
mock_console.verify();
mock_console.restore();
},
"and the allowable is deregistered": {
topic: function () {
mockery.deregisterAllowable('./fixtures/fake_module');
return null;
},
"requiring the module causes a warning to be logged": function () {
var mock_console, fake_module;
mock_console = sinon.mock(console);
mock_console.expects('warn').once();
fake_module = require('./fixtures/fake_module');
assert.equal(fake_module.foo(), 'real foo');
mock_console.verify();
mock_console.restore();
}
}
}
}
};
vows.describe('logging-allowable').addBatch(tests).export(module);

71
node_modules/mockery/test/logging.js generated vendored Normal file
View File

@@ -0,0 +1,71 @@
var vows = require('vows'),
assert = require('assert'),
mockery = require('../mockery'),
sinon = require('sinon');
var tests = {
teardown: function () {
mockery.disable();
mockery.deregisterAll();
},
"when nothing is registered": {
topic: function () {
mockery.enable();
mockery.registerAllowable('../package.json', true);
require('../package.json');
return null;
},
"requiring a module causes a warning to be logged": function () {
var mock_console, fake_module;
mock_console = sinon.mock(console);
mock_console.expects('warn').once();
fake_module = require('./fixtures/fake_module');
assert.equal(fake_module.foo(), 'real foo');
mock_console.verify();
mock_console.restore();
},
"and warnings are disabled": {
topic: function () {
mockery.warnOnUnregistered(false);
return null;
},
"requiring a module causes no warning to be logged": function (test) {
var mock_console, fake_module;
mock_console = sinon.mock(console);
mock_console.expects('warn').never();
fake_module = require('./fixtures/fake_module');
assert.equal(fake_module.foo(), 'real foo');
mock_console.verify();
mock_console.restore();
},
"and warnings are reenabled": {
topic: function (callback) {
mockery.warnOnUnregistered(true);
return null;
},
"requiring a module causes a warning to be logged": function () {
var mock_console, fake_module;
mock_console = sinon.mock(console);
mock_console.expects('warn').once();
fake_module = require('./fixtures/fake_module');
assert.equal(fake_module.foo(), 'real foo');
mock_console.verify();
mock_console.restore();
}
}
}
}
};
vows.describe('logging').addBatch(tests).export(module);

39
node_modules/mockery/test/registered.js generated vendored Normal file
View File

@@ -0,0 +1,39 @@
var vows = require('vows'),
assert = require('assert'),
mockery = require('../mockery'),
sinon = require('sinon');
var mock_fake_module = {
foo: function () {
return 'mocked foo';
}
};
var tests = {
"when a mock is registered": {
topic: function () {
mockery.registerMock('./fixtures/fake_module', mock_fake_module);
mockery.enable();
return null;
},
"requiring the module returns the mock instead": function () {
var fake_module = require('./fixtures/fake_module');
assert.equal(fake_module.foo(), 'mocked foo');
},
"requiring the module returns the original module": function () {
mockery.deregisterMock('not-a-mock', mock_fake_module);
mockery.deregisterMock('./fixtures/fake_module', mock_fake_module);
mockery.registerAllowable('./fixtures/fake_module');
var fake_module = require('./fixtures/fake_module');
assert.equal(fake_module.foo(), 'real foo');
},
"and mockery is then disabled requiring the module returns the original module": function () {
mockery.disable();
var fake_module = require('./fixtures/fake_module');
assert.equal(fake_module.foo(), 'real foo');
}
}
};
vows.describe('registered').addBatch(tests).export(module);

36
node_modules/mockery/test/self-register.js generated vendored Normal file
View File

@@ -0,0 +1,36 @@
var vows = require('vows'),
assert = require('assert'),
mockery = require('../mockery');
var registerBin = function () {
var error = 0;
mockery.enable({
warnOnUnregistered: false,
useCleanCache: true
});
try {
require('unix-dgram'); //or some other binary module
} catch (err) {
error = 1;
}
mockery.deregisterAll();
mockery.disable();
return error;
};
var tests = {
"register bin": {
topic: function () {
var errors = 0;
for (var i = 0; i < 10; i++) {
errors += registerBin();
}
return errors;
},
"should be able to register a bin module multiple times": function(topic) {
assert.equal(topic, 0);
}
}
};
vows.describe('module-failed-to-self-register').addBatch(tests).export(module);

96
node_modules/mockery/test/substitute.js generated vendored Normal file
View File

@@ -0,0 +1,96 @@
var vows = require('vows'),
assert = require('assert'),
mockery = require('../mockery'),
sinon = require('sinon');
var mock_fake_module = {
foo: function () {
return 'mocked foo';
}
};
var tests = {
"when a substitute is registered": {
setup: function () {
mockery.registerSubstitute('./fixtures/fake_module',
'./fixtures/substitute_fake_module');
},
teardown: function () {
mockery.deregisterSubstitute('not-registered-mock');
mockery.deregisterSubstitute('./fixtures/fake_module');
},
"and mockery is enabled": {
topic: function () {
mockery.enable();
return null;
},
"requiring the module returns the substitute instead": function () {
var fake_module = require('./fixtures/fake_module');
assert.equal(fake_module.foo(), 'substitute foo');
},
"throws on an invalid module": function() {
assert.throws(function() {
mockery.registerSubstitute('fs', 'does-not-exist-fs');
require('fs');
}, /Cannot find module/);
},
"throws on an invalid substitute module": function() {
assert.throws(function() {
mockery.registerSubstitute('fs');
require('fs');
}, /Misconfigured substitute for/);
},
"registering a replacement causes a warning to be logged": function () {
var mock_console;
mock_console = sinon.mock(console);
mock_console.expects('warn').once();
mockery.registerSubstitute('./fixtures/fake_module',
'./fixtures/substitute_fake_module');
mock_console.verify();
mock_console.restore();
},
"and warnings are disabled": {
topic: function () {
mockery.warnOnReplace(false);
return null;
},
"registering a replacement causes no warning to be logged": function () {
var mock_console;
mock_console = sinon.mock(console);
mock_console.expects('warn').never();
mockery.registerSubstitute('./fixtures/fake_module',
'./fixtures/substitute_fake_module');
mock_console.verify();
mock_console.restore();
},
"and warnings are reenabled": {
topic: function () {
mockery.warnOnReplace(true);
return null;
},
"registering a replacement causes a warning to be logged": function () {
var mock_console;
mock_console = sinon.mock(console);
mock_console.expects('warn').once();
mockery.registerSubstitute('./fixtures/fake_module',
'./fixtures/substitute_fake_module');
mock_console.verify();
mock_console.restore();
}
}
}
}
}
};
vows.describe('substitute').addBatch(tests).export(module);

52
node_modules/mockery/test/warn-replace.js generated vendored Normal file
View File

@@ -0,0 +1,52 @@
var vows = require('vows'),
assert = require('assert'),
mockery = require('../mockery'),
sinon = require('sinon');
var mock_fake_module = {
foo: function () {
return 'mocked foo';
}
};
var tests = {
"warnings are disabled": {
topic: function () {
mockery.enable();
mockery.warnOnReplace(false);
return null;
},
"registering a replacement causes no warning to be logged": function() {
var mock_console;
mock_console = sinon.mock(console);
mock_console.expects('warn').never();
mockery.registerMock('./fixtures/fake_module', mock_fake_module);
mock_console.verify();
mock_console.restore();
},
"and warnings are reenabled": {
topic: function () {
mockery.warnOnReplace(true);
return null;
},
"registering a replacement causes a warning to be logged": function () {
var mock_console;
mock_console = sinon.mock(console);
mock_console.expects('warn').once();
mockery.registerMock('./fixtures/fake_module', mock_fake_module);
mock_console.verify();
mock_console.restore();
}
}
}
};
vows.describe('warn-replace').addBatch(tests).export(module);