From 64912069caeb5a05da449b6ee04c965477f3ae25 Mon Sep 17 00:00:00 2001 From: Vojta Jina Date: Mon, 5 Mar 2012 19:28:03 -0800 Subject: docs(mock.inject): Fix the example And explicitly say that you need to load your application modules that you wanna test.--- src/angular-mocks.js | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/angular-mocks.js b/src/angular-mocks.js index 625dcf44..93136698 100644 --- a/src/angular-mocks.js +++ b/src/angular-mocks.js @@ -1528,35 +1528,36 @@ window.jasmine && (function(window) { * Example of what a typical jasmine tests looks like with the inject method. *
*
- * 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');
* });
* ));
- *
* });
*
*
--
cgit v1.2.3