Skip to content

Instantly share code, notes, and snippets.

@sodiumjoe
Last active August 29, 2015 13:57
Show Gist options
  • Save sodiumjoe/9814724 to your computer and use it in GitHub Desktop.
Save sodiumjoe/9814724 to your computer and use it in GitHub Desktop.
module.exports = {
provideAndSpy: function provideAndSpy($provide, spy, inj, name, methods) {
'use strict';
var mock = _(methods)
.map(function(method) { return [method, function() {
var key = [name, method].join('.');
return inj[key];
}]})
.zipObject()
.value();
_.each(methods, function(method) {
var module = spy[name] || {};
spy[name] = module;
module[method] = sinon.spy(mock, method);
})
$provide.value(name, mock);
}
};
var TestUtil = require('../test-util.js');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment