Created
August 29, 2012 23:49
-
-
Save fivetanley/3520558 to your computer and use it in GitHub Desktop.
The worst dependency mock/stub api of all time
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
ChatController = module.isolate(__dirname + '/../../lib/controllers/chat_controller' ) | |
validator = ChatController.dependencies.find( /validator\S+index\.js/ ) | |
describe 'ChatController', -> | |
sockets = | |
foo: {} | |
baz: 'foo' | |
bar: 'baz' | |
on: sinon.stub() | |
for own key,socket of sockets | |
socket.emit = sinon.stub() unless key is 'on' | |
chatController = new ChatController( sockets ) | |
describe 'when a client sends a message', -> | |
beforeEach -> | |
ChatController::handleMessage.call( | |
{ sockets: sockets } | |
, 'hello' | |
, sockets.foo | |
) | |
it 'sanitizes that message for xss', -> | |
expect( validator.sanitize ).to.have.been.calledWith( 'hello' ) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment