help-me-test
Advanced tools
Comparing version 0.0.1 to 0.0.2
@@ -8,2 +8,3 @@ module.exports = function(grunt) { | ||
grunt.loadNpmTasks('grunt-contrib-clean'); | ||
grunt.loadNpmTasks('grunt-release'); | ||
@@ -10,0 +11,0 @@ var src = ['lib/**/*.js', 'index.js', 'bin/*']; |
@@ -1,4 +0,5 @@ | ||
var path = require('path'); | ||
var fs = require('fs'); | ||
var sinon = require('sinon'); | ||
var path = require('path'); | ||
var fs = require('fs'); | ||
var sinon = require('sinon'); | ||
var proxyquire = require('proxyquire'); | ||
@@ -49,2 +50,19 @@ module.exports = function () { | ||
/** | ||
* Use proxyquire to require a module with mocks | ||
* @param {string} modulePath - path to module, relative to project lib directory | ||
* @returns {function} | ||
*/ | ||
proxy: function () { | ||
var args = Array.prototype.slice.call(arguments, 0); | ||
var modulePath; | ||
args.unshift(this.testRoot, '..', 'lib'); | ||
modulePath = path.resolve.apply(path, args); | ||
return function (modulePath, mocks) { | ||
return proxyquire(modulePath, mocks || {}); | ||
}.bind(null, modulePath); | ||
}, | ||
/** | ||
* Require mock module | ||
@@ -51,0 +69,0 @@ * @param {string} modulePath - path to module, relative to test mocks directory |
{ | ||
"name": "help-me-test", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"author": "Seth McLaughlin", | ||
@@ -11,3 +11,4 @@ "license": "MIT", | ||
"dependencies": { | ||
"sinon": "~1.10.2" | ||
"sinon": "~1.10.2", | ||
"proxyquire": "~1.0.1" | ||
}, | ||
@@ -27,4 +28,6 @@ "devDependencies": { | ||
"coveralls": "~2.10.0", | ||
"mocha-lcov-reporter": "0.0.1" | ||
"mocha-lcov-reporter": "0.0.1", | ||
"grunt-cli": "~0.1.13", | ||
"grunt-release": "~0.7.0" | ||
} | ||
} |
@@ -63,2 +63,21 @@ var index = require('../../../lib'); | ||
describe('proxy()', function () { | ||
beforeEach(function () { | ||
h.testRoot = path.resolve(__dirname, '..', '..', 'fixtures', 'fake_test_root'); | ||
}); | ||
it('should require the correct child module', function () { | ||
assert.strictEqual(h.proxy('one')(), 1); | ||
}); | ||
it('should require the correct descendant module', function () { | ||
assert.strictEqual(h.proxy('sub', 'two')()(), 2); | ||
}); | ||
it('should require the correct child module with the correct mock', function () { | ||
var module = h.proxy('sub', 'three')({ 'fs': 45 }); | ||
assert.strictEqual(module.myFs, 45); | ||
}); | ||
}); | ||
describe('mock()', function () { | ||
@@ -65,0 +84,0 @@ it('should require the correct child module', function () { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
13199
25
399
2
15
7
+ Addedproxyquire@~1.0.1
+ Addedproxyquire@1.0.1(transitive)