Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

help-me-test

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

help-me-test - npm Package Compare versions

Comparing version 0.0.1 to 0.0.2

test/fixtures/lib/sub/three.js

1

Gruntfile.js

@@ -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

9

package.json
{
"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 () {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc