mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-03-18 15:50:22 +00:00
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.
This commit is contained in:
parent
8248e77a7b
commit
87f9a4c566
1 changed files with 40 additions and 4 deletions
44
test/angular-mocks.js
vendored
44
test/angular-mocks.js
vendored
|
|
@ -22,6 +22,40 @@
|
|||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
|
||||
NUGGGGGH MUST TONGUE WANGS
|
||||
\
|
||||
.....
|
||||
C C /
|
||||
/< /
|
||||
___ __________/_#__=o
|
||||
/(- /(\_\________ \
|
||||
\ ) \ )_ \o \
|
||||
/|\ /|\ |' |
|
||||
| _|
|
||||
/o __\
|
||||
/ ' |
|
||||
/ / |
|
||||
/_/\______|
|
||||
( _( <
|
||||
\ \ \
|
||||
\ \ |
|
||||
\____\____\
|
||||
____\_\__\_\
|
||||
/` /` o\
|
||||
|___ |_______|.. . b'ger
|
||||
|
||||
|
||||
IN THE FINAL BUILD THIS FILE DOESN'T HAVE DIRECT ACCESS TO GLOBAL FUNCTIONS
|
||||
DEFINED IN Angular.js YOU *MUST* REFER TO THEM VIA angular OBJECT
|
||||
(e.g. angular.forEach(...)) AND MAKE SURE THAT THE GIVEN FUNCTION IS EXPORTED
|
||||
TO THE angular NAMESPACE in AngularPublic.js
|
||||
|
||||
*/
|
||||
|
||||
|
||||
function MockBrowser() {
|
||||
var self = this,
|
||||
expectations = {},
|
||||
|
|
@ -80,7 +114,9 @@ function MockBrowser() {
|
|||
MockBrowser.prototype = {
|
||||
|
||||
poll: function poll(){
|
||||
foreach(this.pollFns, function(pollFn){ pollFn(); });
|
||||
angular.foreach(this.pollFns, function(pollFn){
|
||||
pollFn();
|
||||
});
|
||||
},
|
||||
|
||||
addPollFn: function(pollFn) {
|
||||
|
|
@ -104,13 +140,13 @@ MockBrowser.prototype = {
|
|||
if (value == undefined) {
|
||||
delete this.cookieHash[name];
|
||||
} else {
|
||||
if (isString(value) && //strings only
|
||||
value.length <= 4096) { //strict cookie storage limits
|
||||
if (angular.isString(value) && //strings only
|
||||
value.length <= 4096) { //strict cookie storage limits
|
||||
this.cookieHash[name] = value;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (!equals(this.cookieHash, this.lastCookieHash)) {
|
||||
if (!angular.equals(this.cookieHash, this.lastCookieHash)) {
|
||||
this.lastCookieHash = copy(this.cookieHash);
|
||||
this.cookieHash = copy(this.cookieHash);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue