Last active
December 21, 2015 22:59
-
-
Save james-huston/6379433 to your computer and use it in GitHub Desktop.
Test and angular service by injecting a fake mock dependency
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
describe('When using the SocketClient provider', function () { | |
var client, mockEngineio, globalComms; | |
beforeEach(module(function ($provide) { | |
mockEngineio = { | |
connect: function (data) { | |
throw new Error('blarg!'); | |
}, | |
$get: function () { | |
console.log('boogers'); | |
return { | |
socket: function () {} | |
}; | |
} | |
}; | |
$provide.provider('engineio', mockEngineio); | |
})); | |
beforeEach(function () { | |
module('Core.Services.SocketClient'); | |
module('Services.Communicator'); | |
inject(function ($injector, Communicator, $rootScope) { | |
client = $injector.invoke('socketclient', function (socketclient) { | |
return socketclient; | |
}); | |
globalComms = Communicator; | |
}); | |
}); | |
describe('and testing the basics it', function () { | |
it('should do something...', function () { | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment