Last active
August 29, 2015 13:57
-
-
Save sodiumjoe/9814724 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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