@@ -9,13 +9,20 @@ describe('mock modules', function() {
9
9
newModule . value ( 'version' , '2' ) ;
10
10
} ;
11
11
12
- // A second module overriding the 'version' service.
12
+ // A second module overriding the 'version' service.
13
13
// This module shows the use of a string for the load
14
14
// function.
15
15
// TODO(julie): Consider this syntax. Should we allow loading the
16
16
// modules from files? Provide helpers?
17
17
var mockModuleB = "angular.module('moduleB', []).value('version', '3');" ;
18
18
19
+ // A third module overriding the 'version' service. This function
20
+ // references the additional argument provided through addMockModule().
21
+ var mockModuleC = function ( ) {
22
+ var newModule = angular . module ( 'moduleC' , [ ] ) ;
23
+ newModule . value ( 'version' , arguments [ 1 ] ) ;
24
+ } ;
25
+
19
26
afterEach ( function ( ) {
20
27
browser . clearMockModules ( ) ;
21
28
} ) ;
@@ -48,24 +55,32 @@ describe('mock modules', function() {
48
55
expect ( element ( by . css ( '[app-version]' ) ) . getText ( ) ) . toEqual ( '2' ) ;
49
56
} ) ;
50
57
58
+ it ( 'should have the version provided as fourth parameter through the Module C' , function ( ) {
59
+ browser . addMockModule ( 'moduleC' , mockModuleC , 'unused' , '42' ) ;
60
+
61
+ browser . get ( 'index.html' ) ;
62
+
63
+ expect ( element ( by . css ( '[app-version]' ) ) . getText ( ) ) . toEqual ( '42' ) ;
64
+ } ) ;
65
+
51
66
it ( 'should load mock modules after refresh' , function ( ) {
52
67
browser . addMockModule ( 'moduleA' , mockModuleA ) ;
53
68
54
- browser . get ( 'index.html' ) ;
69
+ browser . get ( 'index.html' ) ;
55
70
expect ( element ( by . css ( '[app-version]' ) ) . getText ( ) ) . toEqual ( '2' ) ;
56
71
57
72
browser . navigate ( ) . refresh ( ) ;
58
73
expect ( element ( by . css ( '[app-version]' ) ) . getText ( ) ) . toEqual ( '2' ) ;
59
74
} ) ;
60
75
61
- // Back and forward do NOT work at the moment because of an issue
76
+ // Back and forward do NOT work at the moment because of an issue
62
77
// bootstrapping with Angular
63
- /*
78
+ /*
64
79
it('should load mock modules after navigating back and forward', function() {
65
80
browser.addMockModule('moduleA', mockModuleA);
66
81
67
- browser.get('index.html');
68
- expect(element(by.css('[app-version]')).getText()).toEqual('2');
82
+ browser.get('index.html');
83
+ expect(element(by.css('[app-version]')).getText()).toEqual('2');
69
84
70
85
browser.get('index.html#/repeater');
71
86
expect(element(by.css('[app-version]')).getText()).toEqual('2');
@@ -81,8 +96,8 @@ describe('mock modules', function() {
81
96
it ( 'should load mock modules after navigating back and forward from link' , function ( ) {
82
97
browser . addMockModule ( 'moduleA' , mockModuleA ) ;
83
98
84
- browser . get ( 'index.html' ) ;
85
- expect ( element ( by . css ( '[app-version]' ) ) . getText ( ) ) . toEqual ( '2' ) ;
99
+ browser . get ( 'index.html' ) ;
100
+ expect ( element ( by . css ( '[app-version]' ) ) . getText ( ) ) . toEqual ( '2' ) ;
86
101
87
102
element ( by . linkText ( 'repeater' ) ) . click ( ) ;
88
103
expect ( element ( by . css ( '[app-version]' ) ) . getText ( ) ) . toEqual ( '2' ) ;
@@ -92,6 +107,6 @@ describe('mock modules', function() {
92
107
93
108
browser . navigate ( ) . forward ( ) ;
94
109
expect ( element ( by . css ( '[app-version]' ) ) . getText ( ) ) . toEqual ( '2' ) ;
95
- } ) ;
110
+ } ) ;
96
111
97
112
} ) ;
0 commit comments