Skip to content

Commit 6491206

Browse files
committed
docs(mock.inject): Fix the example
And explicitly say that you need to load your application modules that you wanna test.
1 parent b49ddf9 commit 6491206

File tree

1 file changed

+15
-14
lines changed

1 file changed

+15
-14
lines changed

src/angular-mocks.js

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1528,35 +1528,36 @@ window.jasmine && (function(window) {
15281528
* Example of what a typical jasmine tests looks like with the inject method.
15291529
* <pre>
15301530
*
1531-
* angular.module('myTestsModule', [], function($provide) {
1532-
* $provide.value('mode', 'test');
1533-
* });
1531+
* angular.module('myApplicationModule', [])
1532+
* .value('mode', 'app')
1533+
* .value('version', 'v1.0.1');
1534+
*
15341535
*
15351536
* describe('MyApp', function() {
15361537
*
1537-
* // you can list multiple module function or aliases
1538-
* // which will be used in creating the injector
1539-
* beforeEach(module('myTestModule', function($provide) {
1540-
* // $provide service is configured as needed
1541-
* $provide.value('version', 'v1.0.1');
1542-
* });
1538+
* // You need to load modules that you want to test,
1539+
* // it loads only the "ng" module by default.
1540+
* beforeEach(module('myApplicationModule'));
1541+
*
15431542
*
1544-
* // The inject() is used to get references.
1543+
* // inject() is used to inject arguments of all given functions
15451544
* it('should provide a version', inject(function(mode, version) {
15461545
* expect(version).toEqual('v1.0.1');
1547-
* expect(mode).toEqual('test');
1548-
* });
1546+
* expect(mode).toEqual('app');
1547+
* }));
1548+
*
15491549
*
15501550
* // The inject and module method can also be used inside of the it or beforeEach
1551-
* it('should override a version and test the new version is injected', function(){
1551+
* it('should override a version and test the new version is injected', function() {
1552+
* // module() takes functions or strings (module aliases)
15521553
* module(function($provide) {
15531554
* $provide.value('version', 'overridden'); // override version here
15541555
* });
1556+
*
15551557
* inject(function(version) {
15561558
* expect(version).toEqual('overridden');
15571559
* });
15581560
* ));
1559-
*
15601561
* });
15611562
*
15621563
* </pre>

0 commit comments

Comments
 (0)