Skip to content

Commit 87f9a4c

Browse files
committed
angular-mocks code should access all global functions via angular
mocks must use angular.foo because the final build will hide all the normally accessible functions within an anonymous closure.
1 parent 8248e77 commit 87f9a4c

1 file changed

Lines changed: 40 additions & 4 deletions

File tree

test/angular-mocks.js

Lines changed: 40 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,40 @@
2222
* THE SOFTWARE.
2323
*/
2424

25+
26+
/*
27+
28+
NUGGGGGH MUST TONGUE WANGS
29+
\
30+
.....
31+
C C /
32+
/< /
33+
___ __________/_#__=o
34+
/(- /(\_\________ \
35+
\ ) \ )_ \o \
36+
/|\ /|\ |' |
37+
| _|
38+
/o __\
39+
/ ' |
40+
/ / |
41+
/_/\______|
42+
( _( <
43+
\ \ \
44+
\ \ |
45+
\____\____\
46+
____\_\__\_\
47+
/` /` o\
48+
|___ |_______|.. . b'ger
49+
50+
51+
IN THE FINAL BUILD THIS FILE DOESN'T HAVE DIRECT ACCESS TO GLOBAL FUNCTIONS
52+
DEFINED IN Angular.js YOU *MUST* REFER TO THEM VIA angular OBJECT
53+
(e.g. angular.forEach(...)) AND MAKE SURE THAT THE GIVEN FUNCTION IS EXPORTED
54+
TO THE angular NAMESPACE in AngularPublic.js
55+
56+
*/
57+
58+
2559
function MockBrowser() {
2660
var self = this,
2761
expectations = {},
@@ -80,7 +114,9 @@ function MockBrowser() {
80114
MockBrowser.prototype = {
81115

82116
poll: function poll(){
83-
foreach(this.pollFns, function(pollFn){ pollFn(); });
117+
angular.foreach(this.pollFns, function(pollFn){
118+
pollFn();
119+
});
84120
},
85121

86122
addPollFn: function(pollFn) {
@@ -104,13 +140,13 @@ MockBrowser.prototype = {
104140
if (value == undefined) {
105141
delete this.cookieHash[name];
106142
} else {
107-
if (isString(value) && //strings only
108-
value.length <= 4096) { //strict cookie storage limits
143+
if (angular.isString(value) && //strings only
144+
value.length <= 4096) { //strict cookie storage limits
109145
this.cookieHash[name] = value;
110146
}
111147
}
112148
} else {
113-
if (!equals(this.cookieHash, this.lastCookieHash)) {
149+
if (!angular.equals(this.cookieHash, this.lastCookieHash)) {
114150
this.lastCookieHash = copy(this.cookieHash);
115151
this.cookieHash = copy(this.cookieHash);
116152
}

0 commit comments

Comments
 (0)