docs(mock.inject): Fix the example

And explicitly say that you need to load your application modules that you wanna test.
This commit is contained in:
Vojta Jina 2012-03-05 19:28:03 -08:00
parent b49ddf9848
commit 64912069ca

29
src/angular-mocks.js vendored
View file

@ -1528,35 +1528,36 @@ window.jasmine && (function(window) {
* Example of what a typical jasmine tests looks like with the inject method.
* <pre>
*
* angular.module('myTestsModule', [], function($provide) {
* $provide.value('mode', 'test');
* });
* angular.module('myApplicationModule', [])
* .value('mode', 'app')
* .value('version', 'v1.0.1');
*
*
* describe('MyApp', function() {
*
* // you can list multiple module function or aliases
* // which will be used in creating the injector
* beforeEach(module('myTestModule', function($provide) {
* // $provide service is configured as needed
* $provide.value('version', 'v1.0.1');
* });
* // You need to load modules that you want to test,
* // it loads only the "ng" module by default.
* beforeEach(module('myApplicationModule'));
*
* // The inject() is used to get references.
*
* // inject() is used to inject arguments of all given functions
* it('should provide a version', inject(function(mode, version) {
* expect(version).toEqual('v1.0.1');
* expect(mode).toEqual('test');
* });
* expect(mode).toEqual('app');
* }));
*
*
* // The inject and module method can also be used inside of the it or beforeEach
* it('should override a version and test the new version is injected', function(){
* it('should override a version and test the new version is injected', function() {
* // module() takes functions or strings (module aliases)
* module(function($provide) {
* $provide.value('version', 'overridden'); // override version here
* });
*
* inject(function(version) {
* expect(version).toEqual('overridden');
* });
* ));
*
* });
*
* </pre>