New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

immutable-automock

Package Overview
Dependencies
Maintainers
1
Versions
127
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

immutable-automock - npm Package Compare versions

Comparing version 0.1.1 to 0.3.0

lib/automock/http-client.js

8

lib/automock/core.js

@@ -34,7 +34,11 @@ 'use strict'

*
* @param {object} immutable
* @param {function} method
*/
function automock (method) {
// require function
if (typeof method !== 'function') {
throw new Error('automock error: automock must be called with function')
}
// create automock wrapper function
var automockWrapper = function automockWrapper (args) {
var automockWrapper = function coreAutomockWrapper (args) {
// require args to be object

@@ -41,0 +45,0 @@ args = requireValidOptionalObject(args)

@@ -17,2 +17,3 @@ 'use strict'

core: require('./automock/core'),
httpClient: require('./automock/http-client')
},

@@ -24,5 +25,14 @@ reset: reset,

/* apply automock when required */
// apply automock when first required
mock()
// mapping table of mock data type names to modules
const moduleNameByMockDataType = {
moduleCall: 'core',
moduleCallResolve: 'core',
httpRequest: 'httpClient',
httpRequestError: 'httpClient',
httpResponse: 'httpClient',
}
/**

@@ -112,3 +122,3 @@ * @function loadMock

var library = require(module.libraryName)
// set automock function on library
// apply automock function on library
library.automock(module.automock)

@@ -118,3 +128,5 @@ // set success flag

}
catch (ex) {}
catch (ex) {
console.log(ex)
}
})

@@ -174,8 +186,6 @@

}
// load mock data for core (immutable-core) mocks
if (mockData.type === 'moduleCall' || mockData.type === 'moduleCallResolve') {
automock.module.core.loadMock(mockData, options)
}
// mock data type not recognized
else {
// get automock module name by mock data type
var moduleName = moduleNameByMockDataType[mockData.type]
// require type to be defined with module name
if (!moduleName) {
if (options.ignoreInvalidMockDataType) {

@@ -188,2 +198,4 @@ return

}
// load mock into target module
automock.module[moduleName].loadMock(mockData, options)
}

@@ -12,3 +12,5 @@ {

"chai-as-promised": "^6.0.0",
"http-promise": "^0.1.4",
"immutable-core": "^0.3.2",
"immutable-http-client": "^0.3.0",
"mocha": "^3.0.2"

@@ -26,3 +28,3 @@ },

},
"version": "0.1.1"
"version": "0.3.0"
}

@@ -29,3 +29,3 @@ 'use strict'

// check that foo is wrapped with automock function
assert.match(fooModule.foo.toString(), /automockWrapper/)
assert.match(fooModule.foo.toString(), /coreAutomockWrapper/)
})

@@ -32,0 +32,0 @@

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