@@ -107,6 +107,9 @@ module.exports = function(grunt) {
|
||||
options: {
|
||||
jshintrc: true,
|
||||
},
|
||||
tests: {
|
||||
files: { src: 'test/**/*.js' },
|
||||
},
|
||||
ng: {
|
||||
files: { src: files['angularSrc'] },
|
||||
},
|
||||
|
||||
+22
-23
@@ -16,6 +16,7 @@
|
||||
"sub": true,
|
||||
"undef": true,
|
||||
"browser": true,
|
||||
"indent": 2,
|
||||
"globals": {
|
||||
/* auto/injector.js */
|
||||
"createInjector": false,
|
||||
@@ -42,7 +43,6 @@
|
||||
"isArrayLike": false,
|
||||
"forEach": false,
|
||||
"sortedKeys": false,
|
||||
"forEachSorted": false,
|
||||
"reverseParams": false,
|
||||
"nextUid": false,
|
||||
"setHashKey": false,
|
||||
@@ -103,9 +103,6 @@
|
||||
"getBlockElements": false,
|
||||
"VALIDITY_STATE_PROPERTY": true,
|
||||
|
||||
/* filters.js */
|
||||
"getFirstThursdayOfYear": false,
|
||||
|
||||
/* AngularPublic.js */
|
||||
"version": false,
|
||||
"publishExternalAPI": false,
|
||||
@@ -148,24 +145,6 @@
|
||||
"urlResolve": false,
|
||||
"urlIsSameOrigin": false,
|
||||
|
||||
/* ng/compile.js */
|
||||
"directiveNormalize": false,
|
||||
|
||||
/* ng/parse.js */
|
||||
"setter": false,
|
||||
|
||||
/* ng/directive/directives.js */
|
||||
"ngDirective": false,
|
||||
|
||||
/* ng/directive/input.js */
|
||||
"VALID_CLASS": false,
|
||||
"INVALID_CLASS": false,
|
||||
"PRISTINE_CLASS": false,
|
||||
"DIRTY_CLASS": false,
|
||||
|
||||
/* ng/directive/form.js */
|
||||
"nullFormCtrl": false,
|
||||
|
||||
/* jasmine / karma */
|
||||
"it": false,
|
||||
"iit": false,
|
||||
@@ -176,10 +155,30 @@
|
||||
"expect": false,
|
||||
"jasmine": false,
|
||||
"spyOn": false,
|
||||
"waits": false,
|
||||
"waitsFor": false,
|
||||
"runs": false,
|
||||
"dump": false,
|
||||
|
||||
/* e2e */
|
||||
"browser": false,
|
||||
"element": false,
|
||||
"by": false,
|
||||
|
||||
/* testabilityPatch / matchers */
|
||||
"inject": false,
|
||||
"module": false,
|
||||
"dealoc": false
|
||||
"dealoc": false,
|
||||
"dealoc": false,
|
||||
"_jQuery": false,
|
||||
"_jqLiteMode": false,
|
||||
"sortedHtml": false,
|
||||
"childrenTagsOf": false,
|
||||
"assertHidden": false,
|
||||
"assertVisible": false,
|
||||
"provideLog": false,
|
||||
"spyOnlyCallsWithArgs": false,
|
||||
"createMockStyleSheet": false,
|
||||
"browserTrigger": false
|
||||
}
|
||||
}
|
||||
|
||||
+26
-20
@@ -118,7 +118,7 @@ describe('angular', function() {
|
||||
|
||||
it('should throw an exception when source and destination are equivalent', function() {
|
||||
var src, dst;
|
||||
src = dst = {key: 'value'};
|
||||
src = dst = {key: 'value'};
|
||||
expect(function() { copy(src, dst); }).toThrowMinErr("ng", "cpi", "Can't copy! Source and destination are identical.");
|
||||
src = dst = [2, 4];
|
||||
expect(function() { copy(src, dst); }).toThrowMinErr("ng", "cpi", "Can't copy! Source and destination are identical.");
|
||||
@@ -223,7 +223,7 @@ describe('angular', function() {
|
||||
|
||||
it('should omit properties from prototype chain', function() {
|
||||
var original, clone = {};
|
||||
function Func() {};
|
||||
function Func() {}
|
||||
Func.prototype.hello = "world";
|
||||
|
||||
original = new Func();
|
||||
@@ -349,6 +349,7 @@ describe('angular', function() {
|
||||
});
|
||||
|
||||
it('should correctly test for keys that are present on Object.prototype', function() {
|
||||
/* jshint -W001 */
|
||||
// MS IE8 just doesn't work for this kind of thing, since "for ... in" doesn't return
|
||||
// things like hasOwnProperty even if it is explicitly defined on the actual object!
|
||||
if (msie<=8) return;
|
||||
@@ -497,7 +498,7 @@ describe('angular', function() {
|
||||
expect(toKeyValue({key: [323,'value',true]})).toEqual('key=323&key=value&key');
|
||||
expect(toKeyValue({key: [323,'value',true, 1234]})).
|
||||
toEqual('key=323&key=value&key&key=1234');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -512,13 +513,14 @@ describe('angular', function() {
|
||||
var obj = new MyObj(),
|
||||
log = [];
|
||||
|
||||
forEach(obj, function(value, key) { log.push(key + ':' + value)});
|
||||
forEach(obj, function(value, key) { log.push(key + ':' + value); });
|
||||
|
||||
expect(log).toEqual(['bar:barVal', 'baz:bazVal']);
|
||||
});
|
||||
|
||||
|
||||
it('should not break if obj is an array we override hasOwnProperty', function() {
|
||||
/* jshint -W001 */
|
||||
var obj = [];
|
||||
obj[0] = 1;
|
||||
obj[1] = 2;
|
||||
@@ -546,7 +548,7 @@ describe('angular', function() {
|
||||
log = [];
|
||||
|
||||
|
||||
forEach(nodeList, function(value, key) { log.push(key + ':' + value.innerHTML)});
|
||||
forEach(nodeList, function(value, key) { log.push(key + ':' + value.innerHTML); });
|
||||
expect(log).toEqual(['0:a', '1:b', '2:c']);
|
||||
});
|
||||
|
||||
@@ -561,7 +563,7 @@ describe('angular', function() {
|
||||
var htmlCollection = document.getElementsByName('x'),
|
||||
log = [];
|
||||
|
||||
forEach(htmlCollection, function(value, key) { log.push(key + ':' + value.innerHTML)});
|
||||
forEach(htmlCollection, function(value, key) { log.push(key + ':' + value.innerHTML); });
|
||||
expect(log).toEqual(['0:a', '1:c']);
|
||||
});
|
||||
|
||||
@@ -576,7 +578,7 @@ describe('angular', function() {
|
||||
var htmlCollection = document.querySelectorAll('[name="x"]'),
|
||||
log = [];
|
||||
|
||||
forEach(htmlCollection, function(value, key) { log.push(key + ':' + value.innerHTML)});
|
||||
forEach(htmlCollection, function(value, key) { log.push(key + ':' + value.innerHTML); });
|
||||
expect(log).toEqual(['0:a', '1:c']);
|
||||
});
|
||||
}
|
||||
@@ -585,28 +587,28 @@ describe('angular', function() {
|
||||
var args,
|
||||
log = [];
|
||||
|
||||
(function(){ args = arguments}('a', 'b', 'c'));
|
||||
(function(){ args = arguments; }('a', 'b', 'c'));
|
||||
|
||||
forEach(args, function(value, key) { log.push(key + ':' + value)});
|
||||
forEach(args, function(value, key) { log.push(key + ':' + value); });
|
||||
expect(log).toEqual(['0:a', '1:b', '2:c']);
|
||||
});
|
||||
|
||||
it('should handle string values like arrays', function() {
|
||||
var log = [];
|
||||
|
||||
forEach('bar', function(value, key) { log.push(key + ':' + value)});
|
||||
forEach('bar', function(value, key) { log.push(key + ':' + value); });
|
||||
expect(log).toEqual(['0:b', '1:a', '2:r']);
|
||||
});
|
||||
|
||||
|
||||
it('should handle objects with length property as objects', function() {
|
||||
var obj = {
|
||||
'foo' : 'bar',
|
||||
'length': 2
|
||||
},
|
||||
log = [];
|
||||
'foo' : 'bar',
|
||||
'length': 2
|
||||
},
|
||||
log = [];
|
||||
|
||||
forEach(obj, function(value, key) { log.push(key + ':' + value)});
|
||||
forEach(obj, function(value, key) { log.push(key + ':' + value); });
|
||||
expect(log).toEqual(['foo:bar', 'length:2']);
|
||||
});
|
||||
|
||||
@@ -614,13 +616,13 @@ describe('angular', function() {
|
||||
it('should handle objects of custom types with length property as objects', function() {
|
||||
function CustomType() {
|
||||
this.length = 2;
|
||||
this.foo = 'bar'
|
||||
this.foo = 'bar';
|
||||
}
|
||||
|
||||
var obj = new CustomType(),
|
||||
log = [];
|
||||
|
||||
forEach(obj, function(value, key) { log.push(key + ':' + value)});
|
||||
forEach(obj, function(value, key) { log.push(key + ':' + value); });
|
||||
expect(log).toEqual(['length:2', 'foo:bar']);
|
||||
});
|
||||
});
|
||||
@@ -790,7 +792,9 @@ describe('angular', function() {
|
||||
expect(function() {
|
||||
angularInit(appElement, bootstrap);
|
||||
}).toThrowMatching(
|
||||
/\[\$injector:modulerr] Failed to instantiate module doesntexist due to:\n.*\[\$injector:nomod] Module 'doesntexist' is not available! You either misspelled the module name or forgot to load it\./
|
||||
new RegExp('\\[\\$injector:modulerr] Failed to instantiate module doesntexist due to:\\n' +
|
||||
'.*\\[\\$injector:nomod] Module \'doesntexist\' is not available! You either ' +
|
||||
'misspelled the module name or forgot to load it\\.')
|
||||
);
|
||||
});
|
||||
|
||||
@@ -818,7 +822,7 @@ describe('angular', function() {
|
||||
);
|
||||
|
||||
dealoc(document);
|
||||
})
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -979,7 +983,9 @@ describe('angular', function() {
|
||||
expect(function() {
|
||||
angular.bootstrap(element, ['doesntexist']);
|
||||
}).toThrowMatching(
|
||||
/\[\$injector:modulerr\] Failed to instantiate module doesntexist due to:\n.*\[\$injector:nomod\] Module 'doesntexist' is not available! You either misspelled the module name or forgot to load it\./);
|
||||
new RegExp('\\[\\$injector:modulerr\\] Failed to instantiate module doesntexist due to:\\n' +
|
||||
'.*\\[\\$injector:nomod\\] Module \'doesntexist\' is not available! You either ' +
|
||||
'misspelled the module name or forgot to load it\\.'));
|
||||
|
||||
expect(element.html()).toBe('{{1+2}}');
|
||||
dealoc(element);
|
||||
|
||||
+1
-1
@@ -176,7 +176,7 @@ describe('Binder', function() {
|
||||
var errorLogs = $exceptionHandler.errors;
|
||||
|
||||
$rootScope.error = {
|
||||
'throw': function() {throw 'ErrorMsg1';}
|
||||
'throw': function() {throw 'ErrorMsg1';}
|
||||
};
|
||||
$rootScope.$apply();
|
||||
|
||||
|
||||
+32
-29
@@ -110,6 +110,7 @@ describe('injector', function() {
|
||||
|
||||
|
||||
function fn(a, b, c, d) {
|
||||
/* jshint -W040 */
|
||||
args = [this, a, b, c, d];
|
||||
return a + b + c + d;
|
||||
}
|
||||
@@ -147,6 +148,7 @@ describe('injector', function() {
|
||||
|
||||
|
||||
describe('annotation', function() {
|
||||
/* global annotate: false */
|
||||
it('should return $inject', function() {
|
||||
function fn() {}
|
||||
fn.$inject = ['a'];
|
||||
@@ -159,6 +161,7 @@ describe('injector', function() {
|
||||
|
||||
|
||||
it('should create $inject', function() {
|
||||
var extraParans = angular.noop;
|
||||
// keep the multi-line to make sure we can handle it
|
||||
function $f_n0 /*
|
||||
*/(
|
||||
@@ -175,7 +178,7 @@ describe('injector', function() {
|
||||
|
||||
|
||||
it('should strip leading and trailing underscores from arg name during inference', function() {
|
||||
function beforeEachFn(_foo_) { /* foo = _foo_ */ };
|
||||
function beforeEachFn(_foo_) { /* foo = _foo_ */ }
|
||||
expect(annotate(beforeEachFn)).toEqual(['foo']);
|
||||
});
|
||||
|
||||
@@ -239,10 +242,9 @@ describe('injector', function() {
|
||||
|
||||
describe('module', function() {
|
||||
it('should provide $injector even when no module is requested', function() {
|
||||
var $provide,
|
||||
$injector = createInjector([
|
||||
angular.extend(function(p) { $provide = p; }, {$inject: ['$provide']})
|
||||
]);
|
||||
var $provide, $injector = createInjector([
|
||||
angular.extend(function(p) { $provide = p; }, {$inject: ['$provide']})
|
||||
]);
|
||||
expect($injector.get('$injector')).toBe($injector);
|
||||
});
|
||||
|
||||
@@ -321,9 +323,9 @@ describe('injector', function() {
|
||||
angular.module('a', [], function(){ log += 'a'; }).run(function() { log += 'A'; });
|
||||
angular.module('b', ['a'], function(){ log += 'b'; }).run(function() { log += 'B'; });
|
||||
createInjector([
|
||||
'b',
|
||||
valueFn(function() { log += 'C'; }),
|
||||
[valueFn(function() { log += 'D'; })]
|
||||
'b',
|
||||
valueFn(function() { log += 'C'; }),
|
||||
[valueFn(function() { log += 'D'; })]
|
||||
]);
|
||||
expect(log).toEqual('abABCD');
|
||||
});
|
||||
@@ -351,19 +353,19 @@ describe('injector', function() {
|
||||
it('should create configuration injectable constants', function() {
|
||||
var log = [];
|
||||
createInjector([
|
||||
function($provide){
|
||||
$provide.constant('abc', 123);
|
||||
$provide.constant({a: 'A', b:'B'});
|
||||
return function(a) {
|
||||
log.push(a);
|
||||
}
|
||||
},
|
||||
function(abc) {
|
||||
log.push(abc);
|
||||
return function(b) {
|
||||
log.push(b);
|
||||
}
|
||||
}
|
||||
function($provide){
|
||||
$provide.constant('abc', 123);
|
||||
$provide.constant({a: 'A', b:'B'});
|
||||
return function(a) {
|
||||
log.push(a);
|
||||
};
|
||||
},
|
||||
function(abc) {
|
||||
log.push(abc);
|
||||
return function(b) {
|
||||
log.push(b);
|
||||
};
|
||||
}
|
||||
]).get('abc');
|
||||
expect(log).toEqual([123, 'A', 'B']);
|
||||
});
|
||||
@@ -445,7 +447,7 @@ describe('injector', function() {
|
||||
|
||||
|
||||
it('should configure $provide provider type', function() {
|
||||
function Type() {};
|
||||
function Type() {}
|
||||
Type.prototype.$get = function() {
|
||||
expect(this instanceof Type).toBe(true);
|
||||
return 'abc';
|
||||
@@ -459,7 +461,7 @@ describe('injector', function() {
|
||||
it('should configure $provide using an array', function() {
|
||||
function Type(PREFIX) {
|
||||
this.prefix = PREFIX;
|
||||
};
|
||||
}
|
||||
Type.prototype.$get = function() {
|
||||
return this.prefix + 'def';
|
||||
};
|
||||
@@ -550,7 +552,7 @@ describe('injector', function() {
|
||||
return function(val) {
|
||||
log.push('myService:' + val + ',' + dep1);
|
||||
return 'origReturn';
|
||||
}
|
||||
};
|
||||
}]);
|
||||
|
||||
$provide.decorator('myService', function($delegate) {
|
||||
@@ -577,7 +579,7 @@ describe('injector', function() {
|
||||
return function(val) {
|
||||
log.push('myService:' + val);
|
||||
return 'origReturn';
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
$provide.decorator('myService', function($delegate, dep1) {
|
||||
@@ -727,7 +729,8 @@ describe('injector', function() {
|
||||
})).toEqual('melville:moby');
|
||||
expect($injector.invoke(function(book, author) {
|
||||
expect(this).toEqual($injector);
|
||||
return author + ':' + book;}, $injector)).toEqual('melville:moby');
|
||||
return author + ':' + book;
|
||||
}, $injector)).toEqual('melville:moby');
|
||||
});
|
||||
|
||||
|
||||
@@ -745,7 +748,7 @@ describe('injector', function() {
|
||||
|
||||
it('should invoke method which is annotated', function() {
|
||||
expect($injector.invoke(extend(function(b, a) {
|
||||
return a + ':' + b
|
||||
return a + ':' + b;
|
||||
}, {$inject:['book', 'author']}))).toEqual('melville:moby');
|
||||
expect($injector.invoke(extend(function(b, a) {
|
||||
expect(this).toEqual($injector);
|
||||
@@ -878,10 +881,10 @@ describe('injector', function() {
|
||||
|
||||
|
||||
it('should prevent instance lookup in module', function() {
|
||||
function instanceLookupInModule(name) { throw Error('FAIL'); }
|
||||
function instanceLookupInModule(name) { throw new Error('FAIL'); }
|
||||
expect(function() {
|
||||
createInjector([function($provide) {
|
||||
$provide.value('name', 'angular')
|
||||
$provide.value('name', 'angular');
|
||||
}, instanceLookupInModule]);
|
||||
}).toThrowMatching(/\[\$injector:unpr] Unknown provider: name/);
|
||||
});
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
'use strict';
|
||||
|
||||
describe('docs.angularjs.org', function () {
|
||||
describe('App', function () {
|
||||
// it('should filter the module list when searching', function () {
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
'use strict';
|
||||
|
||||
beforeEach(function() {
|
||||
|
||||
function cssMatcher(presentClasses, absentClasses) {
|
||||
@@ -39,7 +41,7 @@ beforeEach(function() {
|
||||
}
|
||||
});
|
||||
return hidden;
|
||||
};
|
||||
}
|
||||
|
||||
this.addMatchers({
|
||||
toBeInvalid: cssMatcher('ng-invalid', 'ng-valid'),
|
||||
@@ -128,7 +130,7 @@ beforeEach(function() {
|
||||
|
||||
this.message = function() {
|
||||
if (this.actual.callCount != 1) {
|
||||
if (this.actual.callCount == 0) {
|
||||
if (this.actual.callCount === 0) {
|
||||
return [
|
||||
'Expected spy ' + this.actual.identity + ' to have been called once with ' +
|
||||
jasmine.pp(expectedArgs) + ' but it was never called.',
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
'use strict';
|
||||
|
||||
function createMockStyleSheet(doc, wind) {
|
||||
doc = doc ? doc[0] : document;
|
||||
wind = wind || window;
|
||||
@@ -17,7 +19,7 @@ function createMockStyleSheet(doc, wind) {
|
||||
try {
|
||||
ss.addRule(selector, styles);
|
||||
}
|
||||
catch(e) {}
|
||||
catch(e2) {}
|
||||
}
|
||||
},
|
||||
|
||||
@@ -25,4 +27,4 @@ function createMockStyleSheet(doc, wind) {
|
||||
head.removeChild(node);
|
||||
}
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
'use strict';
|
||||
|
||||
describe('private mocks', function() {
|
||||
describe('createMockStyleSheet', function() {
|
||||
|
||||
@@ -29,7 +31,7 @@ describe('private mocks', function() {
|
||||
return node.currentStyle ?
|
||||
node.currentStyle[key] :
|
||||
$window.getComputedStyle(node)[key];
|
||||
};
|
||||
}
|
||||
}));
|
||||
|
||||
});
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
/* global jQuery: true, uid: true */
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
@@ -150,7 +151,7 @@ function sortedHtml(element, showNgClass) {
|
||||
|
||||
var attr = attributes[i];
|
||||
if(attr.name.match(/^ng[\:\-]/) ||
|
||||
(attr.value || attr.value == '') &&
|
||||
(attr.value || attr.value === '') &&
|
||||
attr.value !='null' &&
|
||||
attr.value !='auto' &&
|
||||
attr.value !='false' &&
|
||||
@@ -283,7 +284,7 @@ function provideLog($provide) {
|
||||
var currentMessages = messages;
|
||||
messages = [];
|
||||
return currentMessages;
|
||||
}
|
||||
};
|
||||
|
||||
log.fn = function(msg) {
|
||||
return function() {
|
||||
@@ -299,7 +300,7 @@ function provideLog($provide) {
|
||||
|
||||
function pending() {
|
||||
dump('PENDING');
|
||||
};
|
||||
}
|
||||
|
||||
function trace(name) {
|
||||
dump(new Error(name).stack);
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
/* global $: false */
|
||||
'use strict';
|
||||
|
||||
if (window.jQuery) {
|
||||
|
||||
+41
-38
@@ -1,3 +1,5 @@
|
||||
'use strict';
|
||||
|
||||
describe('jqLite', function() {
|
||||
var scope, a, b, c;
|
||||
|
||||
@@ -57,7 +59,7 @@ describe('jqLite', function() {
|
||||
it('should allow construction with html', function() {
|
||||
var nodes = jqLite('<div>1</div><span>2</span>');
|
||||
expect(nodes[0].parentNode).toBeDefined();
|
||||
expect(nodes[0].parentNode.nodeType).toBe(11); /** Document Fragment **/;
|
||||
expect(nodes[0].parentNode.nodeType).toBe(11); /** Document Fragment **/
|
||||
expect(nodes[0].parentNode).toBe(nodes[1].parentNode);
|
||||
expect(nodes.length).toEqual(2);
|
||||
expect(nodes[0].innerHTML).toEqual('1');
|
||||
@@ -68,7 +70,7 @@ describe('jqLite', function() {
|
||||
it('should allow construction of html with leading whitespace', function() {
|
||||
var nodes = jqLite(' \n\r \r\n<div>1</div><span>2</span>');
|
||||
expect(nodes[0].parentNode).toBeDefined();
|
||||
expect(nodes[0].parentNode.nodeType).toBe(11); /** Document Fragment **/;
|
||||
expect(nodes[0].parentNode.nodeType).toBe(11); /** Document Fragment **/
|
||||
expect(nodes[0].parentNode).toBe(nodes[1].parentNode);
|
||||
expect(nodes.length).toBe(2);
|
||||
expect(nodes[0].innerHTML).toBe('1');
|
||||
@@ -473,7 +475,7 @@ describe('jqLite', function() {
|
||||
span = div.find('span'),
|
||||
log = '';
|
||||
|
||||
span.on('click', function() { log+= 'click;'});
|
||||
span.on('click', function() { log+= 'click;'; });
|
||||
browserTrigger(span);
|
||||
expect(log).toEqual('click;');
|
||||
|
||||
@@ -945,21 +947,21 @@ describe('jqLite', function() {
|
||||
if (jqLite.fn) return; // don't run in jQuery
|
||||
var eventFn;
|
||||
var window = {
|
||||
document: {},
|
||||
location: {},
|
||||
alert: noop,
|
||||
setInterval: noop,
|
||||
length:10, // pretend you are an array
|
||||
addEventListener: function(type, fn){
|
||||
expect(type).toEqual('hashchange');
|
||||
eventFn = fn;
|
||||
},
|
||||
removeEventListener: noop,
|
||||
attachEvent: function(type, fn){
|
||||
expect(type).toEqual('onhashchange');
|
||||
eventFn = fn;
|
||||
},
|
||||
detachEvent: noop
|
||||
document: {},
|
||||
location: {},
|
||||
alert: noop,
|
||||
setInterval: noop,
|
||||
length:10, // pretend you are an array
|
||||
addEventListener: function(type, fn){
|
||||
expect(type).toEqual('hashchange');
|
||||
eventFn = fn;
|
||||
},
|
||||
removeEventListener: noop,
|
||||
attachEvent: function(type, fn){
|
||||
expect(type).toEqual('onhashchange');
|
||||
eventFn = fn;
|
||||
},
|
||||
detachEvent: noop
|
||||
};
|
||||
var log;
|
||||
var jWindow = jqLite(window).on('hashchange', function() {
|
||||
@@ -1046,16 +1048,17 @@ describe('jqLite', function() {
|
||||
if (window.jQuery) return;
|
||||
var browserMoveTrigger = function(from, to){
|
||||
var fireEvent = function(type, element, relatedTarget){
|
||||
var msie = parseInt((/msie (\d+)/.exec(navigator.userAgent.toLowerCase()) || [])[1]);
|
||||
var evnt, msie = parseInt((/msie (\d+)/.exec(navigator.userAgent.toLowerCase()) || [])[1]);
|
||||
if (msie < 9){
|
||||
var evnt = document.createEventObject();
|
||||
evnt = document.createEventObject();
|
||||
evnt.srcElement = element;
|
||||
evnt.relatedTarget = relatedTarget;
|
||||
element.fireEvent('on' + type, evnt);
|
||||
return;
|
||||
};
|
||||
var evnt = document.createEvent('MouseEvents'),
|
||||
originalPreventDefault = evnt.preventDefault,
|
||||
}
|
||||
evnt = document.createEvent('MouseEvents');
|
||||
|
||||
var originalPreventDefault = evnt.preventDefault,
|
||||
appWindow = window,
|
||||
fakeProcessDefault = true,
|
||||
finalProcessDefault;
|
||||
@@ -1657,25 +1660,25 @@ describe('jqLite', function() {
|
||||
|
||||
describe('camelCase', function() {
|
||||
|
||||
it('should leave non-dashed strings alone', function() {
|
||||
expect(camelCase('foo')).toBe('foo');
|
||||
expect(camelCase('')).toBe('');
|
||||
expect(camelCase('fooBar')).toBe('fooBar');
|
||||
});
|
||||
it('should leave non-dashed strings alone', function() {
|
||||
expect(camelCase('foo')).toBe('foo');
|
||||
expect(camelCase('')).toBe('');
|
||||
expect(camelCase('fooBar')).toBe('fooBar');
|
||||
});
|
||||
|
||||
|
||||
it('should covert dash-separated strings to camelCase', function() {
|
||||
expect(camelCase('foo-bar')).toBe('fooBar');
|
||||
expect(camelCase('foo-bar-baz')).toBe('fooBarBaz');
|
||||
expect(camelCase('foo:bar_baz')).toBe('fooBarBaz');
|
||||
});
|
||||
it('should covert dash-separated strings to camelCase', function() {
|
||||
expect(camelCase('foo-bar')).toBe('fooBar');
|
||||
expect(camelCase('foo-bar-baz')).toBe('fooBarBaz');
|
||||
expect(camelCase('foo:bar_baz')).toBe('fooBarBaz');
|
||||
});
|
||||
|
||||
|
||||
it('should covert browser specific css properties', function() {
|
||||
expect(camelCase('-moz-foo-bar')).toBe('MozFooBar');
|
||||
expect(camelCase('-webkit-foo-bar')).toBe('webkitFooBar');
|
||||
expect(camelCase('-webkit-foo-bar')).toBe('webkitFooBar');
|
||||
});
|
||||
it('should covert browser specific css properties', function() {
|
||||
expect(camelCase('-moz-foo-bar')).toBe('MozFooBar');
|
||||
expect(camelCase('-webkit-foo-bar')).toBe('webkitFooBar');
|
||||
expect(camelCase('-webkit-foo-bar')).toBe('webkitFooBar');
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
Vendored
+1
@@ -1,3 +1,4 @@
|
||||
/* global _jQuery: true, _jqLiteMode: true */
|
||||
'use strict';
|
||||
|
||||
var _jQuery = jQuery,
|
||||
|
||||
Vendored
+1
@@ -1,3 +1,4 @@
|
||||
/* global _jQuery: true, _jqLiteMode: true */
|
||||
'use strict';
|
||||
|
||||
var _jQuery = jQuery.noConflict(true),
|
||||
|
||||
+1
-1
@@ -81,5 +81,5 @@ describe('module loader', function() {
|
||||
|
||||
it('should expose `$$minErr` on the `angular` object', function() {
|
||||
expect(window.angular.$$minErr).toEqual(jasmine.any(Function));
|
||||
})
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
'use strict';
|
||||
|
||||
describe('$anchorScroll', function() {
|
||||
|
||||
var elmSpy;
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
'use strict';
|
||||
|
||||
describe("$animate", function() {
|
||||
|
||||
describe("without animation", function() {
|
||||
var element, $rootElement;
|
||||
|
||||
beforeEach(module(function() {
|
||||
return function($compile, _$rootElement_, $rootScope) {
|
||||
element = $compile('<div></div>')($rootScope);
|
||||
|
||||
@@ -49,7 +49,7 @@ function MockWindow() {
|
||||
function MockDocument() {
|
||||
var self = this;
|
||||
|
||||
this[0] = window.document
|
||||
this[0] = window.document;
|
||||
this.basePath = '/';
|
||||
|
||||
this.find = function(name) {
|
||||
@@ -62,15 +62,15 @@ function MockDocument() {
|
||||
throw new Error(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
} else {
|
||||
throw new Error(name);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
describe('browser', function() {
|
||||
|
||||
/* global Browser: false */
|
||||
var browser, fakeWindow, fakeDocument, logs, scripts, removedScripts, sniffer;
|
||||
|
||||
beforeEach(function() {
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
'use strict';
|
||||
|
||||
describe('$cacheFactory', function() {
|
||||
|
||||
it('should be injected', inject(function($cacheFactory) {
|
||||
@@ -176,7 +178,7 @@ describe('$cacheFactory', function() {
|
||||
describe('LRU cache', function() {
|
||||
|
||||
it('should create cache with defined capacity', inject(function($cacheFactory) {
|
||||
cache = $cacheFactory('cache1', {capacity: 5});
|
||||
var cache = $cacheFactory('cache1', {capacity: 5});
|
||||
expect(cache.info().size).toBe(0);
|
||||
|
||||
for (var i=0; i<5; i++) {
|
||||
@@ -193,6 +195,7 @@ describe('$cacheFactory', function() {
|
||||
|
||||
|
||||
describe('eviction', function() {
|
||||
var cache;
|
||||
|
||||
beforeEach(inject(function($cacheFactory) {
|
||||
cache = $cacheFactory('cache1', {capacity: 2});
|
||||
|
||||
+129
-109
@@ -82,13 +82,13 @@ describe('$compile', function() {
|
||||
element.text('SUCCESS');
|
||||
}
|
||||
};
|
||||
})
|
||||
});
|
||||
});
|
||||
inject(function($compile, $rootScope, log) {
|
||||
element = $compile('<div></div>')($rootScope);
|
||||
expect(element.text()).toEqual('SUCCESS');
|
||||
expect(log).toEqual('OK');
|
||||
})
|
||||
});
|
||||
});
|
||||
|
||||
it('should allow registration of multiple directives with same name', function() {
|
||||
@@ -282,7 +282,7 @@ describe('$compile', function() {
|
||||
expect(attr).toBe(templateAttr);
|
||||
expect(scope).toEqual($rootScope);
|
||||
element.text('worked');
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
});
|
||||
@@ -397,7 +397,7 @@ describe('$compile', function() {
|
||||
expect(element.children().length).toBe(1);
|
||||
expect(element.text()).toBe('Hello');
|
||||
});
|
||||
})
|
||||
});
|
||||
});
|
||||
|
||||
describe('compiler control', function() {
|
||||
@@ -436,46 +436,46 @@ describe('$compile', function() {
|
||||
describe('restrict', function() {
|
||||
|
||||
it('should allow restriction of attributes', function() {
|
||||
module(function() {
|
||||
forEach({div:'E', attr:'A', clazz:'C', all:'EAC'}, function(restrict, name) {
|
||||
directive(name, function(log) {
|
||||
return {
|
||||
restrict: restrict,
|
||||
compile: valueFn(function(scope, element, attr) {
|
||||
log(name);
|
||||
})
|
||||
};
|
||||
});
|
||||
module(function() {
|
||||
forEach({div:'E', attr:'A', clazz:'C', all:'EAC'}, function(restrict, name) {
|
||||
directive(name, function(log) {
|
||||
return {
|
||||
restrict: restrict,
|
||||
compile: valueFn(function(scope, element, attr) {
|
||||
log(name);
|
||||
})
|
||||
};
|
||||
});
|
||||
});
|
||||
inject(function($rootScope, $compile, log) {
|
||||
dealoc($compile('<span div class="div"></span>')($rootScope));
|
||||
expect(log).toEqual('');
|
||||
log.reset();
|
||||
});
|
||||
inject(function($rootScope, $compile, log) {
|
||||
dealoc($compile('<span div class="div"></span>')($rootScope));
|
||||
expect(log).toEqual('');
|
||||
log.reset();
|
||||
|
||||
dealoc($compile('<div></div>')($rootScope));
|
||||
expect(log).toEqual('div');
|
||||
log.reset();
|
||||
dealoc($compile('<div></div>')($rootScope));
|
||||
expect(log).toEqual('div');
|
||||
log.reset();
|
||||
|
||||
dealoc($compile('<attr class=""attr"></attr>')($rootScope));
|
||||
expect(log).toEqual('');
|
||||
log.reset();
|
||||
dealoc($compile('<attr class=""attr"></attr>')($rootScope));
|
||||
expect(log).toEqual('');
|
||||
log.reset();
|
||||
|
||||
dealoc($compile('<span attr></span>')($rootScope));
|
||||
expect(log).toEqual('attr');
|
||||
log.reset();
|
||||
dealoc($compile('<span attr></span>')($rootScope));
|
||||
expect(log).toEqual('attr');
|
||||
log.reset();
|
||||
|
||||
dealoc($compile('<clazz clazz></clazz>')($rootScope));
|
||||
expect(log).toEqual('');
|
||||
log.reset();
|
||||
dealoc($compile('<clazz clazz></clazz>')($rootScope));
|
||||
expect(log).toEqual('');
|
||||
log.reset();
|
||||
|
||||
dealoc($compile('<span class="clazz"></span>')($rootScope));
|
||||
expect(log).toEqual('clazz');
|
||||
log.reset();
|
||||
dealoc($compile('<span class="clazz"></span>')($rootScope));
|
||||
expect(log).toEqual('clazz');
|
||||
log.reset();
|
||||
|
||||
dealoc($compile('<all class="all" all></all>')($rootScope));
|
||||
expect(log).toEqual('all; all; all');
|
||||
});
|
||||
dealoc($compile('<all class="all" all></all>')($rootScope));
|
||||
expect(log).toEqual('all; all; all');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -658,7 +658,8 @@ describe('$compile', function() {
|
||||
element = $compile('<div replace-with-interpolated-style></div>')($rootScope);
|
||||
$rootScope.$digest();
|
||||
expect(element.css('width')).toBe('2px');
|
||||
}));
|
||||
}
|
||||
));
|
||||
}
|
||||
|
||||
it('should merge interpolated css class', inject(function($compile, $rootScope) {
|
||||
@@ -699,19 +700,19 @@ describe('$compile', function() {
|
||||
return {
|
||||
replace: true,
|
||||
template: 'dada'
|
||||
}
|
||||
};
|
||||
});
|
||||
directive('multiRootElem', function() {
|
||||
return {
|
||||
replace: true,
|
||||
template: '<div></div><div></div>'
|
||||
}
|
||||
};
|
||||
});
|
||||
directive('singleRootWithWhiteSpace', function() {
|
||||
return {
|
||||
replace: true,
|
||||
template: ' <div></div> \n'
|
||||
}
|
||||
};
|
||||
});
|
||||
});
|
||||
|
||||
@@ -820,32 +821,38 @@ describe('$compile', function() {
|
||||
beforeEach(module(
|
||||
function() {
|
||||
directive('hello', valueFn({
|
||||
restrict: 'CAM', templateUrl: 'hello.html', transclude: true
|
||||
restrict: 'CAM',
|
||||
templateUrl: 'hello.html',
|
||||
transclude: true
|
||||
}));
|
||||
directive('cau', valueFn({
|
||||
restrict: 'CAM', templateUrl: 'cau.html'
|
||||
restrict: 'CAM',
|
||||
templateUrl: 'cau.html'
|
||||
}));
|
||||
directive('crossDomainTemplate', valueFn({
|
||||
restrict: 'CAM', templateUrl: 'http://example.com/should-not-load.html'
|
||||
}));
|
||||
directive('trustedTemplate', function($sce) { return {
|
||||
restrict: 'CAM',
|
||||
templateUrl: function() {
|
||||
return $sce.trustAsResourceUrl('http://example.com/trusted-template.html');
|
||||
}};
|
||||
templateUrl: 'http://example.com/should-not-load.html'
|
||||
}));
|
||||
directive('trustedTemplate', function($sce) {
|
||||
return {
|
||||
restrict: 'CAM',
|
||||
templateUrl: function() {
|
||||
return $sce.trustAsResourceUrl('http://example.com/trusted-template.html');
|
||||
}
|
||||
};
|
||||
});
|
||||
directive('cError', valueFn({
|
||||
restrict: 'CAM',
|
||||
templateUrl:'error.html',
|
||||
compile: function() {
|
||||
throw Error('cError');
|
||||
throw new Error('cError');
|
||||
}
|
||||
}));
|
||||
directive('lError', valueFn({
|
||||
restrict: 'CAM',
|
||||
templateUrl: 'error.html',
|
||||
compile: function() {
|
||||
throw Error('lError');
|
||||
throw new Error('lError');
|
||||
}
|
||||
}));
|
||||
|
||||
@@ -866,7 +873,7 @@ describe('$compile', function() {
|
||||
replace: true,
|
||||
templateUrl:'error.html',
|
||||
compile: function() {
|
||||
throw Error('cError');
|
||||
throw new Error('cError');
|
||||
}
|
||||
}));
|
||||
directive('iLError', valueFn({
|
||||
@@ -874,7 +881,7 @@ describe('$compile', function() {
|
||||
replace: true,
|
||||
templateUrl: 'error.html',
|
||||
compile: function() {
|
||||
throw Error('lError');
|
||||
throw new Error('lError');
|
||||
}
|
||||
}));
|
||||
|
||||
@@ -919,23 +926,25 @@ describe('$compile', function() {
|
||||
));
|
||||
|
||||
it('should not load cross domain templates by default', inject(
|
||||
function($compile, $rootScope, $templateCache, $sce) {
|
||||
expect(function() {
|
||||
$templateCache.put('http://example.com/should-not-load.html', 'Should not load even if in cache.');
|
||||
$compile('<div class="crossDomainTemplate"></div>')($rootScope);
|
||||
}).toThrowMinErr('$sce', 'insecurl', 'Blocked loading resource from url not allowed by $sceDelegate policy. URL: http://example.com/should-not-load.html');
|
||||
}));
|
||||
function($compile, $rootScope, $templateCache, $sce) {
|
||||
expect(function() {
|
||||
$templateCache.put('http://example.com/should-not-load.html', 'Should not load even if in cache.');
|
||||
$compile('<div class="crossDomainTemplate"></div>')($rootScope);
|
||||
}).toThrowMinErr('$sce', 'insecurl', 'Blocked loading resource from url not allowed by $sceDelegate policy. URL: http://example.com/should-not-load.html');
|
||||
}
|
||||
));
|
||||
|
||||
it('should load cross domain templates when trusted', inject(
|
||||
function($compile, $httpBackend, $rootScope, $sce) {
|
||||
$httpBackend.expect('GET', 'http://example.com/trusted-template.html').respond('<span>example.com/trusted_template_contents</span>');
|
||||
element = $compile('<div class="trustedTemplate"></div>')($rootScope);
|
||||
expect(sortedHtml(element)).
|
||||
toEqual('<div class="trustedTemplate"></div>');
|
||||
$httpBackend.flush();
|
||||
expect(sortedHtml(element)).
|
||||
toEqual('<div class="trustedTemplate"><span>example.com/trusted_template_contents</span></div>');
|
||||
}));
|
||||
function($compile, $httpBackend, $rootScope, $sce) {
|
||||
$httpBackend.expect('GET', 'http://example.com/trusted-template.html').respond('<span>example.com/trusted_template_contents</span>');
|
||||
element = $compile('<div class="trustedTemplate"></div>')($rootScope);
|
||||
expect(sortedHtml(element)).
|
||||
toEqual('<div class="trustedTemplate"></div>');
|
||||
$httpBackend.flush();
|
||||
expect(sortedHtml(element)).
|
||||
toEqual('<div class="trustedTemplate"><span>example.com/trusted_template_contents</span></div>');
|
||||
}
|
||||
));
|
||||
|
||||
it('should append template via $http and cache it in $templateCache', inject(
|
||||
function($compile, $httpBackend, $templateCache, $rootScope, $browser) {
|
||||
@@ -1293,15 +1302,15 @@ describe('$compile', function() {
|
||||
function logDirective (name, priority, options) {
|
||||
directive(name, function(log) {
|
||||
return (extend({
|
||||
priority: priority,
|
||||
compile: function() {
|
||||
log(name + '-C');
|
||||
return {
|
||||
pre: function() { log(name + '-PreL'); },
|
||||
post: function() { log(name + '-PostL'); }
|
||||
}
|
||||
}
|
||||
}, options || {}));
|
||||
priority: priority,
|
||||
compile: function() {
|
||||
log(name + '-C');
|
||||
return {
|
||||
pre: function() { log(name + '-PreL'); },
|
||||
post: function() { log(name + '-PostL'); }
|
||||
};
|
||||
}
|
||||
}, options || {}));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1462,7 +1471,7 @@ describe('$compile', function() {
|
||||
return {
|
||||
replace: true,
|
||||
templateUrl: 'template.html'
|
||||
}
|
||||
};
|
||||
});
|
||||
});
|
||||
|
||||
@@ -2078,9 +2087,9 @@ describe('$compile', function() {
|
||||
post: function($scope, $element, $attrs) {
|
||||
log('postLink=' + $attrs.myName);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
};
|
||||
});
|
||||
});
|
||||
module(function() {
|
||||
@@ -2094,7 +2103,7 @@ describe('$compile', function() {
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
};
|
||||
});
|
||||
});
|
||||
inject(function($rootScope, $compile, log) {
|
||||
@@ -2191,7 +2200,7 @@ describe('$compile', function() {
|
||||
|
||||
|
||||
it('should translate {{}} in terminal nodes', inject(function($rootScope, $compile) {
|
||||
element = $compile('<select ng:model="x"><option value="">Greet {{name}}!</option></select>')($rootScope)
|
||||
element = $compile('<select ng:model="x"><option value="">Greet {{name}}!</option></select>')($rootScope);
|
||||
$rootScope.$digest();
|
||||
expect(sortedHtml(element).replace(' selected="true"', '')).
|
||||
toEqual('<select ng:model="x">' +
|
||||
@@ -2257,7 +2266,7 @@ describe('$compile', function() {
|
||||
log(val);
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
});
|
||||
});
|
||||
|
||||
@@ -2270,7 +2279,7 @@ describe('$compile', function() {
|
||||
|
||||
expect(log).toEqual(['carrot']);
|
||||
});
|
||||
})
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -2283,7 +2292,7 @@ describe('$compile', function() {
|
||||
return {
|
||||
restrict: 'ECA',
|
||||
compile: function() {
|
||||
log('t' + uppercase(name))
|
||||
log('t' + uppercase(name));
|
||||
return {
|
||||
pre: function() {
|
||||
log('pre' + uppercase(name));
|
||||
@@ -2424,7 +2433,7 @@ describe('$compile', function() {
|
||||
template: {element: templateElement, attr:templateAttr},
|
||||
link: {element: element, attr: attr}
|
||||
});
|
||||
}
|
||||
};
|
||||
}
|
||||
}),
|
||||
second: valueFn({
|
||||
@@ -2435,7 +2444,7 @@ describe('$compile', function() {
|
||||
template: {element: templateElement, attr:templateAttr},
|
||||
link: {element: element, attr: attr}
|
||||
});
|
||||
}
|
||||
};
|
||||
}
|
||||
})
|
||||
});
|
||||
@@ -2590,7 +2599,7 @@ describe('$compile', function() {
|
||||
link: function(scope) {
|
||||
regularScope = scope;
|
||||
}
|
||||
}
|
||||
};
|
||||
});
|
||||
}));
|
||||
|
||||
@@ -2602,7 +2611,7 @@ describe('$compile', function() {
|
||||
});
|
||||
expect(element.find('input').val()).toBe('from-parent');
|
||||
expect(componentScope).not.toBe(regularScope);
|
||||
expect(componentScope.$parent).toBe(regularScope)
|
||||
expect(componentScope.$parent).toBe(regularScope);
|
||||
}));
|
||||
|
||||
|
||||
@@ -2637,7 +2646,7 @@ describe('$compile', function() {
|
||||
});
|
||||
|
||||
inject(function($rootScope, $templateCache) {
|
||||
$templateCache.put('other.html', 'value: {{value}}')
|
||||
$templateCache.put('other.html', 'value: {{value}}');
|
||||
compile('<div my-component other-tpl-dir>');
|
||||
|
||||
$rootScope.$apply(function() {
|
||||
@@ -2716,14 +2725,14 @@ describe('$compile', function() {
|
||||
componentScope.ref = 'misko';
|
||||
|
||||
$rootScope.$apply();
|
||||
expect($rootScope.name).toEqual({mark:123})
|
||||
expect($rootScope.name).toEqual({mark:123});
|
||||
expect(componentScope.ref).toBe($rootScope.name);
|
||||
expect(componentScope.refAlias).toBe($rootScope.name);
|
||||
|
||||
$rootScope.name = 'igor';
|
||||
componentScope.ref = {};
|
||||
$rootScope.$apply();
|
||||
expect($rootScope.name).toEqual('igor')
|
||||
expect($rootScope.name).toEqual('igor');
|
||||
expect(componentScope.ref).toBe($rootScope.name);
|
||||
expect(componentScope.refAlias).toBe($rootScope.name);
|
||||
}));
|
||||
@@ -3142,7 +3151,7 @@ describe('$compile', function() {
|
||||
link: function($scope, $element) {
|
||||
log($element.attr('scope-tester') + '=' + ($scope.$root === $scope ? 'non-isolate' : 'isolate'));
|
||||
}
|
||||
}
|
||||
};
|
||||
});
|
||||
});
|
||||
|
||||
@@ -3156,7 +3165,7 @@ describe('$compile', function() {
|
||||
expect(log).toEqual('inside=isolate; ' +
|
||||
'outside replaced=non-isolate; ' + // outside
|
||||
'outside replaced=isolate; ' + // replaced
|
||||
'sibling=non-isolate')
|
||||
'sibling=non-isolate');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -3338,7 +3347,7 @@ describe('$compile', function() {
|
||||
controller: asyncCtrlSpy,
|
||||
compile: function() {
|
||||
return function() {
|
||||
}
|
||||
};
|
||||
}
|
||||
}));
|
||||
});
|
||||
@@ -3398,7 +3407,7 @@ describe('$compile', function() {
|
||||
element = $compile('<div parent-directive><div child-directive></div>childContentText;</div>')($rootScope);
|
||||
$rootScope.$apply();
|
||||
expect(log).toEqual('parentController; childController');
|
||||
expect(element.text()).toBe('childTemplateText;childContentText;')
|
||||
expect(element.text()).toBe('childTemplateText;childContentText;');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -3502,7 +3511,7 @@ describe('$compile', function() {
|
||||
'</div>')($rootScope);
|
||||
$rootScope.$apply();
|
||||
expect(log).toEqual('parentController; childController; babyController');
|
||||
expect(element.text()).toBe('childContentText;babyTemplateText;')
|
||||
expect(element.text()).toBe('childContentText;babyTemplateText;');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -3605,7 +3614,7 @@ describe('$compile', function() {
|
||||
replace: true,
|
||||
scope: true,
|
||||
template: '<ul><li>W:{{$parent.$id}}-{{$id}};</li><li ng-transclude></li></ul>'
|
||||
}
|
||||
};
|
||||
});
|
||||
});
|
||||
inject(function(log, $rootScope, $compile) {
|
||||
@@ -3637,7 +3646,7 @@ describe('$compile', function() {
|
||||
$httpBackend.
|
||||
expect('GET', 'chapter.html').
|
||||
respond('<div>chapter-<div section>[<div ng-transclude></div>]</div></div>');
|
||||
}
|
||||
};
|
||||
});
|
||||
inject(function(log, $rootScope, $compile, $httpBackend) {
|
||||
element = $compile('<div><div book>paragraph</div></div>')($rootScope);
|
||||
@@ -3755,9 +3764,9 @@ describe('$compile', function() {
|
||||
$compile('<div><div ng-transclude></div></div>')($rootScope);
|
||||
} catch(e) {
|
||||
expect(e.message).toMatch(new RegExp(
|
||||
'^\\\[ngTransclude:orphan\\\] ' +
|
||||
'^\\[ngTransclude:orphan\\] ' +
|
||||
'Illegal use of ngTransclude directive in the template! ' +
|
||||
'No parent directive that requires a transclusion found\. ' +
|
||||
'No parent directive that requires a transclusion found\\. ' +
|
||||
'Element: <div ng-transclude.+'));
|
||||
}
|
||||
});
|
||||
@@ -4257,11 +4266,11 @@ describe('$compile', function() {
|
||||
return function(scope, element, attrs, ctrl) {
|
||||
log('link');
|
||||
var cursor = element;
|
||||
template(scope.$new(), function(clone) {cursor.after(cursor = clone)});
|
||||
ctrl.$transclude(function(clone) {cursor.after(clone)});
|
||||
template(scope.$new(), function(clone) { cursor.after(cursor = clone); });
|
||||
ctrl.$transclude(function(clone) { cursor.after(clone); });
|
||||
};
|
||||
}
|
||||
}
|
||||
};
|
||||
});
|
||||
});
|
||||
inject(function(log, $rootScope, $compile) {
|
||||
@@ -4434,7 +4443,7 @@ describe('$compile', function() {
|
||||
});
|
||||
inject(function($compile) {
|
||||
element = $compile('<div transclude></div>')($rootScope);
|
||||
expect(_$transclude).toBeDefined()
|
||||
expect(_$transclude).toBeDefined();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -4559,7 +4568,8 @@ describe('$compile', function() {
|
||||
expect(log.toArray()).toEqual([
|
||||
"outer:#comment:outer:",
|
||||
"innerAgain:#comment:innerAgain:",
|
||||
"inner:#comment:innerAgain:"]);
|
||||
"inner:#comment:innerAgain:"
|
||||
]);
|
||||
expect(child.length).toBe(1);
|
||||
expect(child.contents().length).toBe(2);
|
||||
expect(lowercase(nodeName_(child.contents().eq(0)))).toBe('#comment');
|
||||
@@ -4644,6 +4654,7 @@ describe('$compile', function() {
|
||||
}));
|
||||
|
||||
it('should not sanitize attributes other than src', inject(function($compile, $rootScope) {
|
||||
/* jshint scripturl:true */
|
||||
element = $compile('<img title="{{testUrl}}"></img>')($rootScope);
|
||||
$rootScope.testUrl = "javascript:doEvilStuff()";
|
||||
$rootScope.$apply();
|
||||
@@ -4688,6 +4699,7 @@ describe('$compile', function() {
|
||||
describe('a[href] sanitization', function() {
|
||||
|
||||
it('should not sanitize href on elements other than anchor', inject(function($compile, $rootScope) {
|
||||
/* jshint scripturl:true */
|
||||
element = $compile('<div href="{{testUrl}}"></div>')($rootScope);
|
||||
$rootScope.testUrl = "javascript:doEvilStuff()";
|
||||
$rootScope.$apply();
|
||||
@@ -4696,6 +4708,7 @@ describe('$compile', function() {
|
||||
}));
|
||||
|
||||
it('should not sanitize attributes other than href', inject(function($compile, $rootScope) {
|
||||
/* jshint scripturl:true */
|
||||
element = $compile('<a title="{{testUrl}}"></a>')($rootScope);
|
||||
$rootScope.testUrl = "javascript:doEvilStuff()";
|
||||
$rootScope.$apply();
|
||||
@@ -4759,6 +4772,7 @@ describe('$compile', function() {
|
||||
}));
|
||||
|
||||
it('should pass through arbitrary values on onXYZ event attributes that contain a hyphen', inject(function($compile, $rootScope) {
|
||||
/* jshint scripturl:true */
|
||||
element = $compile('<button on-click="{{onClickJs}}"></script>')($rootScope);
|
||||
$rootScope.onClickJs = 'javascript:doSomething()';
|
||||
$rootScope.$apply();
|
||||
@@ -4789,22 +4803,24 @@ describe('$compile', function() {
|
||||
it('should clear out src attributes for a different domain', inject(function($compile, $rootScope, $sce) {
|
||||
element = $compile('<iframe src="{{testUrl}}"></iframe>')($rootScope);
|
||||
$rootScope.testUrl = "http://a.different.domain.example.com";
|
||||
expect(function() { $rootScope.$apply() }).toThrowMinErr(
|
||||
expect(function() { $rootScope.$apply(); }).toThrowMinErr(
|
||||
"$interpolate", "interr", "Can't interpolate: {{testUrl}}\nError: [$sce:insecurl] Blocked " +
|
||||
"loading resource from url not allowed by $sceDelegate policy. URL: " +
|
||||
"http://a.different.domain.example.com");
|
||||
}));
|
||||
|
||||
it('should clear out JS src attributes', inject(function($compile, $rootScope, $sce) {
|
||||
/* jshint scripturl:true */
|
||||
element = $compile('<iframe src="{{testUrl}}"></iframe>')($rootScope);
|
||||
$rootScope.testUrl = "javascript:alert(1);";
|
||||
expect(function() { $rootScope.$apply() }).toThrowMinErr(
|
||||
expect(function() { $rootScope.$apply(); }).toThrowMinErr(
|
||||
"$interpolate", "interr", "Can't interpolate: {{testUrl}}\nError: [$sce:insecurl] Blocked " +
|
||||
"loading resource from url not allowed by $sceDelegate policy. URL: " +
|
||||
"javascript:alert(1);");
|
||||
}));
|
||||
|
||||
it('should clear out non-resource_url src attributes', inject(function($compile, $rootScope, $sce) {
|
||||
/* jshint scripturl:true */
|
||||
element = $compile('<iframe src="{{testUrl}}"></iframe>')($rootScope);
|
||||
$rootScope.testUrl = $sce.trustAsUrl("javascript:doTrustedStuff()");
|
||||
expect($rootScope.$apply).toThrowMinErr(
|
||||
@@ -4813,6 +4829,7 @@ describe('$compile', function() {
|
||||
}));
|
||||
|
||||
it('should pass through $sce.trustAs() values in src attributes', inject(function($compile, $rootScope, $sce) {
|
||||
/* jshint scripturl:true */
|
||||
element = $compile('<iframe src="{{testUrl}}"></iframe>')($rootScope);
|
||||
$rootScope.testUrl = $sce.trustAsResourceUrl("javascript:doTrustedStuff()");
|
||||
$rootScope.$apply();
|
||||
@@ -4832,22 +4849,24 @@ describe('$compile', function() {
|
||||
it('should clear out action attribute for a different domain', inject(function($compile, $rootScope, $sce) {
|
||||
element = $compile('<form action="{{testUrl}}"></form>')($rootScope);
|
||||
$rootScope.testUrl = "http://a.different.domain.example.com";
|
||||
expect(function() { $rootScope.$apply() }).toThrowMinErr(
|
||||
expect(function() { $rootScope.$apply(); }).toThrowMinErr(
|
||||
"$interpolate", "interr", "Can't interpolate: {{testUrl}}\nError: [$sce:insecurl] Blocked " +
|
||||
"loading resource from url not allowed by $sceDelegate policy. URL: " +
|
||||
"http://a.different.domain.example.com");
|
||||
}));
|
||||
|
||||
it('should clear out JS action attribute', inject(function($compile, $rootScope, $sce) {
|
||||
/* jshint scripturl:true */
|
||||
element = $compile('<form action="{{testUrl}}"></form>')($rootScope);
|
||||
$rootScope.testUrl = "javascript:alert(1);";
|
||||
expect(function() { $rootScope.$apply() }).toThrowMinErr(
|
||||
expect(function() { $rootScope.$apply(); }).toThrowMinErr(
|
||||
"$interpolate", "interr", "Can't interpolate: {{testUrl}}\nError: [$sce:insecurl] Blocked " +
|
||||
"loading resource from url not allowed by $sceDelegate policy. URL: " +
|
||||
"javascript:alert(1);");
|
||||
}));
|
||||
|
||||
it('should clear out non-resource_url action attribute', inject(function($compile, $rootScope, $sce) {
|
||||
/* jshint scripturl:true */
|
||||
element = $compile('<form action="{{testUrl}}"></form>')($rootScope);
|
||||
$rootScope.testUrl = $sce.trustAsUrl("javascript:doTrustedStuff()");
|
||||
expect($rootScope.$apply).toThrowMinErr(
|
||||
@@ -4856,6 +4875,7 @@ describe('$compile', function() {
|
||||
}));
|
||||
|
||||
it('should pass through $sce.trustAs() values in action attribute', inject(function($compile, $rootScope, $sce) {
|
||||
/* jshint scripturl:true */
|
||||
element = $compile('<form action="{{testUrl}}"></form>')($rootScope);
|
||||
$rootScope.testUrl = $sce.trustAsResourceUrl("javascript:doTrustedStuff()");
|
||||
$rootScope.$apply();
|
||||
|
||||
@@ -16,7 +16,7 @@ describe('$controller', function() {
|
||||
describe('provider', function() {
|
||||
|
||||
it('should allow registration of controllers', function() {
|
||||
var FooCtrl = function($scope) { $scope.foo = 'bar' },
|
||||
var FooCtrl = function($scope) { $scope.foo = 'bar'; },
|
||||
scope = {},
|
||||
ctrl;
|
||||
|
||||
@@ -29,8 +29,8 @@ describe('$controller', function() {
|
||||
|
||||
|
||||
it('should allow registration of map of controllers', function() {
|
||||
var FooCtrl = function($scope) { $scope.foo = 'foo' },
|
||||
BarCtrl = function($scope) { $scope.bar = 'bar' },
|
||||
var FooCtrl = function($scope) { $scope.foo = 'foo'; },
|
||||
BarCtrl = function($scope) { $scope.bar = 'bar'; },
|
||||
scope = {},
|
||||
ctrl;
|
||||
|
||||
@@ -47,7 +47,7 @@ describe('$controller', function() {
|
||||
|
||||
|
||||
it('should allow registration of controllers annotated with arrays', function() {
|
||||
var FooCtrl = function($scope) { $scope.foo = 'bar' },
|
||||
var FooCtrl = function($scope) { $scope.foo = 'bar'; },
|
||||
scope = {},
|
||||
ctrl;
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ describe('boolean attr directives', function() {
|
||||
|
||||
it('should properly evaluate 0 as false', inject(function($rootScope, $compile) {
|
||||
// jQuery does not treat 0 as false, when setting attr()
|
||||
element = $compile('<button ng-disabled="isDisabled">Button</button>')($rootScope)
|
||||
element = $compile('<button ng-disabled="isDisabled">Button</button>')($rootScope);
|
||||
$rootScope.isDisabled = 0;
|
||||
$rootScope.$digest();
|
||||
expect(element.attr('disabled')).toBeFalsy();
|
||||
@@ -21,7 +21,7 @@ describe('boolean attr directives', function() {
|
||||
|
||||
|
||||
it('should bind disabled', inject(function($rootScope, $compile) {
|
||||
element = $compile('<button ng-disabled="isDisabled">Button</button>')($rootScope)
|
||||
element = $compile('<button ng-disabled="isDisabled">Button</button>')($rootScope);
|
||||
$rootScope.isDisabled = false;
|
||||
$rootScope.$digest();
|
||||
expect(element.attr('disabled')).toBeFalsy();
|
||||
@@ -32,7 +32,7 @@ describe('boolean attr directives', function() {
|
||||
|
||||
|
||||
it('should bind checked', inject(function($rootScope, $compile) {
|
||||
element = $compile('<input type="checkbox" ng-checked="isChecked" />')($rootScope)
|
||||
element = $compile('<input type="checkbox" ng-checked="isChecked" />')($rootScope);
|
||||
$rootScope.isChecked = false;
|
||||
$rootScope.$digest();
|
||||
expect(element.attr('checked')).toBeFalsy();
|
||||
@@ -43,8 +43,8 @@ describe('boolean attr directives', function() {
|
||||
|
||||
|
||||
it('should bind selected', inject(function($rootScope, $compile) {
|
||||
element = $compile('<select><option value=""></option><option ng-selected="isSelected">Greetings!</option></select>')($rootScope)
|
||||
jqLite(document.body).append(element)
|
||||
element = $compile('<select><option value=""></option><option ng-selected="isSelected">Greetings!</option></select>')($rootScope);
|
||||
jqLite(document.body).append(element);
|
||||
$rootScope.isSelected=false;
|
||||
$rootScope.$digest();
|
||||
expect(element.children()[1].selected).toBeFalsy();
|
||||
@@ -55,7 +55,7 @@ describe('boolean attr directives', function() {
|
||||
|
||||
|
||||
it('should bind readonly', inject(function($rootScope, $compile) {
|
||||
element = $compile('<input type="text" ng-readonly="isReadonly" />')($rootScope)
|
||||
element = $compile('<input type="text" ng-readonly="isReadonly" />')($rootScope);
|
||||
$rootScope.isReadonly=false;
|
||||
$rootScope.$digest();
|
||||
expect(element.attr('readOnly')).toBeFalsy();
|
||||
@@ -66,7 +66,7 @@ describe('boolean attr directives', function() {
|
||||
|
||||
|
||||
it('should bind open', inject(function($rootScope, $compile) {
|
||||
element = $compile('<details ng-open="isOpen"></details>')($rootScope)
|
||||
element = $compile('<details ng-open="isOpen"></details>')($rootScope);
|
||||
$rootScope.isOpen=false;
|
||||
$rootScope.$digest();
|
||||
expect(element.attr('open')).toBeFalsy();
|
||||
@@ -78,7 +78,7 @@ describe('boolean attr directives', function() {
|
||||
|
||||
describe('multiple', function() {
|
||||
it('should NOT bind to multiple via ngMultiple', inject(function($rootScope, $compile) {
|
||||
element = $compile('<select ng-multiple="isMultiple"></select>')($rootScope)
|
||||
element = $compile('<select ng-multiple="isMultiple"></select>')($rootScope);
|
||||
$rootScope.isMultiple=false;
|
||||
$rootScope.$digest();
|
||||
expect(element.attr('multiple')).toBeFalsy();
|
||||
@@ -92,7 +92,7 @@ describe('boolean attr directives', function() {
|
||||
if (msie < 9) return; //IE8 doesn't support biding to boolean attributes
|
||||
|
||||
expect(function() {
|
||||
$compile('<select multiple="{{isMultiple}}"></select>')
|
||||
$compile('<select multiple="{{isMultiple}}"></select>');
|
||||
}).toThrowMinErr('$compile', 'selmulti', 'Binding to the \'multiple\' attribute is not supported. ' +
|
||||
'Element: <select multiple="{{isMultiple}}">');
|
||||
|
||||
@@ -225,7 +225,7 @@ describe('ngHref', function() {
|
||||
|
||||
|
||||
it('should interpolate the expression and bind to href', inject(function($compile, $rootScope) {
|
||||
element = $compile('<div ng-href="some/{{id}}"></div>')($rootScope)
|
||||
element = $compile('<div ng-href="some/{{id}}"></div>')($rootScope);
|
||||
$rootScope.$digest();
|
||||
expect(element.attr('href')).toEqual('some/');
|
||||
|
||||
@@ -247,7 +247,7 @@ describe('ngHref', function() {
|
||||
|
||||
|
||||
it('should bind href even if no interpolation', inject(function($rootScope, $compile) {
|
||||
element = $compile('<a ng-href="http://server"></a>')($rootScope)
|
||||
element = $compile('<a ng-href="http://server"></a>')($rootScope);
|
||||
$rootScope.$digest();
|
||||
expect(element.attr('href')).toEqual('http://server');
|
||||
}));
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
/* global FormController: false */
|
||||
'use strict';
|
||||
|
||||
describe('form', function() {
|
||||
@@ -148,9 +149,9 @@ describe('form', function() {
|
||||
'<input name="hasOwnProperty" ng-model="some" />'+
|
||||
'<input name="other" ng-model="someOther" />'+
|
||||
'</form>');
|
||||
expect(function() {
|
||||
$compile(doc)(scope);
|
||||
}).toThrowMinErr('ng', 'badname');
|
||||
expect(function() {
|
||||
$compile(doc)(scope);
|
||||
}).toThrowMinErr('ng', 'badname');
|
||||
});
|
||||
|
||||
|
||||
@@ -177,7 +178,7 @@ describe('form', function() {
|
||||
|
||||
scope.submitMe = function() {
|
||||
submitted = true;
|
||||
}
|
||||
};
|
||||
|
||||
if (msie!=8) addEventListenerFn(doc[0], 'submit', assertPreventDefaultListener);
|
||||
|
||||
@@ -218,11 +219,11 @@ describe('form', function() {
|
||||
// $location change) that will cause some directive to destroy the dom (e.g. ngView+$route)
|
||||
doc.empty();
|
||||
destroyed = true;
|
||||
}
|
||||
};
|
||||
|
||||
scope.submitMe = function() {
|
||||
submitted = true;
|
||||
}
|
||||
};
|
||||
|
||||
var assertPreventDefaultListener = function(e) {
|
||||
reloadPrevented = e.defaultPrevented || (e.returnValue === false);
|
||||
@@ -434,7 +435,7 @@ describe('form', function() {
|
||||
expect(parent.$error.myRule).toBe(false);
|
||||
expect(child.$error.myRule).toBe(false);
|
||||
});
|
||||
})
|
||||
});
|
||||
|
||||
|
||||
describe('validation', function() {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
describe('NgModelController', function() {
|
||||
/* global NgModelController: false */
|
||||
var ctrl, scope, ngModelAccessor, element, parentFormCtrl;
|
||||
|
||||
beforeEach(inject(function($rootScope, $controller) {
|
||||
@@ -9,7 +10,7 @@ describe('NgModelController', function() {
|
||||
parentFormCtrl = {
|
||||
$setValidity: jasmine.createSpy('$setValidity'),
|
||||
$setDirty: jasmine.createSpy('$setDirty')
|
||||
}
|
||||
};
|
||||
|
||||
element = jqLite('<form><input></form>');
|
||||
element.data('$formController', parentFormCtrl);
|
||||
@@ -17,7 +18,9 @@ describe('NgModelController', function() {
|
||||
scope = $rootScope;
|
||||
ngModelAccessor = jasmine.createSpy('ngModel accessor');
|
||||
ctrl = $controller(NgModelController, {
|
||||
$scope: scope, $element: element.find('input'), $attrs: attrs
|
||||
$scope: scope,
|
||||
$element: element.find('input'),
|
||||
$attrs: attrs
|
||||
});
|
||||
}));
|
||||
|
||||
@@ -387,24 +390,20 @@ describe('ngModel', function() {
|
||||
it('should keep previously defined watches consistent when changes in validity are made',
|
||||
inject(function($compile, $rootScope) {
|
||||
|
||||
var isFormValid;
|
||||
$rootScope.$watch('myForm.$valid', function(value) { isFormValid = value; });
|
||||
|
||||
var element = $compile('<form name="myForm">' +
|
||||
'<input name="myControl" ng-model="value" required >' +
|
||||
'</form>')($rootScope);
|
||||
|
||||
$rootScope.$apply();
|
||||
expect(isFormValid).toBe(false);
|
||||
expect($rootScope.myForm.$valid).toBe(false);
|
||||
|
||||
$rootScope.value='value';
|
||||
$rootScope.$apply();
|
||||
expect(isFormValid).toBe(true);
|
||||
expect($rootScope.myForm.$valid).toBe(true);
|
||||
|
||||
dealoc(element);
|
||||
}));
|
||||
var isFormValid;
|
||||
$rootScope.$watch('myForm.$valid', function(value) { isFormValid = value; });
|
||||
var element = $compile('<form name="myForm">' +
|
||||
'<input name="myControl" ng-model="value" required >' +
|
||||
'</form>')($rootScope);
|
||||
$rootScope.$apply();
|
||||
expect(isFormValid).toBe(false);
|
||||
expect($rootScope.myForm.$valid).toBe(false);
|
||||
$rootScope.value='value';
|
||||
$rootScope.$apply();
|
||||
expect(isFormValid).toBe(true);
|
||||
expect($rootScope.myForm.$valid).toBe(true);
|
||||
dealoc(element);
|
||||
}));
|
||||
|
||||
});
|
||||
|
||||
@@ -472,7 +471,7 @@ describe('input', function() {
|
||||
this.message = function() {
|
||||
return "Attribute '" + attributeName + "' expected to be off but was '" + actualValue +
|
||||
"' in: " + angular.mock.dump(this.actual);
|
||||
}
|
||||
};
|
||||
|
||||
return !actualValue || actualValue == 'false';
|
||||
}
|
||||
@@ -495,7 +494,7 @@ describe('input', function() {
|
||||
expect(scope.name).toEqual('adam');
|
||||
});
|
||||
|
||||
if (!(msie < 9)) {
|
||||
if (!msie || msie >= 9) {
|
||||
describe('compositionevents', function() {
|
||||
it('should not update the model between "compositionstart" and "compositionend" on non android', inject(function($sniffer) {
|
||||
$sniffer.android = false;
|
||||
@@ -529,7 +528,7 @@ describe('input', function() {
|
||||
|
||||
it('should update the model on "compositionend"', function() {
|
||||
compileInput('<input type="text" ng-model="name" name="alias" />');
|
||||
if (!(msie < 9)) {
|
||||
if (!msie || msie >= 9) {
|
||||
browserTrigger(inputElm, 'compositionstart');
|
||||
changeInputValueTo('caitp');
|
||||
expect(scope.name).toBeUndefined();
|
||||
@@ -976,7 +975,7 @@ describe('input', function() {
|
||||
});
|
||||
|
||||
expect(inputElm).toBeValid();
|
||||
expect(inputElm.val()).toBe('0')
|
||||
expect(inputElm.val()).toBe('0');
|
||||
expect(scope.form.alias.$error.required).toBeFalsy();
|
||||
});
|
||||
|
||||
@@ -1013,7 +1012,7 @@ describe('input', function() {
|
||||
|
||||
|
||||
describe('EMAIL_REGEXP', function() {
|
||||
|
||||
/* global EMAIL_REGEXP: false */
|
||||
it('should validate email', function() {
|
||||
expect(EMAIL_REGEXP.test('a@b.com')).toBe(true);
|
||||
expect(EMAIL_REGEXP.test('a@b.museum')).toBe(true);
|
||||
@@ -1047,7 +1046,7 @@ describe('input', function() {
|
||||
|
||||
|
||||
describe('URL_REGEXP', function() {
|
||||
|
||||
/* global URL_REGEXP: false */
|
||||
it('should validate url', function() {
|
||||
expect(URL_REGEXP.test('http://server:123/path')).toBe(true);
|
||||
expect(URL_REGEXP.test('a@B.c')).toBe(false);
|
||||
@@ -1562,7 +1561,7 @@ describe('NgModel animations', function() {
|
||||
}
|
||||
}
|
||||
return animations;
|
||||
};
|
||||
}
|
||||
|
||||
function assertValidAnimation(animation, event, className) {
|
||||
expect(animation.event).toBe(event);
|
||||
|
||||
@@ -72,7 +72,8 @@ describe('ngClass', function() {
|
||||
$rootScope.$digest();
|
||||
expect(element.hasClass('A')).toBeFalsy();
|
||||
expect(element.hasClass('B')).toBeTruthy();
|
||||
}));
|
||||
})
|
||||
);
|
||||
|
||||
|
||||
it('should support adding multiple classes via a space delimited string', inject(function($rootScope, $compile) {
|
||||
@@ -195,16 +196,16 @@ describe('ngClass', function() {
|
||||
|
||||
|
||||
it("should allow ngClassOdd/Even on the same element with overlapping classes", inject(function($rootScope, $compile, $animate) {
|
||||
var className;
|
||||
var className;
|
||||
|
||||
element = $compile('<ul><li ng-repeat="i in [0,1,2]" ng-class-odd="\'same odd\'" ng-class-even="\'same even\'"></li><ul>')($rootScope);
|
||||
$rootScope.$digest();
|
||||
var e1 = jqLite(element[0].childNodes[1]);
|
||||
var e2 = jqLite(element[0].childNodes[5]);
|
||||
expect(e1.hasClass('same')).toBeTruthy();
|
||||
expect(e1.hasClass('odd')).toBeTruthy();
|
||||
expect(e2.hasClass('same')).toBeTruthy();
|
||||
expect(e2.hasClass('odd')).toBeTruthy();
|
||||
element = $compile('<ul><li ng-repeat="i in [0,1,2]" ng-class-odd="\'same odd\'" ng-class-even="\'same even\'"></li><ul>')($rootScope);
|
||||
$rootScope.$digest();
|
||||
var e1 = jqLite(element[0].childNodes[1]);
|
||||
var e2 = jqLite(element[0].childNodes[5]);
|
||||
expect(e1.hasClass('same')).toBeTruthy();
|
||||
expect(e1.hasClass('odd')).toBeTruthy();
|
||||
expect(e2.hasClass('same')).toBeTruthy();
|
||||
expect(e2.hasClass('odd')).toBeTruthy();
|
||||
}));
|
||||
|
||||
it('should allow ngClass with overlapping classes', inject(function($rootScope, $compile, $animate) {
|
||||
|
||||
@@ -35,7 +35,7 @@ describe('ngController', function() {
|
||||
|
||||
$window.Public = function() {
|
||||
this.mark = 'works';
|
||||
}
|
||||
};
|
||||
}));
|
||||
|
||||
afterEach(function() {
|
||||
|
||||
@@ -226,8 +226,8 @@ describe('ngIf and transcludes', function() {
|
||||
describe('ngIf animations', function () {
|
||||
var body, element, $rootElement;
|
||||
|
||||
function html(html) {
|
||||
$rootElement.html(html);
|
||||
function html(content) {
|
||||
$rootElement.html(content);
|
||||
element = $rootElement.children().eq(0);
|
||||
return element;
|
||||
}
|
||||
@@ -272,7 +272,8 @@ describe('ngIf animations', function () {
|
||||
expect(item.element.text()).toBe('Hi');
|
||||
|
||||
expect(element.children().length).toBe(1);
|
||||
}));
|
||||
})
|
||||
);
|
||||
|
||||
it('should fire off the leave animation',
|
||||
inject(function ($compile, $rootScope, $animate) {
|
||||
@@ -297,7 +298,8 @@ describe('ngIf animations', function () {
|
||||
expect(item.element.text()).toBe('Hi');
|
||||
|
||||
expect(element.children().length).toBe(0);
|
||||
}));
|
||||
})
|
||||
);
|
||||
|
||||
it('should destroy the previous leave animation if a new one takes place', function() {
|
||||
module(function($provide) {
|
||||
|
||||
@@ -112,7 +112,7 @@ describe('ngInclude', function() {
|
||||
it('should fire $includeContentRequested event on scope after making the xhr call', inject(
|
||||
function ($rootScope, $compile, $httpBackend) {
|
||||
var contentRequestedSpy = jasmine.createSpy('content requested').andCallFake(function (event) {
|
||||
expect(event.targetScope).toBe($rootScope);
|
||||
expect(event.targetScope).toBe($rootScope);
|
||||
});
|
||||
|
||||
$httpBackend.whenGET('url').respond('my partial');
|
||||
@@ -233,7 +233,8 @@ describe('ngInclude', function() {
|
||||
var called = 0;
|
||||
// we want to assert only during first watch
|
||||
$rootScope.$watch(function() {
|
||||
if (!called++) expect(element.text()).toBe('');
|
||||
if (!called) expect(element.text()).toBe('');
|
||||
called++;
|
||||
});
|
||||
|
||||
$rootScope.$digest();
|
||||
@@ -249,7 +250,7 @@ describe('ngInclude', function() {
|
||||
$rootScope.templateUrl = 'myUrl1';
|
||||
$rootScope.logger = function(msg) {
|
||||
log[msg] = true;
|
||||
}
|
||||
};
|
||||
$compile(element)($rootScope);
|
||||
expect(log).toEqual({});
|
||||
|
||||
@@ -451,16 +452,17 @@ describe('ngInclude', function() {
|
||||
}));
|
||||
|
||||
it('should only call $anchorScroll after the "enter" animation completes', inject(
|
||||
compileAndLink('<div><ng:include src="tpl" autoscroll></ng:include></div>'),
|
||||
function($rootScope, $animate, $timeout) {
|
||||
expect(autoScrollSpy).not.toHaveBeenCalled();
|
||||
compileAndLink('<div><ng:include src="tpl" autoscroll></ng:include></div>'),
|
||||
function($rootScope, $animate, $timeout) {
|
||||
expect(autoScrollSpy).not.toHaveBeenCalled();
|
||||
|
||||
$rootScope.$apply("tpl = 'template.html'");
|
||||
expect($animate.queue.shift().event).toBe('enter');
|
||||
$animate.triggerCallbacks();
|
||||
$rootScope.$apply("tpl = 'template.html'");
|
||||
expect($animate.queue.shift().event).toBe('enter');
|
||||
$animate.triggerCallbacks();
|
||||
|
||||
expect(autoScrollSpy).toHaveBeenCalledOnce();
|
||||
}));
|
||||
expect(autoScrollSpy).toHaveBeenCalledOnce();
|
||||
}
|
||||
));
|
||||
});
|
||||
});
|
||||
|
||||
@@ -569,8 +571,8 @@ describe('ngInclude and transcludes', function() {
|
||||
describe('ngInclude animations', function() {
|
||||
var body, element, $rootElement;
|
||||
|
||||
function html(html) {
|
||||
$rootElement.html(html);
|
||||
function html(content) {
|
||||
$rootElement.html(content);
|
||||
element = $rootElement.children().eq(0);
|
||||
return element;
|
||||
}
|
||||
@@ -611,7 +613,8 @@ describe('ngInclude animations', function() {
|
||||
var animation = $animate.queue.pop();
|
||||
expect(animation.event).toBe('enter');
|
||||
expect(animation.element.text()).toBe('data');
|
||||
}));
|
||||
})
|
||||
);
|
||||
|
||||
it('should fire off the leave animation',
|
||||
inject(function($compile, $rootScope, $templateCache, $animate) {
|
||||
@@ -635,7 +638,8 @@ describe('ngInclude animations', function() {
|
||||
animation = $animate.queue.shift();
|
||||
expect(animation.event).toBe('leave');
|
||||
expect(animation.element.text()).toBe('data');
|
||||
}));
|
||||
})
|
||||
);
|
||||
|
||||
it('should animate two separate ngInclude elements',
|
||||
inject(function($compile, $rootScope, $templateCache, $animate) {
|
||||
@@ -661,7 +665,8 @@ describe('ngInclude animations', function() {
|
||||
expect(itemA.attr('ng-include')).toBe('tpl');
|
||||
expect(itemB.attr('ng-include')).toBe('tpl');
|
||||
expect(itemA).not.toEqual(itemB);
|
||||
}));
|
||||
}
|
||||
));
|
||||
|
||||
it('should destroy the previous leave animation if a new one takes place', function() {
|
||||
module(function($provide) {
|
||||
|
||||
@@ -240,6 +240,6 @@ describe('ngPluralize', function() {
|
||||
expect(element.text()).toBe('Igor and 2 other people are viewing.');
|
||||
expect(elementAlt.text()).toBe('Igor and 2 other people are viewing.');
|
||||
});
|
||||
})
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -79,6 +79,7 @@ describe('ngRepeat', function() {
|
||||
});
|
||||
|
||||
it('should iterate over an array-like class', function() {
|
||||
/* jshint -W009 */
|
||||
function Collection() {}
|
||||
Collection.prototype = new Array();
|
||||
Collection.prototype.length = 0;
|
||||
@@ -395,10 +396,10 @@ describe('ngRepeat', function() {
|
||||
|
||||
|
||||
it("should throw error when left-hand-side of ngRepeat can't be parsed", function() {
|
||||
element = jqLite('<ul><li ng-repeat="i dont parse in foo"></li></ul>');
|
||||
$compile(element)(scope);
|
||||
element = jqLite('<ul><li ng-repeat="i dont parse in foo"></li></ul>');
|
||||
$compile(element)(scope);
|
||||
expect($exceptionHandler.errors.shift()[0].message).
|
||||
toMatch(/^\[ngRepeat:iidexp\] '_item_' in '_item_ in _collection_' should be an identifier or '\(_key_, _value_\)' expression, but got 'i dont parse'\./);
|
||||
toMatch(/^\[ngRepeat:iidexp\] '_item_' in '_item_ in _collection_' should be an identifier or '\(_key_, _value_\)' expression, but got 'i dont parse'\./);
|
||||
});
|
||||
|
||||
|
||||
@@ -818,7 +819,7 @@ describe('ngRepeat', function() {
|
||||
expect(children[1].nextSibling.nodeValue).toBe(' end ngRepeat: val in values ');
|
||||
expect(children[2].nextSibling.nodeType).toBe(8);
|
||||
expect(children[2].nextSibling.nodeValue).toBe(' end ngRepeat: val in values ');
|
||||
}
|
||||
};
|
||||
|
||||
$rootScope.values = [1, 2, 3];
|
||||
|
||||
@@ -1045,7 +1046,7 @@ describe('ngRepeat', function() {
|
||||
inject(function($compile, $rootScope) {
|
||||
element = $compile('<div><div ng-repeat="i in [1,2]" elm-trans>{{i}}</div></div>')($rootScope);
|
||||
$rootScope.$digest();
|
||||
expect(element.text()).toBe('[[1]][[2]]')
|
||||
expect(element.text()).toBe('[[1]][[2]]');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1143,8 +1144,8 @@ describe('ngRepeat and transcludes', function() {
|
||||
describe('ngRepeat animations', function() {
|
||||
var body, element, $rootElement;
|
||||
|
||||
function html(html) {
|
||||
$rootElement.html(html);
|
||||
function html(content) {
|
||||
$rootElement.html(content);
|
||||
element = $rootElement.children().eq(0);
|
||||
return element;
|
||||
}
|
||||
@@ -1268,6 +1269,7 @@ describe('ngRepeat animations', function() {
|
||||
item = $animate.queue.shift();
|
||||
expect(item.event).toBe('move');
|
||||
expect(item.element.text()).toBe('3');
|
||||
}));
|
||||
})
|
||||
);
|
||||
|
||||
});
|
||||
|
||||
@@ -55,9 +55,9 @@ describe('ngShow / ngHide', function() {
|
||||
describe('ngShow / ngHide animations', function() {
|
||||
var body, element, $rootElement;
|
||||
|
||||
function html(html) {
|
||||
function html(content) {
|
||||
body.append($rootElement);
|
||||
$rootElement.html(html);
|
||||
$rootElement.html(content);
|
||||
element = $rootElement.children().eq(0);
|
||||
return element;
|
||||
}
|
||||
|
||||
@@ -26,22 +26,24 @@ describe('ngSrc', function() {
|
||||
it('should error on src attributes for a different domain', inject(function($compile, $rootScope) {
|
||||
element = $compile('<iframe ng-src="{{testUrl}}"></iframe>')($rootScope);
|
||||
$rootScope.testUrl = "http://a.different.domain.example.com";
|
||||
expect(function() { $rootScope.$apply() }).toThrowMinErr(
|
||||
expect(function() { $rootScope.$apply(); }).toThrowMinErr(
|
||||
"$interpolate", "interr", "Can't interpolate: {{testUrl}}\nError: [$sce:insecurl] Blocked " +
|
||||
"loading resource from url not allowed by $sceDelegate policy. URL: " +
|
||||
"http://a.different.domain.example.com");
|
||||
}));
|
||||
|
||||
it('should error on JS src attributes', inject(function($compile, $rootScope) {
|
||||
/* jshint scripturl:true */
|
||||
element = $compile('<iframe ng-src="{{testUrl}}"></iframe>')($rootScope);
|
||||
$rootScope.testUrl = "javascript:alert(1);";
|
||||
expect(function() { $rootScope.$apply() }).toThrowMinErr(
|
||||
expect(function() { $rootScope.$apply(); }).toThrowMinErr(
|
||||
"$interpolate", "interr", "Can't interpolate: {{testUrl}}\nError: [$sce:insecurl] Blocked " +
|
||||
"loading resource from url not allowed by $sceDelegate policy. URL: " +
|
||||
"javascript:alert(1);");
|
||||
}));
|
||||
|
||||
it('should error on non-resource_url src attributes', inject(function($compile, $rootScope, $sce) {
|
||||
/* jshint scripturl:true */
|
||||
element = $compile('<iframe ng-src="{{testUrl}}"></iframe>')($rootScope);
|
||||
$rootScope.testUrl = $sce.trustAsUrl("javascript:doTrustedStuff()");
|
||||
expect($rootScope.$apply).toThrowMinErr(
|
||||
@@ -51,6 +53,7 @@ describe('ngSrc', function() {
|
||||
}));
|
||||
|
||||
it('should pass through $sce.trustAs() values in src attributes', inject(function($compile, $rootScope, $sce) {
|
||||
/* jshint scripturl:true */
|
||||
element = $compile('<iframe ng-src="{{testUrl}}"></iframe>')($rootScope);
|
||||
$rootScope.testUrl = $sce.trustAsResourceUrl("javascript:doTrustedStuff()");
|
||||
$rootScope.$apply();
|
||||
|
||||
@@ -240,8 +240,8 @@ describe('ngSwitch', function() {
|
||||
describe('ngSwitch animations', function() {
|
||||
var body, element, $rootElement;
|
||||
|
||||
function html(html) {
|
||||
$rootElement.html(html);
|
||||
function html(content) {
|
||||
$rootElement.html(content);
|
||||
element = $rootElement.children().eq(0);
|
||||
return element;
|
||||
}
|
||||
@@ -281,7 +281,8 @@ describe('ngSwitch animations', function() {
|
||||
item = $animate.queue.shift();
|
||||
expect(item.event).toBe('enter');
|
||||
expect(item.element.text()).toBe('one');
|
||||
}));
|
||||
})
|
||||
);
|
||||
|
||||
|
||||
it('should fire off the leave animation',
|
||||
@@ -314,7 +315,8 @@ describe('ngSwitch animations', function() {
|
||||
item = $animate.queue.shift();
|
||||
expect(item.event).toBe('enter');
|
||||
expect(item.element.text()).toBe('three');
|
||||
}));
|
||||
})
|
||||
);
|
||||
|
||||
it('should destroy the previous leave animation if a new one takes place', function() {
|
||||
module(function($provide) {
|
||||
|
||||
@@ -218,7 +218,7 @@ describe('select', function() {
|
||||
|
||||
it('should not break if both the select and repeater models change at once', function() {
|
||||
scope.robots = ['c3p0', 'r2d2'];
|
||||
scope.robot = 'c3p0'
|
||||
scope.robot = 'c3p0';
|
||||
compile('<select ng-model="robot">' +
|
||||
'<option value="">--select--</option>' +
|
||||
'<option ng-repeat="r in robots">{{r}}</option>' +
|
||||
@@ -1206,7 +1206,7 @@ describe('select', function() {
|
||||
|
||||
it('should deselect all options when model is emptied', function() {
|
||||
createMultiSelect();
|
||||
scope.$apply(function() {
|
||||
scope.$apply(function() {
|
||||
scope.values = [{name: 'A'}, {name: 'B'}];
|
||||
scope.selected = [scope.values[0]];
|
||||
});
|
||||
@@ -1217,7 +1217,7 @@ describe('select', function() {
|
||||
});
|
||||
|
||||
expect(element.find('option')[0].selected).toEqual(false);
|
||||
})
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -1325,7 +1325,7 @@ describe('select', function() {
|
||||
});
|
||||
|
||||
it('should set value even if self closing HTML', function() {
|
||||
scope.x = 'hello'
|
||||
scope.x = 'hello';
|
||||
compile('<select ng-model="x"><option>hello</select>');
|
||||
expect(element).toEqualSelect(['hello']);
|
||||
});
|
||||
|
||||
@@ -1,24 +1,25 @@
|
||||
'use strict';
|
||||
|
||||
describe('$exceptionHandler', function() {
|
||||
it('should log errors with single argument', function() {
|
||||
module(function($provide){
|
||||
$provide.provider('$exceptionHandler', $ExceptionHandlerProvider);
|
||||
});
|
||||
inject(function($log, $exceptionHandler) {
|
||||
$exceptionHandler('myError');
|
||||
expect($log.error.logs.shift()).toEqual(['myError']);
|
||||
});
|
||||
/* global $ExceptionHandlerProvider:false */
|
||||
it('should log errors with single argument', function() {
|
||||
module(function($provide){
|
||||
$provide.provider('$exceptionHandler', $ExceptionHandlerProvider);
|
||||
});
|
||||
inject(function($log, $exceptionHandler) {
|
||||
$exceptionHandler('myError');
|
||||
expect($log.error.logs.shift()).toEqual(['myError']);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
it('should log errors with multiple arguments', function() {
|
||||
module(function($provide){
|
||||
$provide.provider('$exceptionHandler', $ExceptionHandlerProvider);
|
||||
});
|
||||
inject(function($log, $exceptionHandler) {
|
||||
$exceptionHandler('myError', 'comment');
|
||||
expect($log.error.logs.shift()).toEqual(['myError', 'comment']);
|
||||
});
|
||||
it('should log errors with multiple arguments', function() {
|
||||
module(function($provide){
|
||||
$provide.provider('$exceptionHandler', $ExceptionHandlerProvider);
|
||||
});
|
||||
inject(function($log, $exceptionHandler) {
|
||||
$exceptionHandler('myError', 'comment');
|
||||
expect($log.error.logs.shift()).toEqual(['myError', 'comment']);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -77,7 +77,8 @@ describe('Filter: filter', function() {
|
||||
{person: {name: 'Joan'}}];
|
||||
expect(filter(items, {person: {name: 'Jo'}}).length).toBe(2);
|
||||
expect(filter(items, {person: {name: 'Jo'}})).toEqual([
|
||||
{person: {name: 'John'}}, {person: {name: 'Joan'}}]);
|
||||
{person: {name: 'John'}}, {person: {name: 'Joan'}}
|
||||
]);
|
||||
});
|
||||
|
||||
|
||||
@@ -94,8 +95,8 @@ describe('Filter: filter', function() {
|
||||
|
||||
it('should support boolean properties', function() {
|
||||
var items = [{name: 'tom', current: true},
|
||||
{name: 'demi', current: false},
|
||||
{name: 'sofia'}];
|
||||
{name: 'demi', current: false},
|
||||
{name: 'sofia'}];
|
||||
|
||||
expect(filter(items, {current:true}).length).toBe(1);
|
||||
expect(filter(items, {current:true})[0].name).toBe('tom');
|
||||
@@ -118,26 +119,26 @@ describe('Filter: filter', function() {
|
||||
expect(filter(items, expr, true)).toEqual([items[1]]);
|
||||
expect(filter(items, expr, false)).toEqual([items[1], items[2]]);
|
||||
|
||||
var items = [
|
||||
items = [
|
||||
{key: 'value1', nonkey: 1},
|
||||
{key: 'value2', nonkey: 2},
|
||||
{key: 'value12', nonkey: 3},
|
||||
{key: 'value1', nonkey:4},
|
||||
{key: 'Value1', nonkey:5}
|
||||
];
|
||||
var expr = {key: 'value1'};
|
||||
expr = {key: 'value1'};
|
||||
expect(filter(items, expr, true)).toEqual([items[0], items[3]]);
|
||||
|
||||
var items = [
|
||||
items = [
|
||||
{key: 1, nonkey: 1},
|
||||
{key: 2, nonkey: 2},
|
||||
{key: 12, nonkey: 3},
|
||||
{key: 1, nonkey:4}
|
||||
];
|
||||
var expr = { key: 1 };
|
||||
expr = { key: 1 };
|
||||
expect(filter(items, expr, true)).toEqual([items[0], items[3]]);
|
||||
|
||||
var expr = 12;
|
||||
expr = 12;
|
||||
expect(filter(items, expr, true)).toEqual([items[2]]);
|
||||
});
|
||||
|
||||
@@ -151,7 +152,7 @@ describe('Filter: filter', function() {
|
||||
var expr = {key: 10};
|
||||
var comparator = function (obj,value) {
|
||||
return obj > value;
|
||||
}
|
||||
};
|
||||
expect(filter(items, expr, comparator)).toEqual([items[2]]);
|
||||
|
||||
expr = 10;
|
||||
|
||||
@@ -19,6 +19,7 @@ describe('filters', function() {
|
||||
});
|
||||
|
||||
describe('formatNumber', function() {
|
||||
/* global formatNumber: false */
|
||||
var pattern;
|
||||
|
||||
beforeEach(function() {
|
||||
@@ -68,18 +69,18 @@ describe('filters', function() {
|
||||
expect(num).toBe('123.100');
|
||||
num = formatNumber(123.12, pattern, ',', '.');
|
||||
expect(num).toBe('123.12');
|
||||
var num = formatNumber(123.1116, pattern, ',', '.');
|
||||
num = formatNumber(123.1116, pattern, ',', '.');
|
||||
expect(num).toBe('123.112');
|
||||
});
|
||||
|
||||
it('should format the same with string as well as numeric fractionSize', function(){
|
||||
var num = formatNumber(123.1, pattern, ',', '.', "0");
|
||||
expect(num).toBe('123');
|
||||
var num = formatNumber(123.1, pattern, ',', '.', 0);
|
||||
num = formatNumber(123.1, pattern, ',', '.', 0);
|
||||
expect(num).toBe('123');
|
||||
var num = formatNumber(123.1, pattern, ',', '.', "3");
|
||||
num = formatNumber(123.1, pattern, ',', '.', "3");
|
||||
expect(num).toBe('123.100');
|
||||
var num = formatNumber(123.1, pattern, ',', '.', 3);
|
||||
num = formatNumber(123.1, pattern, ',', '.', 3);
|
||||
expect(num).toBe('123.100');
|
||||
});
|
||||
});
|
||||
@@ -121,6 +122,7 @@ describe('filters', function() {
|
||||
|
||||
|
||||
it('should do basic filter', function() {
|
||||
/* jshint -W008 */
|
||||
expect(number(0, 0)).toEqual('0');
|
||||
expect(number(-999)).toEqual('-999');
|
||||
expect(number(123)).toEqual('123');
|
||||
@@ -276,19 +278,19 @@ describe('filters', function() {
|
||||
var westOfUTCPartial = new angular.mock.TzDate(+5.5, '2010-09-03T12:05:08.000Z');
|
||||
|
||||
expect(date(utc, "yyyy-MM-ddTHH:mm:ssZ")).
|
||||
toEqual('2010-09-03T12:05:08+0000')
|
||||
toEqual('2010-09-03T12:05:08+0000');
|
||||
|
||||
expect(date(eastOfUTC, "yyyy-MM-ddTHH:mm:ssZ")).
|
||||
toEqual('2010-09-03T17:05:08+0500')
|
||||
toEqual('2010-09-03T17:05:08+0500');
|
||||
|
||||
expect(date(westOfUTC, "yyyy-MM-ddTHH:mm:ssZ")).
|
||||
toEqual('2010-09-03T07:05:08-0500')
|
||||
toEqual('2010-09-03T07:05:08-0500');
|
||||
|
||||
expect(date(eastOfUTCPartial, "yyyy-MM-ddTHH:mm:ssZ")).
|
||||
toEqual('2010-09-03T17:35:08+0530')
|
||||
toEqual('2010-09-03T17:35:08+0530');
|
||||
|
||||
expect(date(westOfUTCPartial, "yyyy-MM-ddTHH:mm:ssZ")).
|
||||
toEqual('2010-09-03T06:35:08-0530')
|
||||
toEqual('2010-09-03T06:35:08-0530');
|
||||
});
|
||||
|
||||
it('should treat single quoted strings as string literals', function() {
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
describe('Filter: limitTo', function() {
|
||||
var items;
|
||||
var str
|
||||
var str;
|
||||
var limitTo;
|
||||
|
||||
beforeEach(inject(function($filter) {
|
||||
@@ -67,7 +67,7 @@ describe('Filter: limitTo', function() {
|
||||
expect(limitTo(str, '9')).toEqual(str);
|
||||
expect(limitTo(str, -9)).toEqual(str);
|
||||
expect(limitTo(str, '-9')).toEqual(str);
|
||||
})
|
||||
});
|
||||
|
||||
it('should return entire input array when limited by Infinity', function() {
|
||||
expect(limitTo(items, Infinity)).toEqual(items);
|
||||
|
||||
@@ -32,13 +32,15 @@ describe('Filter: orderBy', function() {
|
||||
});
|
||||
|
||||
it('should support string predicates with names containing non-identifier characters', function() {
|
||||
/* jshint -W008 */
|
||||
expect(orderBy([{"Tip %": .25}, {"Tip %": .15}, {"Tip %": .40}], '"Tip %"'))
|
||||
.toEqualData([{"Tip %": .15}, {"Tip %": .25}, {"Tip %": .40}]);
|
||||
expect(orderBy([{"원": 76000}, {"원": 31000}, {"원": 156000}], '"원"'))
|
||||
.toEqualData([{"원": 31000}, {"원": 76000}, {"원": 156000}])
|
||||
.toEqualData([{"원": 31000}, {"원": 76000}, {"원": 156000}]);
|
||||
});
|
||||
|
||||
it('should throw if quoted string predicate is quoted incorrectly', function() {
|
||||
/* jshint -W008 */
|
||||
expect(function() {
|
||||
return orderBy([{"Tip %": .15}, {"Tip %": .25}, {"Tip %": .40}], '"Tip %\'');
|
||||
}).toThrow();
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
/* global createHttpBackend: false, createMockXhr: false, MockXhr: false */
|
||||
'use strict';
|
||||
|
||||
describe('$httpBackend', function() {
|
||||
|
||||
var $backend, $browser, callbacks,
|
||||
@@ -42,12 +45,14 @@ describe('$httpBackend', function() {
|
||||
// msie8 depends on modifying readyState for testing. This property is readonly,
|
||||
// so it requires a fake object. For other browsers, we do need to make use of
|
||||
// event listener registration/deregistration, so these stubs are needed.
|
||||
if (msie <= 8) return {
|
||||
attachEvent: noop,
|
||||
detachEvent: noop,
|
||||
addEventListener: noop,
|
||||
removeEventListener: noop
|
||||
};
|
||||
if (msie <= 8) {
|
||||
return {
|
||||
attachEvent: noop,
|
||||
detachEvent: noop,
|
||||
addEventListener: noop,
|
||||
removeEventListener: noop
|
||||
};
|
||||
}
|
||||
// Return a proper script element...
|
||||
return document.createElement(arguments[0]);
|
||||
}),
|
||||
@@ -307,7 +312,7 @@ describe('$httpBackend', function() {
|
||||
expect(response).toBe('response');
|
||||
});
|
||||
|
||||
$backend = createHttpBackend($browser, function() { return new SyncXhr() });
|
||||
$backend = createHttpBackend($browser, function() { return new SyncXhr(); });
|
||||
$backend('GET', '/url', null, callback);
|
||||
expect(callback).toHaveBeenCalledOnce();
|
||||
});
|
||||
@@ -518,6 +523,7 @@ describe('$httpBackend', function() {
|
||||
});
|
||||
|
||||
it('should convert 0 to 404 if no content - relative url', function() {
|
||||
/* global urlParsingNode: true */
|
||||
var originalUrlParsingNode = urlParsingNode;
|
||||
|
||||
//temporarily overriding the DOM element to pretend that the test runs origin with file:// protocol
|
||||
|
||||
+29
-21
@@ -9,12 +9,12 @@ describe('$http', function() {
|
||||
});
|
||||
|
||||
beforeEach(module(function($exceptionHandlerProvider) {
|
||||
$exceptionHandlerProvider.mode('log');
|
||||
$exceptionHandlerProvider.mode('log');
|
||||
}));
|
||||
|
||||
afterEach(inject(function($exceptionHandler, $httpBackend, $rootScope) {
|
||||
forEach($exceptionHandler.errors, function(e) {
|
||||
dump('Unhandled exception: ', e)
|
||||
dump('Unhandled exception: ', e);
|
||||
});
|
||||
|
||||
if ($exceptionHandler.errors.length) {
|
||||
@@ -28,7 +28,7 @@ describe('$http', function() {
|
||||
|
||||
describe('$httpProvider', function() {
|
||||
describe('interceptors', function() {
|
||||
it('should accept injected rejected response interceptor', function() {
|
||||
it('should accept injected rejected response interceptor', function() {
|
||||
var wasCalled = false;
|
||||
module(function($httpProvider, $provide) {
|
||||
$httpProvider.responseInterceptors.push('injectedInterceptor');
|
||||
@@ -83,7 +83,7 @@ describe('$http', function() {
|
||||
return {
|
||||
response: function(response) {
|
||||
response.data += ':1';
|
||||
savedResponse = response
|
||||
savedResponse = response;
|
||||
return $q.reject(':2');
|
||||
}
|
||||
};
|
||||
@@ -194,7 +194,7 @@ describe('$http', function() {
|
||||
response.data += '!';
|
||||
return response;
|
||||
});
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
// return a new resolved promise representing modified response object
|
||||
@@ -221,7 +221,7 @@ describe('$http', function() {
|
||||
response.data = uppercase(response.data);
|
||||
return response;
|
||||
});
|
||||
}
|
||||
};
|
||||
});
|
||||
$httpProvider.responseInterceptors.push('myInterceptor');
|
||||
});
|
||||
@@ -344,7 +344,7 @@ describe('$http', function() {
|
||||
$rootScope.$apply();
|
||||
expect(config.method).toEqual('get');
|
||||
expect(config.url).toEqual('/url');
|
||||
expect(config.headers.foo).toEqual('bar')
|
||||
expect(config.headers.foo).toEqual('bar');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -442,8 +442,8 @@ describe('$http', function() {
|
||||
|
||||
|
||||
it('should expand arrays in params map', inject(function($httpBackend, $http) {
|
||||
$httpBackend.expect('GET', '/url?a=1&a=2&a=3').respond('');
|
||||
$http({url: '/url', params: {a: [1,2,3]}, method: 'GET'});
|
||||
$httpBackend.expect('GET', '/url?a=1&a=2&a=3').respond('');
|
||||
$http({url: '/url', params: {a: [1,2,3]}, method: 'GET'});
|
||||
}));
|
||||
|
||||
|
||||
@@ -460,7 +460,7 @@ describe('$http', function() {
|
||||
it('should not add question mark when params is empty', function() {
|
||||
$httpBackend.expect('GET', '/url').respond('');
|
||||
$http({url: '/url', params: {}, method: 'GET'});
|
||||
})
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -591,7 +591,7 @@ describe('$http', function() {
|
||||
expect(r.headers('nothing')).toBe(null);
|
||||
});
|
||||
|
||||
$http({url: '/url', method: 'GET'}).then(callback)
|
||||
$http({url: '/url', method: 'GET'}).then(callback);
|
||||
$httpBackend.flush();
|
||||
|
||||
expect(callback).toHaveBeenCalledOnce();
|
||||
@@ -629,6 +629,7 @@ describe('$http', function() {
|
||||
|
||||
|
||||
describe('response headers parser', function() {
|
||||
/* global parseHeaders: false */
|
||||
|
||||
it('should parse basic', function() {
|
||||
var parsed = parseHeaders(
|
||||
@@ -849,8 +850,8 @@ describe('$http', function() {
|
||||
$http({url: '/url', method: 'POST', headers: {'S-ome': 'Header'}});
|
||||
$http({url: '/url', method: 'PUT', headers: {'Another': 'Header'}});
|
||||
$http({url: '/url', method: 'DELETE', headers: {}});
|
||||
$http({url: '/url', method: 'GET', xsrfHeaderName: 'aHeader'})
|
||||
$http({url: '/url', method: 'GET', xsrfCookieName: 'aCookie'})
|
||||
$http({url: '/url', method: 'GET', xsrfHeaderName: 'aHeader'});
|
||||
$http({url: '/url', method: 'GET', xsrfCookieName: 'aCookie'});
|
||||
|
||||
$httpBackend.flush();
|
||||
}));
|
||||
@@ -1073,8 +1074,8 @@ describe('$http', function() {
|
||||
|
||||
|
||||
it('should pipeline more functions', function() {
|
||||
function first(d, h) {return d + '-first' + ':' + h('h1')}
|
||||
function second(d) {return uppercase(d)}
|
||||
function first(d, h) {return d + '-first' + ':' + h('h1');}
|
||||
function second(d) {return uppercase(d);}
|
||||
|
||||
$httpBackend.expect('POST', '/url', 'REQ-FIRST:V1').respond(200);
|
||||
$http.post('/url', 'req', {
|
||||
@@ -1158,8 +1159,8 @@ describe('$http', function() {
|
||||
|
||||
|
||||
it('should pipeline more functions', function() {
|
||||
function first(d, h) {return d + '-first' + ':' + h('h1')}
|
||||
function second(d) {return uppercase(d)}
|
||||
function first(d, h) {return d + '-first' + ':' + h('h1');}
|
||||
function second(d) {return uppercase(d);}
|
||||
|
||||
$httpBackend.expect('POST', '/url').respond(200, 'resp', {h1: 'v1'});
|
||||
$http.post('/url', '', {transformResponse: [first, second]}).success(callback);
|
||||
@@ -1368,7 +1369,7 @@ describe('$http', function() {
|
||||
describe('$http.defaults.cache', function () {
|
||||
|
||||
it('should be undefined by default', function() {
|
||||
expect($http.defaults.cache).toBeUndefined()
|
||||
expect($http.defaults.cache).toBeUndefined();
|
||||
});
|
||||
|
||||
it('should cache requests when no cache given in request config', function() {
|
||||
@@ -1546,7 +1547,7 @@ describe('$http', function() {
|
||||
expect($http.defaults.headers.post).not.toBe($http.defaults.headers.put);
|
||||
expect($http.defaults.headers.post).not.toBe($http.defaults.headers.patch);
|
||||
expect($http.defaults.headers.put).not.toBe($http.defaults.headers.patch);
|
||||
})
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1566,7 +1567,11 @@ describe('$http', function() {
|
||||
|
||||
inject(function($http, $rootScope) {
|
||||
$http({
|
||||
method: 'GET', url: 'some.html', timeout: 12345, withCredentials: true, responseType: 'json'
|
||||
method: 'GET',
|
||||
url: 'some.html',
|
||||
timeout: 12345,
|
||||
withCredentials: true,
|
||||
responseType: 'json'
|
||||
});
|
||||
$rootScope.$digest();
|
||||
expect($httpBackend).toHaveBeenCalledOnce();
|
||||
@@ -1590,7 +1595,10 @@ describe('$http', function() {
|
||||
inject(function($http, $rootScope) {
|
||||
$http.defaults.withCredentials = true;
|
||||
$http({
|
||||
method: 'GET', url: 'some.html', timeout: 12345, responseType: 'json'
|
||||
method: 'GET',
|
||||
url: 'some.html',
|
||||
timeout: 12345,
|
||||
responseType: 'json'
|
||||
});
|
||||
$rootScope.$digest();
|
||||
expect($httpBackend).toHaveBeenCalledOnce();
|
||||
|
||||
@@ -62,7 +62,7 @@ describe('$interpolate', function() {
|
||||
|
||||
|
||||
it('should ignore undefined return value', inject(function($interpolate, $rootScope) {
|
||||
$rootScope.foo = function() {return undefined};
|
||||
$rootScope.foo = function() {return undefined;};
|
||||
expect($interpolate("Hello {{'World' + foo()}}")($rootScope)).toEqual('Hello World');
|
||||
}));
|
||||
|
||||
@@ -70,7 +70,7 @@ describe('$interpolate', function() {
|
||||
describe('interpolating in a trusted context', function() {
|
||||
var sce;
|
||||
beforeEach(function() {
|
||||
function log() {};
|
||||
function log() {}
|
||||
var fakeLog = {log: log, warn: log, info: log, error: log};
|
||||
module(function($provide, $sceProvider) {
|
||||
$provide.value('$log', fakeLog);
|
||||
@@ -106,8 +106,8 @@ describe('$interpolate', function() {
|
||||
var foo = sce.trustAsCss("foo");
|
||||
var bar = sce.trustAsCss("bar");
|
||||
expect(function() {
|
||||
return $interpolate('{{foo}}{{bar}}', true, sce.CSS)(
|
||||
{foo: foo, bar: bar}); }).toThrowMinErr(
|
||||
return $interpolate('{{foo}}{{bar}}', true, sce.CSS)({foo: foo, bar: bar});
|
||||
}).toThrowMinErr(
|
||||
"$interpolate", "noconcat", "Error while interpolating: {{foo}}{{bar}}\n" +
|
||||
"Strict Contextual Escaping disallows interpolations that concatenate multiple " +
|
||||
"expressions when a trusted value is required. See " +
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
describe('$interval', function() {
|
||||
|
||||
/* global $IntervalProvider: false */
|
||||
beforeEach(module(function($provide){
|
||||
var repeatFns = [],
|
||||
nextRepeatId = 0,
|
||||
@@ -58,7 +58,7 @@ describe('$interval', function() {
|
||||
|
||||
expect(counter).toBe(0);
|
||||
|
||||
$window.flush(1000)
|
||||
$window.flush(1000);
|
||||
expect(counter).toBe(1);
|
||||
|
||||
$window.flush(1000);
|
||||
@@ -113,7 +113,7 @@ describe('$interval', function() {
|
||||
|
||||
it('should allow you to specify a number of iterations', inject(function($interval, $window) {
|
||||
var counter = 0;
|
||||
$interval(function() {counter++}, 1000, 2);
|
||||
$interval(function() {counter++;}, 1000, 2);
|
||||
|
||||
$window.flush(1000);
|
||||
expect(counter).toBe(1);
|
||||
@@ -157,7 +157,8 @@ describe('$interval', function() {
|
||||
$window.flush(1000);
|
||||
|
||||
expect(log).toEqual([
|
||||
'tick', 'promise update: 0', 'tick', 'promise update: 1', 'promise success: 2']);
|
||||
'tick', 'promise update: 0', 'tick', 'promise update: 1', 'promise success: 2'
|
||||
]);
|
||||
|
||||
}));
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
describe('$locale', function() {
|
||||
|
||||
/* global $LocaleProvider: false */
|
||||
var $locale = new $LocaleProvider().$get();
|
||||
|
||||
it('should have locale id set to en-us', function() {
|
||||
|
||||
+23
-20
@@ -1,6 +1,6 @@
|
||||
/* global LocationHashbangUrl: false, LocationHtml5Url: false */
|
||||
'use strict';
|
||||
|
||||
|
||||
describe('$location', function() {
|
||||
var url;
|
||||
|
||||
@@ -14,6 +14,7 @@ describe('$location', function() {
|
||||
|
||||
|
||||
describe('File Protocol', function () {
|
||||
/* global urlParsingNode: true */
|
||||
var urlParsingNodePlaceholder;
|
||||
|
||||
beforeEach(inject(function ($sniffer) {
|
||||
@@ -230,7 +231,7 @@ describe('$location', function() {
|
||||
|
||||
it('should set path to forward-slash when empty', function() {
|
||||
url = new LocationHtml5Url('http://server/');
|
||||
url.$$parse('http://server/')
|
||||
url.$$parse('http://server/');
|
||||
expect(url.path()).toBe('/');
|
||||
expect(url.absUrl()).toBe('http://server/');
|
||||
});
|
||||
@@ -446,28 +447,28 @@ describe('$location', function() {
|
||||
|
||||
it('should return decoded characters for search specified with setter', function() {
|
||||
var locationUrl = new LocationHtml5Url('http://host.com/');
|
||||
locationUrl.$$parse('http://host.com/')
|
||||
locationUrl.$$parse('http://host.com/');
|
||||
locationUrl.search('q', '1/2 3');
|
||||
expect(locationUrl.search()).toEqual({'q': '1/2 3'});
|
||||
});
|
||||
|
||||
it('should return an array for duplicate params', function() {
|
||||
var locationUrl = new LocationHtml5Url('http://host.com');
|
||||
locationUrl.$$parse('http://host.com')
|
||||
locationUrl.$$parse('http://host.com');
|
||||
locationUrl.search('q', ['1/2 3','4/5 6']);
|
||||
expect(locationUrl.search()).toEqual({'q': ['1/2 3','4/5 6']});
|
||||
});
|
||||
|
||||
it('should encode an array correctly from search and add to url', function() {
|
||||
var locationUrl = new LocationHtml5Url('http://host.com');
|
||||
locationUrl.$$parse('http://host.com')
|
||||
locationUrl.$$parse('http://host.com');
|
||||
locationUrl.search({'q': ['1/2 3','4/5 6']});
|
||||
expect(locationUrl.absUrl()).toEqual('http://host.com?q=1%2F2%203&q=4%2F5%206');
|
||||
});
|
||||
|
||||
it('should rewrite params when specifing a single param in search', function() {
|
||||
var locationUrl = new LocationHtml5Url('http://host.com');
|
||||
locationUrl.$$parse('http://host.com')
|
||||
locationUrl.$$parse('http://host.com');
|
||||
locationUrl.search({'q': '1/2 3'});
|
||||
expect(locationUrl.absUrl()).toEqual('http://host.com?q=1%2F2%203');
|
||||
locationUrl.search({'q': '4/5 6'});
|
||||
@@ -756,7 +757,7 @@ describe('$location', function() {
|
||||
});
|
||||
|
||||
describe('PATH_MATCH', function() {
|
||||
|
||||
/* global PATH_MATCH: false */
|
||||
it('should parse just path', function() {
|
||||
var match = PATH_MATCH.exec('/path');
|
||||
expect(match[1]).toBe('/path');
|
||||
@@ -1129,7 +1130,7 @@ describe('$location', function() {
|
||||
|
||||
|
||||
// don't run next tests on IE<9, as browserTrigger does not simulate pressed keys
|
||||
if (!(msie < 9)) {
|
||||
if (!msie || msie >= 9) {
|
||||
|
||||
it('should not rewrite when clicked with ctrl pressed', function() {
|
||||
configureService('/a?b=c', true, true);
|
||||
@@ -1163,10 +1164,10 @@ describe('$location', function() {
|
||||
module(function() {
|
||||
return function($browser) {
|
||||
window.location.hash = 'someHash';
|
||||
base = window.location.href
|
||||
base = window.location.href;
|
||||
$browser.url(base);
|
||||
base = base.split('#')[0];
|
||||
}
|
||||
};
|
||||
});
|
||||
inject(function($rootScope, $compile, $browser, $rootElement, $document, $location) {
|
||||
// we need to do this otherwise we can't simulate events
|
||||
@@ -1198,7 +1199,7 @@ describe('$location', function() {
|
||||
$browser.url(base = window.location.href);
|
||||
base = base.split('#')[0];
|
||||
$locationProvider.hashPrefix('!');
|
||||
}
|
||||
};
|
||||
});
|
||||
inject(function($rootScope, $compile, $browser, $rootElement, $document, $location) {
|
||||
// we need to do this otherwise we can't simulate events
|
||||
@@ -1231,7 +1232,7 @@ describe('$location', function() {
|
||||
});
|
||||
return function($browser) {
|
||||
$browser.url(base = 'http://server/');
|
||||
}
|
||||
};
|
||||
});
|
||||
inject(function($location) {
|
||||
// make IE happy
|
||||
@@ -1261,7 +1262,7 @@ describe('$location', function() {
|
||||
});
|
||||
return function($browser) {
|
||||
$browser.url(base = 'http://server/');
|
||||
}
|
||||
};
|
||||
});
|
||||
inject(function($rootScope, $compile, $browser, $rootElement, $document, $location) {
|
||||
// make IE happy
|
||||
@@ -1302,7 +1303,7 @@ describe('$location', function() {
|
||||
$browser.url(base = window.location.href);
|
||||
base = base.split('#')[0];
|
||||
$locationProvider.hashPrefix('!');
|
||||
}
|
||||
};
|
||||
});
|
||||
inject(function($rootScope, $compile, $browser, $rootElement, $document, $location) {
|
||||
// we need to do this otherwise we can't simulate events
|
||||
@@ -1357,7 +1358,7 @@ describe('$location', function() {
|
||||
event.preventDefault();
|
||||
});
|
||||
$rootScope.$on('$locationChangeSuccess', function(event, newUrl, oldUrl) {
|
||||
throw Error('location should have been canceled');
|
||||
throw new Error('location should have been canceled');
|
||||
});
|
||||
|
||||
expect($location.url()).toEqual('');
|
||||
@@ -1407,7 +1408,7 @@ describe('$location', function() {
|
||||
$rootElement.html('<a href="http://server/#/somePath">link</a>');
|
||||
$compile($rootElement)($rootScope);
|
||||
jqLite(document.body).append($rootElement);
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
inject(function($location, $rootScope, $browser, $rootElement) {
|
||||
@@ -1440,7 +1441,7 @@ describe('$location', function() {
|
||||
$rootElement.html('<a href="http://server/somePath">link</a>');
|
||||
$compile($rootElement)($rootScope);
|
||||
jqLite(document.body).append($rootElement);
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
inject(function($location, $rootScope, $browser, $rootElement) {
|
||||
@@ -1516,6 +1517,7 @@ describe('$location', function() {
|
||||
var location;
|
||||
|
||||
it('should rewrite URL', function() {
|
||||
/* jshint scripturl: true */
|
||||
location = new LocationHashbangUrl('http://server/pre/', '#');
|
||||
|
||||
expect(location.$$rewrite('http://other')).toEqual(undefined);
|
||||
@@ -1527,7 +1529,7 @@ describe('$location', function() {
|
||||
it("should not set hash if one was not originally specified", function() {
|
||||
location = new LocationHashbangUrl('http://server/pre/index.html', '#');
|
||||
|
||||
location.$$parse('http://server/pre/index.html')
|
||||
location.$$parse('http://server/pre/index.html');
|
||||
expect(location.url()).toBe('');
|
||||
expect(location.absUrl()).toBe('http://server/pre/index.html');
|
||||
});
|
||||
@@ -1535,7 +1537,7 @@ describe('$location', function() {
|
||||
it("should parse hash if one was specified", function() {
|
||||
location = new LocationHashbangUrl('http://server/pre/index.html', '#');
|
||||
|
||||
location.$$parse('http://server/pre/index.html#/foo/bar')
|
||||
location.$$parse('http://server/pre/index.html#/foo/bar');
|
||||
expect(location.url()).toBe('/foo/bar');
|
||||
expect(location.absUrl()).toBe('http://server/pre/index.html#/foo/bar');
|
||||
});
|
||||
@@ -1544,7 +1546,7 @@ describe('$location', function() {
|
||||
it("should prefix hash url with / if one was originally missing", function() {
|
||||
location = new LocationHashbangUrl('http://server/pre/index.html', '#');
|
||||
|
||||
location.$$parse('http://server/pre/index.html#not-starting-with-slash')
|
||||
location.$$parse('http://server/pre/index.html#not-starting-with-slash');
|
||||
expect(location.url()).toBe('/not-starting-with-slash');
|
||||
expect(location.absUrl()).toBe('http://server/pre/index.html#/not-starting-with-slash');
|
||||
});
|
||||
@@ -1562,6 +1564,7 @@ describe('$location', function() {
|
||||
|
||||
|
||||
describe('LocationHashbangInHtml5Url', function() {
|
||||
/* global LocationHashbangInHtml5Url: false */
|
||||
var location, locationIndex;
|
||||
|
||||
beforeEach(function() {
|
||||
|
||||
+18
-17
@@ -1,3 +1,4 @@
|
||||
/* global $LogProvider: false */
|
||||
'use strict';
|
||||
|
||||
function initService(debugEnabled) {
|
||||
@@ -118,24 +119,24 @@ describe('$log', function() {
|
||||
|
||||
describe("$log.debug", function () {
|
||||
|
||||
beforeEach(initService(false));
|
||||
beforeEach(initService(false));
|
||||
|
||||
it("should skip debugging output if disabled", inject(
|
||||
function(){
|
||||
$window.console = {log: log,
|
||||
warn: warn,
|
||||
info: info,
|
||||
error: error,
|
||||
debug: debug};
|
||||
},
|
||||
function($log) {
|
||||
$log.log();
|
||||
$log.warn();
|
||||
$log.info();
|
||||
$log.error();
|
||||
$log.debug();
|
||||
expect(logger).toEqual('log;warn;info;error;');
|
||||
}
|
||||
it("should skip debugging output if disabled", inject(
|
||||
function(){
|
||||
$window.console = {log: log,
|
||||
warn: warn,
|
||||
info: info,
|
||||
error: error,
|
||||
debug: debug};
|
||||
},
|
||||
function($log) {
|
||||
$log.log();
|
||||
$log.warn();
|
||||
$log.info();
|
||||
$log.error();
|
||||
$log.debug();
|
||||
expect(logger).toEqual('log;warn;info;error;');
|
||||
}
|
||||
));
|
||||
|
||||
});
|
||||
|
||||
+11
-6
@@ -3,6 +3,7 @@
|
||||
describe('parser', function() {
|
||||
|
||||
beforeEach(function() {
|
||||
/* global getterFnCache: true, promiseWarningCache: true */
|
||||
// clear caches
|
||||
getterFnCache = {};
|
||||
promiseWarningCache = {};
|
||||
@@ -13,6 +14,7 @@ describe('parser', function() {
|
||||
var lex;
|
||||
|
||||
beforeEach(function () {
|
||||
/* global Lexer: false */
|
||||
lex = function () {
|
||||
var lexer = new Lexer({csp: false, unwrapPromises: false});
|
||||
return lexer.lex.apply(lexer, arguments);
|
||||
@@ -225,6 +227,7 @@ describe('parser', function() {
|
||||
}));
|
||||
|
||||
it('should parse expressions', function() {
|
||||
/*jshint -W006, -W007 */
|
||||
expect(scope.$eval("-1")).toEqual(-1);
|
||||
expect(scope.$eval("1 + 2.5")).toEqual(3.5);
|
||||
expect(scope.$eval("1 + -2.5")).toEqual(-1.5);
|
||||
@@ -235,6 +238,7 @@ describe('parser', function() {
|
||||
});
|
||||
|
||||
it('should parse comparison', function() {
|
||||
/* jshint -W041 */
|
||||
expect(scope.$eval("false")).toBeFalsy();
|
||||
expect(scope.$eval("!true")).toBeFalsy();
|
||||
expect(scope.$eval("1==1")).toBeTruthy();
|
||||
@@ -367,11 +371,11 @@ describe('parser', function() {
|
||||
// Assign to x1 and build path 'x1.x2.x3. ... .x[n]' to access the final value.
|
||||
scope.x1 = obj;
|
||||
var path = 'x1';
|
||||
for (var i = 2; i <= pathLength; i++) {
|
||||
for (i = 2; i <= pathLength; i++) {
|
||||
path += '.x' + i;
|
||||
}
|
||||
expect(scope.$eval(path)).toBe(42);
|
||||
locals['x' + pathLength] = 'not 42'
|
||||
locals['x' + pathLength] = 'not 42';
|
||||
expect(scope.$eval(path, locals)).toBe(42);
|
||||
});
|
||||
});
|
||||
@@ -444,7 +448,7 @@ describe('parser', function() {
|
||||
|
||||
it('should evaluate function call from a return value', function() {
|
||||
scope.val = 33;
|
||||
scope.getter = function() { return function() { return this.val; }};
|
||||
scope.getter = function() { return function() { return this.val; }; };
|
||||
expect(scope.$eval("getter()()")).toBe(33);
|
||||
});
|
||||
|
||||
@@ -580,6 +584,7 @@ describe('parser', function() {
|
||||
});
|
||||
|
||||
it('should evaluate negation', function() {
|
||||
/* jshint -W018 */
|
||||
expect(scope.$eval("!false || true")).toEqual(!false || true);
|
||||
expect(scope.$eval("!11 == 10")).toEqual(!11 == 10);
|
||||
expect(scope.$eval("12/6/2")).toEqual(12/6/2);
|
||||
@@ -709,7 +714,7 @@ describe('parser', function() {
|
||||
'Expression: $eval.call()');
|
||||
|
||||
expect(function() {
|
||||
scope.$eval('fn()')
|
||||
scope.$eval('fn()');
|
||||
}).toThrowMinErr(
|
||||
'$parse', 'isecff', 'Referencing call, apply or bind in Angular expressions is disallowed! ' +
|
||||
'Expression: fn()');
|
||||
@@ -976,9 +981,9 @@ describe('parser', function() {
|
||||
'null,' +
|
||||
'"alert(1)"' +
|
||||
')()' +
|
||||
'')
|
||||
'');
|
||||
}).toThrow();
|
||||
})
|
||||
});
|
||||
});
|
||||
|
||||
it('should call the function from the received instance and not from a new one', function() {
|
||||
|
||||
+31
-29
@@ -72,7 +72,7 @@ describe('q', function() {
|
||||
name = 'success' + (name || '');
|
||||
return function() {
|
||||
return _logInvocation(name, arguments, (returnValDefined ? returnVal : arguments[0]), throwReturnVal);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -88,7 +88,7 @@ describe('q', function() {
|
||||
name = 'finally' + (name || '');
|
||||
return function() {
|
||||
return _logInvocation(name, arguments, (returnValDefined ? returnVal : arguments[0]), throwReturnVal);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -104,7 +104,7 @@ describe('q', function() {
|
||||
name = 'progress' + (name || '');
|
||||
return function() {
|
||||
return _logInvocation(name, arguments, (returnValDefined ? returnVal : arguments[0]), throwReturnVal);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -125,7 +125,7 @@ describe('q', function() {
|
||||
} else {
|
||||
return _logInvocation(name, arguments, returnVal, throwReturnVal);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/** helper for synchronous resolution of deferred */
|
||||
@@ -177,13 +177,14 @@ describe('q', function() {
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
beforeEach(function() {
|
||||
/* global qFactory: false */
|
||||
q = qFactory(mockNextTick.nextTick, noop),
|
||||
defer = q.defer;
|
||||
deferred = defer()
|
||||
deferred = defer();
|
||||
promise = deferred.promise;
|
||||
log = [];
|
||||
mockNextTick.queue = [];
|
||||
@@ -343,7 +344,7 @@ describe('q', function() {
|
||||
expect(mockNextTick.queue.length).toBe(0);
|
||||
expect(logStr()).toBe('');
|
||||
|
||||
promise.then(success(2), error(2))
|
||||
promise.then(success(2), error(2));
|
||||
expect(logStr()).toBe('');
|
||||
mockNextTick.flush();
|
||||
expect(logStr()).toBe('success2(foo)->foo');
|
||||
@@ -364,7 +365,7 @@ describe('q', function() {
|
||||
expect(mockNextTick.queue.length).toBe(0);
|
||||
expect(logStr()).toBe('');
|
||||
|
||||
promise.then(success(2), error(2))
|
||||
promise.then(success(2), error(2));
|
||||
expect(logStr()).toBe('');
|
||||
mockNextTick.flush();
|
||||
expect(logStr()).toBe('error2(foo)->reject(foo)');
|
||||
@@ -442,7 +443,7 @@ describe('q', function() {
|
||||
log = [];
|
||||
deferred.reject('bar');
|
||||
deferred.resolve('baz');
|
||||
deferred.notify('qux')
|
||||
deferred.notify('qux');
|
||||
expect(mockNextTick.queue.length).toBe(0);
|
||||
expect(logStr()).toBe('');
|
||||
|
||||
@@ -769,7 +770,7 @@ describe('q', function() {
|
||||
|
||||
it('should not take an argument',
|
||||
function() {
|
||||
promise['finally'](fin(1))
|
||||
promise['finally'](fin(1));
|
||||
syncResolve(deferred, 'foo');
|
||||
expect(logStr()).toBe('finally1()');
|
||||
});
|
||||
@@ -778,7 +779,7 @@ describe('q', function() {
|
||||
|
||||
it('should call the callback',
|
||||
function() {
|
||||
promise.then(success(1))['finally'](fin(1))
|
||||
promise.then(success(1))['finally'](fin(1));
|
||||
syncResolve(deferred, 'foo');
|
||||
expect(logStr()).toBe('success1(foo)->foo; finally1()');
|
||||
});
|
||||
@@ -800,7 +801,7 @@ describe('q', function() {
|
||||
then(success('BB', 'bb'), error('BB'));
|
||||
promise.then(success('C', 'c'), error('C'))['finally'](fin('CC', 'IGNORED'))
|
||||
.then(success('CCC', 'cc'), error('CCC'))
|
||||
.then(success('CCCC', 'ccc'), error('CCCC'))
|
||||
.then(success('CCCC', 'ccc'), error('CCCC'));
|
||||
syncResolve(deferred, 'RESOLVED_VAL');
|
||||
|
||||
expect(log).toEqual(['successA(RESOLVED_VAL)->a',
|
||||
@@ -822,7 +823,7 @@ describe('q', function() {
|
||||
returnedDef.resolve('bar');
|
||||
|
||||
promise['finally'](fin(1, returnedDef.promise))
|
||||
.then(success(2))
|
||||
.then(success(2));
|
||||
|
||||
syncResolve(deferred, 'foo');
|
||||
|
||||
@@ -833,10 +834,10 @@ describe('q', function() {
|
||||
describe("that is rejected", function() {
|
||||
it("should reject with this new rejection reason",
|
||||
function () {
|
||||
var returnedDef = defer()
|
||||
var returnedDef = defer();
|
||||
returnedDef.reject('bar');
|
||||
promise['finally'](fin(1, returnedDef.promise))
|
||||
.then(success(2), error(1))
|
||||
.then(success(2), error(1));
|
||||
syncResolve(deferred, 'foo');
|
||||
expect(logStr()).toBe('finally1()->{}; error1(bar)->reject(bar)');
|
||||
});
|
||||
@@ -847,7 +848,7 @@ describe('q', function() {
|
||||
describe("when the callback throws an exception", function() {
|
||||
it("should reject with this new exception", function() {
|
||||
promise['finally'](fin(1, "exception", true))
|
||||
.then(success(1), error(2))
|
||||
.then(success(1), error(2));
|
||||
syncResolve(deferred, 'foo');
|
||||
expect(logStr()).toBe('finally1()->throw(exception); error2(exception)->reject(exception)');
|
||||
});
|
||||
@@ -860,14 +861,14 @@ describe('q', function() {
|
||||
|
||||
it("should call the callback", function () {
|
||||
promise['finally'](fin(1))
|
||||
.then(success(2), error(1))
|
||||
.then(success(2), error(1));
|
||||
syncReject(deferred, 'foo');
|
||||
expect(logStr()).toBe('finally1(); error1(foo)->reject(foo)');
|
||||
});
|
||||
|
||||
it('should reject with the original reason', function() {
|
||||
promise['finally'](fin(1), "hello")
|
||||
.then(success(2), error(2))
|
||||
.then(success(2), error(2));
|
||||
syncReject(deferred, 'original');
|
||||
expect(logStr()).toBe('finally1(); error2(original)->reject(original)');
|
||||
});
|
||||
@@ -877,10 +878,10 @@ describe('q', function() {
|
||||
describe("that is fulfilled", function() {
|
||||
|
||||
it("should reject with the original reason after that promise resolves", function () {
|
||||
var returnedDef = defer()
|
||||
var returnedDef = defer();
|
||||
returnedDef.resolve('bar');
|
||||
promise['finally'](fin(1, returnedDef.promise))
|
||||
.then(success(2), error(2))
|
||||
.then(success(2), error(2));
|
||||
syncReject(deferred, 'original');
|
||||
expect(logStr()).toBe('finally1()->{}; error2(original)->reject(original)');
|
||||
});
|
||||
@@ -890,10 +891,10 @@ describe('q', function() {
|
||||
describe("that is rejected", function () {
|
||||
|
||||
it("should reject with the new reason", function() {
|
||||
var returnedDef = defer()
|
||||
var returnedDef = defer();
|
||||
returnedDef.reject('bar');
|
||||
promise['finally'](fin(1, returnedDef.promise))
|
||||
.then(success(2), error(1))
|
||||
.then(success(2), error(1));
|
||||
syncResolve(deferred, 'foo');
|
||||
expect(logStr()).toBe('finally1()->{}; error1(bar)->reject(bar)');
|
||||
});
|
||||
@@ -906,7 +907,7 @@ describe('q', function() {
|
||||
|
||||
it("should reject with this new exception", function() {
|
||||
promise['finally'](fin(1, "exception", true))
|
||||
.then(success(1), error(2))
|
||||
.then(success(1), error(2));
|
||||
syncResolve(deferred, 'foo');
|
||||
expect(logStr()).toBe('finally1()->throw(exception); error2(exception)->reject(exception)');
|
||||
});
|
||||
@@ -918,7 +919,7 @@ describe('q', function() {
|
||||
|
||||
describe('catch', function() {
|
||||
it('should be a shorthand for defining promise error handlers', function() {
|
||||
promise['catch'](error(1)).then(null, error(2))
|
||||
promise['catch'](error(1)).then(null, error(2));
|
||||
syncReject(deferred, 'foo');
|
||||
expect(logStr()).toBe('error1(foo)->reject(foo); error2(foo)->reject(foo)');
|
||||
});
|
||||
@@ -937,7 +938,7 @@ describe('q', function() {
|
||||
|
||||
|
||||
it('should package an exception into a rejected promise', function() {
|
||||
var rejectedPromise = q.reject(Error('not gonna happen'));
|
||||
var rejectedPromise = q.reject(new Error('not gonna happen'));
|
||||
promise.then(success(), error());
|
||||
syncResolve(deferred, rejectedPromise);
|
||||
expect(log).toEqual(['error(Error: not gonna happen)->reject(Error: not gonna happen)']);
|
||||
@@ -955,7 +956,7 @@ describe('q', function() {
|
||||
it('should catch exceptions thrown in errback and forward them to derived promises', function() {
|
||||
var rejectedPromise = q.reject('rejected');
|
||||
rejectedPromise.then(null, error('Broken', 'catch me!', true)).
|
||||
then(null, error('Affected'))
|
||||
then(null, error('Affected'));
|
||||
mockNextTick.flush();
|
||||
expect(log).toEqual(['errorBroken(rejected)->throw(catch me!)', 'errorAffected(catch me!)->reject(catch me!)']);
|
||||
});
|
||||
@@ -1355,13 +1356,13 @@ describe('q', function() {
|
||||
logger: function(e) {
|
||||
mockExceptionLogger.log.push(e);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
beforeEach(function() {
|
||||
q = qFactory(mockNextTick.nextTick, mockExceptionLogger.logger),
|
||||
defer = q.defer;
|
||||
deferred = defer()
|
||||
deferred = defer();
|
||||
promise = deferred.promise;
|
||||
log = [];
|
||||
mockExceptionLogger.log = [];
|
||||
@@ -1413,7 +1414,8 @@ describe('q', function() {
|
||||
log = [];
|
||||
syncResolve(deferred, 'ok');
|
||||
expect(logStr()).toBe('success(ok)->ok');
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
|
||||
+1
-1
@@ -27,7 +27,7 @@ describe('$$rAF', function() {
|
||||
|
||||
try {
|
||||
$$rAF.flush();
|
||||
} catch(e) {};
|
||||
} catch(e) {}
|
||||
expect(present).toBe(true);
|
||||
}));
|
||||
|
||||
|
||||
+26
-22
@@ -13,6 +13,7 @@ describe('Scope', function() {
|
||||
|
||||
|
||||
it('should expose the constructor', inject(function($rootScope) {
|
||||
/* jshint -W103 */
|
||||
if (msie) return;
|
||||
expect($rootScope.__proto__).toBe($rootScope.constructor.prototype);
|
||||
}));
|
||||
@@ -251,7 +252,7 @@ describe('Scope', function() {
|
||||
|
||||
try {
|
||||
$rootScope.$digest();
|
||||
throw Error('Should have thrown exception');
|
||||
throw new Error('Should have thrown exception');
|
||||
} catch(e) {
|
||||
expect(e.message.match(/"fn: (watcherA|function)/g).length).toBe(10);
|
||||
}
|
||||
@@ -260,27 +261,27 @@ describe('Scope', function() {
|
||||
|
||||
it('should prevent infinite loop when creating and resolving a promise in a watched expression', function() {
|
||||
module(function($rootScopeProvider) {
|
||||
$rootScopeProvider.digestTtl(10);
|
||||
$rootScopeProvider.digestTtl(10);
|
||||
});
|
||||
inject(function($rootScope, $q) {
|
||||
var d = $q.defer();
|
||||
var d = $q.defer();
|
||||
|
||||
d.resolve('Hello, world.');
|
||||
$rootScope.$watch(function () {
|
||||
var $d2 = $q.defer();
|
||||
$d2.resolve('Goodbye.');
|
||||
$d2.promise.then(function () { });
|
||||
return d.promise;
|
||||
}, function () { return 0; });
|
||||
d.resolve('Hello, world.');
|
||||
$rootScope.$watch(function () {
|
||||
var $d2 = $q.defer();
|
||||
$d2.resolve('Goodbye.');
|
||||
$d2.promise.then(function () { });
|
||||
return d.promise;
|
||||
}, function () { return 0; });
|
||||
|
||||
expect(function() {
|
||||
$rootScope.$digest();
|
||||
}).toThrowMinErr('$rootScope', 'infdig', '10 $digest() iterations reached. Aborting!\n'+
|
||||
'Watchers fired in the last 5 iterations: []');
|
||||
expect(function() {
|
||||
$rootScope.$digest();
|
||||
}).toThrowMinErr('$rootScope', 'infdig', '10 $digest() iterations reached. Aborting!\n'+
|
||||
'Watchers fired in the last 5 iterations: []');
|
||||
|
||||
expect($rootScope.$$phase).toBeNull();
|
||||
});
|
||||
expect($rootScope.$$phase).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
it('should not fire upon $watch registration on initial $digest', inject(function($rootScope) {
|
||||
@@ -748,7 +749,7 @@ describe('Scope', function() {
|
||||
$rootScope.$watch(log.fn('w4'), function() {
|
||||
log('w4action');
|
||||
$rootScope.$evalAsync(function() {
|
||||
log('evalAsync')
|
||||
log('evalAsync');
|
||||
});
|
||||
});
|
||||
$rootScope.$digest();
|
||||
@@ -1067,7 +1068,8 @@ describe('Scope', function() {
|
||||
expect($rootScope.$$asyncQueue).toEqual([
|
||||
{scope: $rootScope, expression: 'rootExpression'},
|
||||
{scope: childScope, expression: 'childExpression'},
|
||||
{scope: isolateScope, expression: 'isolateExpression'}]);
|
||||
{scope: isolateScope, expression: 'isolateExpression'}
|
||||
]);
|
||||
}));
|
||||
|
||||
|
||||
@@ -1247,9 +1249,11 @@ describe('Scope', function() {
|
||||
});
|
||||
});
|
||||
|
||||
expect(function() { childScope2.$apply(function() {
|
||||
childScope2.x = 'something';
|
||||
}); }).toThrowMinErr('$rootScope', 'inprog', '$digest already in progress');
|
||||
expect(function() {
|
||||
childScope2.$apply(function() {
|
||||
childScope2.x = 'something';
|
||||
});
|
||||
}).toThrowMinErr('$rootScope', 'inprog', '$digest already in progress');
|
||||
}));
|
||||
});
|
||||
});
|
||||
@@ -1668,7 +1672,7 @@ describe('Scope', function() {
|
||||
expect(scope.greeting).toEqual(undefined);
|
||||
|
||||
scope.$watch('name', function() {
|
||||
scope.greeting = scope.salutation + ' ' + scope.name + '!';
|
||||
scope.greeting = scope.salutation + ' ' + scope.name + '!';
|
||||
}); // initialize the watch
|
||||
|
||||
expect(scope.greeting).toEqual(undefined);
|
||||
|
||||
@@ -12,7 +12,7 @@ describe('sanitizeUri', function() {
|
||||
};
|
||||
sanitizeImg = function(uri) {
|
||||
return $$sanitizeUri(uri, true);
|
||||
}
|
||||
};
|
||||
});
|
||||
});
|
||||
|
||||
@@ -25,6 +25,7 @@ describe('sanitizeUri', function() {
|
||||
describe('img[src] sanitization', function() {
|
||||
|
||||
it('should sanitize javascript: urls', function() {
|
||||
/* jshint scripturl:true */
|
||||
testUrl = "javascript:doEvilStuff()";
|
||||
expect(sanitizeImg(testUrl)).toBe('unsafe:javascript:doEvilStuff()');
|
||||
});
|
||||
@@ -50,6 +51,7 @@ describe('sanitizeUri', function() {
|
||||
});
|
||||
|
||||
it('should sanitize obfuscated javascript: urls', function() {
|
||||
/* jshint scripturl:true */
|
||||
// case-sensitive
|
||||
testUrl = "JaVaScRiPt:doEvilStuff()";
|
||||
expect(sanitizeImg(testUrl)).toBe('unsafe:javascript:doEvilStuff()');
|
||||
@@ -79,6 +81,7 @@ describe('sanitizeUri', function() {
|
||||
});
|
||||
|
||||
it('should sanitize ng-src bindings as well', function() {
|
||||
/* jshint scripturl:true */
|
||||
testUrl = "javascript:doEvilStuff()";
|
||||
expect(sanitizeImg(testUrl)).toBe('unsafe:javascript:doEvilStuff()');
|
||||
});
|
||||
@@ -115,6 +118,7 @@ describe('sanitizeUri', function() {
|
||||
|
||||
|
||||
it('should allow reconfiguration of the src whitelist', function() {
|
||||
/* jshint scripturl:true */
|
||||
var returnVal;
|
||||
expect(sanitizeUriProvider.imgSrcSanitizationWhitelist() instanceof RegExp).toBe(true);
|
||||
returnVal = sanitizeUriProvider.imgSrcSanitizationWhitelist(/javascript:/);
|
||||
@@ -133,6 +137,7 @@ describe('sanitizeUri', function() {
|
||||
describe('a[href] sanitization', function() {
|
||||
|
||||
it('should sanitize javascript: urls', inject(function() {
|
||||
/* jshint scripturl:true */
|
||||
testUrl = "javascript:doEvilStuff()";
|
||||
expect(sanitizeHref(testUrl)).toBe('unsafe:javascript:doEvilStuff()');
|
||||
}));
|
||||
@@ -145,6 +150,7 @@ describe('sanitizeUri', function() {
|
||||
|
||||
|
||||
it('should sanitize obfuscated javascript: urls', inject(function() {
|
||||
/* jshint scripturl:true */
|
||||
// case-sensitive
|
||||
testUrl = "JaVaScRiPt:doEvilStuff()";
|
||||
expect(sanitizeHref(testUrl)).toBe('unsafe:javascript:doEvilStuff()');
|
||||
@@ -175,6 +181,7 @@ describe('sanitizeUri', function() {
|
||||
|
||||
|
||||
it('should sanitize ngHref bindings as well', inject(function() {
|
||||
/* jshint scripturl:true */
|
||||
testUrl = "javascript:doEvilStuff()";
|
||||
expect(sanitizeHref(testUrl)).toBe('unsafe:javascript:doEvilStuff()');
|
||||
}));
|
||||
@@ -213,16 +220,17 @@ describe('sanitizeUri', function() {
|
||||
}));
|
||||
|
||||
it('should allow reconfiguration of the href whitelist', function() {
|
||||
/* jshint scripturl:true */
|
||||
var returnVal;
|
||||
expect(sanitizeUriProvider.aHrefSanitizationWhitelist() instanceof RegExp).toBe(true);
|
||||
returnVal = sanitizeUriProvider.aHrefSanitizationWhitelist(/javascript:/);
|
||||
expect(returnVal).toBe(sanitizeUriProvider);
|
||||
|
||||
testUrl = "javascript:doEvilStuff()";
|
||||
expect(sanitizeHref(testUrl)).toBe('javascript:doEvilStuff()');
|
||||
expect(sanitizeHref(testUrl)).toBe('javascript:doEvilStuff()');
|
||||
|
||||
testUrl = "http://recon/figured";
|
||||
expect(sanitizeHref(testUrl)).toBe('unsafe:http://recon/figured');
|
||||
expect(sanitizeHref(testUrl)).toBe('unsafe:http://recon/figured');
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
+33
-20
@@ -38,6 +38,7 @@ describe('SCE', function() {
|
||||
|
||||
inject(function($window, $injector) {
|
||||
function constructSce() {
|
||||
/* global $SceProvider: false */
|
||||
var sceProvider = new $SceProvider();
|
||||
sceProvider.enabled(enabled);
|
||||
return $injector.invoke(sceProvider.$get, sceProvider);
|
||||
@@ -162,7 +163,7 @@ describe('SCE', function() {
|
||||
};
|
||||
}
|
||||
var wrappedValue = new TrustedValueHolder("originalValue");
|
||||
expect(function() { return $sce.getTrusted($sce.HTML, wrappedValue) }).toThrowMinErr(
|
||||
expect(function() { return $sce.getTrusted($sce.HTML, wrappedValue); }).toThrowMinErr(
|
||||
'$sce', 'unsafe', 'Attempting to use an unsafe value in a safe context.');
|
||||
}));
|
||||
|
||||
@@ -179,9 +180,9 @@ describe('SCE', function() {
|
||||
it('should override the default $sce.trustAs/valueOf/etc.', function() {
|
||||
module(function($provide) {
|
||||
$provide.value('$sceDelegate', {
|
||||
trustAs: function(type, value) { return "wrapped:" + value; },
|
||||
getTrusted: function(type, value) { return "unwrapped:" + value; },
|
||||
valueOf: function(value) { return "valueOf:" + value; }
|
||||
trustAs: function(type, value) { return "wrapped:" + value; },
|
||||
getTrusted: function(type, value) { return "unwrapped:" + value; },
|
||||
valueOf: function(value) { return "valueOf:" + value; }
|
||||
});
|
||||
});
|
||||
|
||||
@@ -196,7 +197,7 @@ describe('SCE', function() {
|
||||
|
||||
|
||||
describe('$sce.parseAs', function($sce) {
|
||||
it('should parse constant literals as trusted', inject(function($sce) {
|
||||
it('should parse constant literals as trusted', inject(function($sce) {
|
||||
expect($sce.parseAsJs('1')()).toBe(1);
|
||||
expect($sce.parseAsJs('1', $sce.ANY)()).toBe(1);
|
||||
expect($sce.parseAsJs('1', $sce.HTML)()).toBe(1);
|
||||
@@ -218,7 +219,7 @@ describe('SCE', function() {
|
||||
it('should NOT return untrusted values from expression function', inject(function($sce) {
|
||||
var exprFn = $sce.parseAs($sce.HTML, 'foo');
|
||||
expect(function() {
|
||||
return exprFn({}, {'foo': true})
|
||||
return exprFn({}, {'foo': true});
|
||||
}).toThrowMinErr(
|
||||
'$sce', 'unsafe', 'Attempting to use an unsafe value in a safe context.');
|
||||
}));
|
||||
@@ -226,7 +227,7 @@ describe('SCE', function() {
|
||||
it('should NOT return trusted values of the wrong type from expression function', inject(function($sce) {
|
||||
var exprFn = $sce.parseAs($sce.HTML, 'foo');
|
||||
expect(function() {
|
||||
return exprFn({}, {'foo': $sce.trustAs($sce.JS, '123')})
|
||||
return exprFn({}, {'foo': $sce.trustAs($sce.JS, '123')});
|
||||
}).toThrowMinErr(
|
||||
'$sce', 'unsafe', 'Attempting to use an unsafe value in a safe context.');
|
||||
}));
|
||||
@@ -262,11 +263,11 @@ describe('SCE', function() {
|
||||
}
|
||||
});
|
||||
inject(testFn);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
it('should default to "self" which allows relative urls', runTest({}, function($sce, $document) {
|
||||
expect($sce.getTrustedResourceUrl('foo/bar')).toEqual('foo/bar');
|
||||
expect($sce.getTrustedResourceUrl('foo/bar')).toEqual('foo/bar');
|
||||
}));
|
||||
|
||||
it('should reject everything when whitelist is empty', runTest(
|
||||
@@ -276,7 +277,8 @@ describe('SCE', function() {
|
||||
}, function($sce) {
|
||||
expect(function() { $sce.getTrustedResourceUrl('#'); }).toThrowMinErr(
|
||||
'$sce', 'insecurl', 'Blocked loading resource from url not allowed by $sceDelegate policy. URL: #');
|
||||
}));
|
||||
}
|
||||
));
|
||||
|
||||
it('should match against normalized urls', runTest(
|
||||
{
|
||||
@@ -285,7 +287,8 @@ describe('SCE', function() {
|
||||
}, function($sce) {
|
||||
expect(function() { $sce.getTrustedResourceUrl('foo'); }).toThrowMinErr(
|
||||
'$sce', 'insecurl', 'Blocked loading resource from url not allowed by $sceDelegate policy. URL: foo');
|
||||
}));
|
||||
}
|
||||
));
|
||||
|
||||
it('should not accept unknown matcher type', function() {
|
||||
expect(function() {
|
||||
@@ -296,6 +299,7 @@ describe('SCE', function() {
|
||||
});
|
||||
|
||||
describe('adjustMatcher', function() {
|
||||
/* global adjustMatcher: false */
|
||||
it('should rewrite regex into regex and add ^ & $ on either end', function() {
|
||||
expect(adjustMatcher(/a.*b/).exec('a.b')).not.toBeNull();
|
||||
expect(adjustMatcher(/a.*b/).exec('-a.b-')).toBeNull();
|
||||
@@ -318,7 +322,8 @@ describe('SCE', function() {
|
||||
// https doesn't match (mismatched protocol.)
|
||||
expect(function() { $sce.getTrustedResourceUrl('https://example.com/foo'); }).toThrowMinErr(
|
||||
'$sce', 'insecurl', 'Blocked loading resource from url not allowed by $sceDelegate policy. URL: https://example.com/foo');
|
||||
}));
|
||||
}
|
||||
));
|
||||
|
||||
it('should match entire regex', runTest(
|
||||
{
|
||||
@@ -335,7 +340,8 @@ describe('SCE', function() {
|
||||
// Prefix not allowed even though original regex does not contain a leading ^.
|
||||
expect(function() { $sce.getTrustedResourceUrl('xhttp://example.com/foo'); }).toThrowMinErr(
|
||||
'$sce', 'insecurl', 'Blocked loading resource from url not allowed by $sceDelegate policy. URL: xhttp://example.com/foo');
|
||||
}));
|
||||
}
|
||||
));
|
||||
});
|
||||
|
||||
describe('string matchers', function() {
|
||||
@@ -354,7 +360,8 @@ describe('SCE', function() {
|
||||
// You can match a suffix.
|
||||
expect(function() { $sce.getTrustedResourceUrl('xhttp://example.com/foo'); }).toThrowMinErr(
|
||||
'$sce', 'insecurl', 'Blocked loading resource from url not allowed by $sceDelegate policy. URL: xhttp://example.com/foo');
|
||||
}));
|
||||
}
|
||||
));
|
||||
|
||||
it('should support the * wildcard', runTest(
|
||||
{
|
||||
@@ -382,7 +389,8 @@ describe('SCE', function() {
|
||||
// The * wildcard does not match ';'
|
||||
expect(function() { $sce.getTrustedResourceUrl('http://example-com/foo;bar'); }).toThrowMinErr(
|
||||
'$sce', 'insecurl', 'Blocked loading resource from url not allowed by $sceDelegate policy. URL: http://example-com/foo;bar');
|
||||
}));
|
||||
}
|
||||
));
|
||||
|
||||
it('should support the ** wildcard', runTest(
|
||||
{
|
||||
@@ -394,7 +402,8 @@ describe('SCE', function() {
|
||||
expect($sce.getTrustedResourceUrl('http://example.com/foo-bar')).toEqual('http://example.com/foo-bar');
|
||||
// The ** wildcard accepts the ':/.?&' characters.
|
||||
expect($sce.getTrustedResourceUrl('http://example.com/foo:1/2.3?4&5-6')).toEqual('http://example.com/foo:1/2.3?4&5-6');
|
||||
}));
|
||||
}
|
||||
));
|
||||
|
||||
it('should not accept *** in the string', function() {
|
||||
expect(function() {
|
||||
@@ -412,7 +421,8 @@ describe('SCE', function() {
|
||||
blackList: []
|
||||
}, function($sce) {
|
||||
expect($sce.getTrustedResourceUrl('foo')).toEqual('foo');
|
||||
}));
|
||||
}
|
||||
));
|
||||
|
||||
it('should support the special string "self" in blacklist', runTest(
|
||||
{
|
||||
@@ -421,7 +431,8 @@ describe('SCE', function() {
|
||||
}, function($sce) {
|
||||
expect(function() { $sce.getTrustedResourceUrl('foo'); }).toThrowMinErr(
|
||||
'$sce', 'insecurl', 'Blocked loading resource from url not allowed by $sceDelegate policy. URL: foo');
|
||||
}));
|
||||
}
|
||||
));
|
||||
});
|
||||
|
||||
it('should have blacklist override the whitelist', runTest(
|
||||
@@ -431,7 +442,8 @@ describe('SCE', function() {
|
||||
}, function($sce) {
|
||||
expect(function() { $sce.getTrustedResourceUrl('foo'); }).toThrowMinErr(
|
||||
'$sce', 'insecurl', 'Blocked loading resource from url not allowed by $sceDelegate policy. URL: foo');
|
||||
}));
|
||||
}
|
||||
));
|
||||
|
||||
it('should support multiple items in both lists', runTest(
|
||||
{
|
||||
@@ -445,7 +457,8 @@ describe('SCE', function() {
|
||||
'$sce', 'insecurl', 'Blocked loading resource from url not allowed by $sceDelegate policy. URL: http://example.com/3');
|
||||
expect(function() { $sce.getTrustedResourceUrl('open_redirect'); }).toThrowMinErr(
|
||||
'$sce', 'insecurl', 'Blocked loading resource from url not allowed by $sceDelegate policy. URL: open_redirect');
|
||||
}));
|
||||
}
|
||||
));
|
||||
});
|
||||
|
||||
describe('sanitizing html', function() {
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
describe('$sniffer', function() {
|
||||
|
||||
function sniffer($window, $document) {
|
||||
/* global $SnifferProvider: false */
|
||||
$window.navigator = {};
|
||||
$document = jqLite($document || {});
|
||||
if (!$document[0].body) {
|
||||
|
||||
@@ -20,7 +20,7 @@ describe('urlUtils', function() {
|
||||
//IE counts / as empty, necessary to use / so that pathname is not context.html
|
||||
var parsed = urlResolve('/');
|
||||
expect(parsed.pathname).toBe('/');
|
||||
})
|
||||
});
|
||||
});
|
||||
|
||||
describe('isSameOrigin', function() {
|
||||
|
||||
@@ -19,7 +19,7 @@ describe("ngAnimate", function() {
|
||||
hasBeenAnimated = true;
|
||||
done();
|
||||
}
|
||||
}
|
||||
};
|
||||
});
|
||||
});
|
||||
inject(function($rootScope, $compile, $animate, $rootElement, $document) {
|
||||
@@ -70,9 +70,9 @@ describe("ngAnimate", function() {
|
||||
|
||||
var element, $rootElement;
|
||||
|
||||
function html(html) {
|
||||
function html(content) {
|
||||
body.append($rootElement);
|
||||
$rootElement.html(html);
|
||||
$rootElement.html(content);
|
||||
element = $rootElement.children().eq(0);
|
||||
return element;
|
||||
}
|
||||
@@ -100,7 +100,7 @@ describe("ngAnimate", function() {
|
||||
count++;
|
||||
done();
|
||||
}
|
||||
}
|
||||
};
|
||||
});
|
||||
});
|
||||
inject(function($compile, $rootScope, $animate, $sniffer, $rootElement, $timeout) {
|
||||
@@ -148,7 +148,7 @@ describe("ngAnimate", function() {
|
||||
count++;
|
||||
done();
|
||||
}
|
||||
}
|
||||
};
|
||||
});
|
||||
});
|
||||
inject(function($compile, $rootScope, $animate, $sniffer, $rootElement, $timeout) {
|
||||
@@ -174,7 +174,7 @@ describe("ngAnimate", function() {
|
||||
captured = true;
|
||||
done();
|
||||
}
|
||||
}
|
||||
};
|
||||
});
|
||||
});
|
||||
inject(function($animate, $rootElement, $rootScope, $compile, $timeout) {
|
||||
@@ -215,43 +215,43 @@ describe("ngAnimate", function() {
|
||||
start: function(element, done) {
|
||||
done();
|
||||
}
|
||||
}
|
||||
};
|
||||
});
|
||||
$animateProvider.register('.custom-delay', function($timeout) {
|
||||
$animateProvider.register('.custom-delay', function($timeout) {
|
||||
function animate(element, done) {
|
||||
done = arguments.length == 3 ? arguments[2] : done;
|
||||
$timeout(done, 2000, false);
|
||||
return function() {
|
||||
element.addClass('animation-cancelled');
|
||||
}
|
||||
};
|
||||
}
|
||||
return {
|
||||
leave : animate,
|
||||
addClass : animate,
|
||||
removeClass : animate
|
||||
}
|
||||
};
|
||||
});
|
||||
$animateProvider.register('.custom-long-delay', function($timeout) {
|
||||
$animateProvider.register('.custom-long-delay', function($timeout) {
|
||||
function animate(element, done) {
|
||||
done = arguments.length == 3 ? arguments[2] : done;
|
||||
$timeout(done, 20000, false);
|
||||
return function(cancelled) {
|
||||
element.addClass(cancelled ? 'animation-cancelled' : 'animation-ended');
|
||||
}
|
||||
};
|
||||
}
|
||||
return {
|
||||
leave : animate,
|
||||
addClass : animate,
|
||||
removeClass : animate
|
||||
}
|
||||
};
|
||||
});
|
||||
$animateProvider.register('.setup-memo', function() {
|
||||
$animateProvider.register('.setup-memo', function() {
|
||||
return {
|
||||
removeClass: function(element, className, done) {
|
||||
element.text('memento');
|
||||
done();
|
||||
}
|
||||
}
|
||||
};
|
||||
});
|
||||
return function($animate, $compile, $rootScope, $rootElement) {
|
||||
element = $compile('<div></div>')($rootScope);
|
||||
@@ -269,7 +269,7 @@ describe("ngAnimate", function() {
|
||||
$rootElement.append(element);
|
||||
};
|
||||
});
|
||||
})
|
||||
});
|
||||
|
||||
|
||||
it("should animate the enter animation event",
|
||||
@@ -439,7 +439,7 @@ describe("ngAnimate", function() {
|
||||
}
|
||||
};
|
||||
});
|
||||
})
|
||||
});
|
||||
inject(function($animate, $rootScope, $sniffer, $timeout) {
|
||||
child.attr('class','classify no');
|
||||
$animate.setClass(child, 'yes', 'no');
|
||||
@@ -517,7 +517,7 @@ describe("ngAnimate", function() {
|
||||
}
|
||||
};
|
||||
});
|
||||
})
|
||||
});
|
||||
inject(function($animate, $rootScope, $sniffer, $timeout) {
|
||||
child.attr('class','classify no');
|
||||
$animate.setClass(child, 'yes', 'no');
|
||||
@@ -764,7 +764,8 @@ describe("ngAnimate", function() {
|
||||
$timeout.flush(20000);
|
||||
expect(element.hasClass('custom-delay')).toBe(true);
|
||||
expect(element.hasClass('custom-long-delay')).toBe(true);
|
||||
}));
|
||||
})
|
||||
);
|
||||
|
||||
|
||||
it("should allow both multiple JS and CSS animations which run in parallel",
|
||||
@@ -806,7 +807,7 @@ describe("ngAnimate", function() {
|
||||
return function(_$rootElement_) {
|
||||
$rootElement = _$rootElement_;
|
||||
};
|
||||
})
|
||||
});
|
||||
});
|
||||
|
||||
/* The CSS animation handler must always be rendered before the other JS animation
|
||||
@@ -821,13 +822,13 @@ describe("ngAnimate", function() {
|
||||
$animateProvider.register('', function() {
|
||||
return {
|
||||
leave : function() { log.push('css'); }
|
||||
}
|
||||
};
|
||||
});
|
||||
//custom JS animation handler
|
||||
$animateProvider.register('.js-animation', function() {
|
||||
return {
|
||||
leave : function() { log.push('js'); }
|
||||
}
|
||||
};
|
||||
});
|
||||
});
|
||||
inject(function($animate, $rootScope, $compile, $sniffer) {
|
||||
@@ -967,7 +968,8 @@ describe("ngAnimate", function() {
|
||||
}
|
||||
|
||||
expect(element.hasClass('ng-hide-remove-active')).toBe(false);
|
||||
}));
|
||||
})
|
||||
);
|
||||
|
||||
|
||||
it("should stagger the items when the correct CSS class is provided",
|
||||
@@ -995,13 +997,13 @@ describe("ngAnimate", function() {
|
||||
|
||||
var container = $compile(html('<div></div>'))($rootScope);
|
||||
|
||||
var elements = [];
|
||||
var newScope, element, elements = [];
|
||||
for(var i = 0; i < 5; i++) {
|
||||
var newScope = $rootScope.$new();
|
||||
var element = $compile('<div class="real-animation"></div>')(newScope);
|
||||
newScope = $rootScope.$new();
|
||||
element = $compile('<div class="real-animation"></div>')(newScope);
|
||||
$animate.enter(element, container);
|
||||
elements.push(element);
|
||||
};
|
||||
}
|
||||
|
||||
$rootScope.$digest();
|
||||
$animate.triggerReflow();
|
||||
@@ -1015,13 +1017,13 @@ describe("ngAnimate", function() {
|
||||
//final closing timeout
|
||||
$timeout.flush();
|
||||
|
||||
for(var i = 0; i < 5; i++) {
|
||||
for(i = 0; i < 5; i++) {
|
||||
dealoc(elements[i]);
|
||||
var newScope = $rootScope.$new();
|
||||
var element = $compile('<div class="fake-animation"></div>')(newScope);
|
||||
newScope = $rootScope.$new();
|
||||
element = $compile('<div class="fake-animation"></div>')(newScope);
|
||||
$animate.enter(element, container);
|
||||
elements[i] = element;
|
||||
};
|
||||
}
|
||||
|
||||
$rootScope.$digest();
|
||||
|
||||
@@ -1059,7 +1061,7 @@ describe("ngAnimate", function() {
|
||||
var element = $compile('<div class="blocked-animation"></div>')(newScope);
|
||||
$animate.enter(element, container);
|
||||
elements.push(element);
|
||||
};
|
||||
}
|
||||
|
||||
$rootScope.$digest();
|
||||
|
||||
@@ -1102,7 +1104,7 @@ describe("ngAnimate", function() {
|
||||
var element = $compile('<div class="stagger-animation"></div>')(newScope);
|
||||
$animate.enter(element, container);
|
||||
elements.push(element);
|
||||
};
|
||||
}
|
||||
|
||||
$rootScope.$digest();
|
||||
$animate.triggerReflow();
|
||||
@@ -1209,7 +1211,8 @@ describe("ngAnimate", function() {
|
||||
browserTrigger(element,'transitionend', { timeStamp: now + 3000, elapsedTime: 3 });
|
||||
}
|
||||
expect(element).toBeShown();
|
||||
}));
|
||||
})
|
||||
);
|
||||
|
||||
|
||||
it("should NOT overwrite styles with outdated values when animation completes",
|
||||
@@ -1286,7 +1289,8 @@ describe("ngAnimate", function() {
|
||||
browserTrigger(element,'animationend', { timeStamp: Date.now() + 11000, elapsedTime: 11 });
|
||||
expect(element.hasClass('ng-hide-remove-active')).toBe(false);
|
||||
}
|
||||
}));
|
||||
})
|
||||
);
|
||||
|
||||
|
||||
it("should finish the previous transition when a new animation is started",
|
||||
@@ -1319,7 +1323,8 @@ describe("ngAnimate", function() {
|
||||
expect(element.hasClass('ng-hide-add')).toBe(true);
|
||||
expect(element.hasClass('ng-hide-add-active')).toBe(true);
|
||||
}
|
||||
}));
|
||||
})
|
||||
);
|
||||
|
||||
|
||||
it("should stagger the items when the correct CSS class is provided",
|
||||
@@ -1347,13 +1352,13 @@ describe("ngAnimate", function() {
|
||||
|
||||
var container = $compile(html('<div></div>'))($rootScope);
|
||||
|
||||
var elements = [];
|
||||
var newScope, element, elements = [];
|
||||
for(var i = 0; i < 5; i++) {
|
||||
var newScope = $rootScope.$new();
|
||||
var element = $compile('<div class="real-animation"></div>')(newScope);
|
||||
newScope = $rootScope.$new();
|
||||
element = $compile('<div class="real-animation"></div>')(newScope);
|
||||
$animate.enter(element, container);
|
||||
elements.push(element);
|
||||
};
|
||||
}
|
||||
|
||||
$rootScope.$digest();
|
||||
$animate.triggerReflow();
|
||||
@@ -1364,13 +1369,13 @@ describe("ngAnimate", function() {
|
||||
expect(elements[3].attr('style')).toMatch(/transition-delay: 0\.3\d*s/);
|
||||
expect(elements[4].attr('style')).toMatch(/transition-delay: 0\.4\d*s/);
|
||||
|
||||
for(var i = 0; i < 5; i++) {
|
||||
for(i = 0; i < 5; i++) {
|
||||
dealoc(elements[i]);
|
||||
var newScope = $rootScope.$new();
|
||||
var element = $compile('<div class="fake-animation"></div>')(newScope);
|
||||
newScope = $rootScope.$new();
|
||||
element = $compile('<div class="fake-animation"></div>')(newScope);
|
||||
$animate.enter(element, container);
|
||||
elements[i] = element;
|
||||
};
|
||||
}
|
||||
|
||||
$rootScope.$digest();
|
||||
$animate.triggerReflow();
|
||||
@@ -1406,7 +1411,7 @@ describe("ngAnimate", function() {
|
||||
var element = $compile('<div class="stagger-animation"></div>')(newScope);
|
||||
$animate.enter(element, container);
|
||||
elements.push(element);
|
||||
};
|
||||
}
|
||||
|
||||
$rootScope.$digest();
|
||||
$animate.triggerReflow();
|
||||
@@ -1459,8 +1464,8 @@ describe("ngAnimate", function() {
|
||||
return currentTimestamp;
|
||||
});
|
||||
}
|
||||
}
|
||||
})
|
||||
};
|
||||
});
|
||||
inject(function($animate, $rootScope, $compile, $sniffer, $timeout) {
|
||||
if (!$sniffer.transitions) return;
|
||||
|
||||
@@ -1530,13 +1535,13 @@ describe("ngAnimate", function() {
|
||||
$animate.triggerReflow(); //reflow
|
||||
expect(element.children().length).toBe(5);
|
||||
|
||||
for(var i = 0; i < 5; i++) {
|
||||
for(i = 0; i < 5; i++) {
|
||||
expect(kids[i].hasClass('ng-enter-active')).toBe(true);
|
||||
}
|
||||
|
||||
$timeout.flush(7500);
|
||||
|
||||
for(var i = 0; i < 5; i++) {
|
||||
for(i = 0; i < 5; i++) {
|
||||
expect(kids[i].hasClass('ng-enter-active')).toBe(true);
|
||||
}
|
||||
|
||||
@@ -1545,13 +1550,13 @@ describe("ngAnimate", function() {
|
||||
//9500 - 7500 = 2000
|
||||
$timeout.flush(1999); //remove 1999 more
|
||||
|
||||
for(var i = 0; i < 5; i++) {
|
||||
for(i = 0; i < 5; i++) {
|
||||
expect(kids[i].hasClass('ng-enter-active')).toBe(true);
|
||||
}
|
||||
|
||||
$timeout.flush(1); //up to 2000ms
|
||||
|
||||
for(var i = 0; i < 5; i++) {
|
||||
for(i = 0; i < 5; i++) {
|
||||
expect(kids[i].hasClass('ng-enter-active')).toBe(false);
|
||||
}
|
||||
}));
|
||||
@@ -1616,7 +1621,7 @@ describe("ngAnimate", function() {
|
||||
var element = $compile('<div class="stagger-animation"></div>')(newScope);
|
||||
$animate.enter(element, container);
|
||||
elements.push(element);
|
||||
};
|
||||
}
|
||||
|
||||
$rootScope.$digest();
|
||||
$animate.triggerReflow();
|
||||
@@ -1629,7 +1634,7 @@ describe("ngAnimate", function() {
|
||||
expect(elements[2].attr('style')).toMatch(/transition-delay:\s+1.2\d*/);
|
||||
expect(elements[2].attr('style')).toMatch(/animation-delay: 1\.4\d*s,\s*2\.4\d*s/);
|
||||
|
||||
for(var i = 0; i < 3; i++) {
|
||||
for(i = 0; i < 3; i++) {
|
||||
browserTrigger(elements[i],'transitionend', { timeStamp: Date.now() + 22000, elapsedTime: 22000 });
|
||||
expect(elements[i].attr('style')).toBeFalsy();
|
||||
}
|
||||
@@ -1724,16 +1729,16 @@ describe("ngAnimate", function() {
|
||||
removeClass : function(element, className, done) {
|
||||
$timeout(done, 2000);
|
||||
}
|
||||
}
|
||||
};
|
||||
});
|
||||
$animateProvider.register('.other', function() {
|
||||
$animateProvider.register('.other', function($timeout) {
|
||||
return {
|
||||
enter : function(element, done) {
|
||||
$timeout(done, 10000);
|
||||
}
|
||||
}
|
||||
};
|
||||
});
|
||||
})
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -2050,7 +2055,7 @@ describe("ngAnimate", function() {
|
||||
captured = 'removeClass-' + className;
|
||||
$timeout(done, 3000, false);
|
||||
}
|
||||
}
|
||||
};
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -2431,7 +2436,7 @@ describe("ngAnimate", function() {
|
||||
$rootElement = _$rootElement_;
|
||||
$document = _$document_;
|
||||
$animate.enabled(true);
|
||||
}
|
||||
};
|
||||
}));
|
||||
|
||||
function html(element) {
|
||||
@@ -2516,9 +2521,9 @@ describe("ngAnimate", function() {
|
||||
element.addClass('i-was-animated');
|
||||
$timeout(done, 10, false);
|
||||
}
|
||||
}
|
||||
};
|
||||
});
|
||||
})
|
||||
});
|
||||
inject(function($compile, $rootScope, $animate, $sniffer, $timeout) {
|
||||
|
||||
ss.addRule('.ng-enter', '-webkit-transition: 1s linear all;' +
|
||||
@@ -2551,7 +2556,7 @@ describe("ngAnimate", function() {
|
||||
element.addClass('this-is-mine-now');
|
||||
$timeout(done, 55, false);
|
||||
}
|
||||
}
|
||||
};
|
||||
});
|
||||
});
|
||||
inject(function($compile, $rootScope, $animate, $sniffer, $timeout) {
|
||||
@@ -2724,12 +2729,12 @@ describe("ngAnimate", function() {
|
||||
move : function(element, done) {
|
||||
fn = function() {
|
||||
done();
|
||||
}
|
||||
};
|
||||
return function() {
|
||||
interceptedClass = element.attr('class');
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
};
|
||||
});
|
||||
});
|
||||
inject(function($compile, $rootScope, $animate, $timeout) {
|
||||
@@ -2766,9 +2771,9 @@ describe("ngAnimate", function() {
|
||||
element.data('classify','add-' + className);
|
||||
done();
|
||||
}
|
||||
}
|
||||
};
|
||||
});
|
||||
})
|
||||
});
|
||||
inject(function($compile, $rootScope, $animate) {
|
||||
var element = html($compile('<div class="classify"></div>')($rootScope));
|
||||
|
||||
@@ -2859,14 +2864,14 @@ describe("ngAnimate", function() {
|
||||
step = done;
|
||||
return function(cancelled) {
|
||||
animationState = cancelled ? 'enter-cancel' : animationState;
|
||||
}
|
||||
};
|
||||
},
|
||||
addClass : function(element, className, done) {
|
||||
animationState = 'addClass';
|
||||
step = done;
|
||||
return function(cancelled) {
|
||||
animationState = cancelled ? 'addClass-cancel' : animationState;
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
});
|
||||
@@ -2958,7 +2963,7 @@ describe("ngAnimate", function() {
|
||||
childAnimated = true;
|
||||
done();
|
||||
}
|
||||
}
|
||||
};
|
||||
});
|
||||
$animateProvider.register('.container', function() {
|
||||
return {
|
||||
@@ -2966,7 +2971,7 @@ describe("ngAnimate", function() {
|
||||
containerAnimated = true;
|
||||
done();
|
||||
}
|
||||
}
|
||||
};
|
||||
});
|
||||
});
|
||||
|
||||
@@ -3017,8 +3022,8 @@ describe("ngAnimate", function() {
|
||||
continueAnimation = function() {
|
||||
continueAnimation = angular.noop;
|
||||
(done || className)();
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -3091,7 +3096,7 @@ describe("ngAnimate", function() {
|
||||
intercepted = true;
|
||||
done();
|
||||
}
|
||||
}
|
||||
};
|
||||
});
|
||||
});
|
||||
|
||||
@@ -3122,16 +3127,16 @@ describe("ngAnimate", function() {
|
||||
});
|
||||
|
||||
inject(function($animate, $rootScope, $compile, $rootElement, $timeout, $document, $sniffer) {
|
||||
if(!$sniffer.transitions) return;
|
||||
if (!$sniffer.transitions) return;
|
||||
|
||||
$animate.enabled(true);
|
||||
|
||||
var element = $compile('<div></div>')($rootScope);
|
||||
var kid, element = $compile('<div></div>')($rootScope);
|
||||
$rootElement.append(element);
|
||||
jqLite($document[0].body).append($rootElement);
|
||||
|
||||
for(var i=0;i<20;i++) {
|
||||
var kid = $compile('<div class="kid"></div>')($rootScope);
|
||||
kid = $compile('<div class="kid"></div>')($rootScope);
|
||||
$animate.enter(kid, element);
|
||||
}
|
||||
$rootScope.$digest();
|
||||
@@ -3142,8 +3147,8 @@ describe("ngAnimate", function() {
|
||||
dealoc(element);
|
||||
count = 0;
|
||||
|
||||
for(var i=0;i<20;i++) {
|
||||
var kid = $compile('<div class="kid c-'+i+'"></div>')($rootScope);
|
||||
for(i=0;i<20;i++) {
|
||||
kid = $compile('<div class="kid c-'+i+'"></div>')($rootScope);
|
||||
$animate.enter(kid, element);
|
||||
}
|
||||
|
||||
@@ -3197,8 +3202,8 @@ describe("ngAnimate", function() {
|
||||
|
||||
function assertClasses(str) {
|
||||
var className = element.attr('class');
|
||||
str.length == 0
|
||||
? className.length == 0
|
||||
str.length === 0
|
||||
? className.length === 0
|
||||
: expect(className.split(/\s+/)).toEqual(str.split(' '));
|
||||
}
|
||||
|
||||
@@ -3237,14 +3242,14 @@ describe("ngAnimate", function() {
|
||||
currentFn = done;
|
||||
return function(cancelled) {
|
||||
currentAnimation = cancelled ? null : currentAnimation;
|
||||
}
|
||||
};
|
||||
},
|
||||
beforeRemoveClass : function(element, className, done) {
|
||||
currentAnimation = 'removeClass';
|
||||
currentFn = done;
|
||||
return function(cancelled) {
|
||||
currentAnimation = cancelled ? null : currentAnimation;
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
});
|
||||
@@ -3276,7 +3281,7 @@ describe("ngAnimate", function() {
|
||||
count++;
|
||||
done();
|
||||
}
|
||||
}
|
||||
};
|
||||
});
|
||||
});
|
||||
inject(function($compile, $rootScope, $animate, $sniffer, $rootElement, $timeout) {
|
||||
@@ -3470,7 +3475,7 @@ describe("ngAnimate", function() {
|
||||
expect($window.getComputedStyle(element[0])[prop + 'Duration']).toBe('1s');
|
||||
done();
|
||||
}
|
||||
}
|
||||
};
|
||||
});
|
||||
});
|
||||
inject(function($rootScope, $compile, $rootElement, $document, $animate, $sniffer, $timeout, $window) {
|
||||
@@ -3518,7 +3523,8 @@ describe("ngAnimate", function() {
|
||||
browserTrigger(element, 'transitionend', { timeStamp: Date.now() + 1000, elapsedTime: 0.50999999991 });
|
||||
|
||||
expect($rootElement.children().length).toBe(0);
|
||||
}));
|
||||
})
|
||||
);
|
||||
|
||||
|
||||
it('should properly animate elements with compound directives', function() {
|
||||
@@ -3534,7 +3540,7 @@ describe("ngAnimate", function() {
|
||||
capturedAnimation = 'leave';
|
||||
done();
|
||||
}
|
||||
}
|
||||
};
|
||||
});
|
||||
});
|
||||
inject(function($rootScope, $compile, $rootElement, $document, $timeout, $templateCache, $sniffer, $animate) {
|
||||
@@ -3588,7 +3594,7 @@ describe("ngAnimate", function() {
|
||||
return function(element, className, done) {
|
||||
captures[key] = true;
|
||||
(done || className)();
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -3639,7 +3645,7 @@ describe("ngAnimate", function() {
|
||||
return function(element, className, done) {
|
||||
captures[key] = true;
|
||||
(done || className)();
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@@ -145,5 +145,5 @@ describe('$cookieStore', function() {
|
||||
$browser.cookieHash['blankCookie'] = '';
|
||||
$browser.poll();
|
||||
expect($cookieStore.get("blankCookie")).toEqual('');
|
||||
}))
|
||||
}));
|
||||
});
|
||||
|
||||
Vendored
+31
-27
@@ -246,29 +246,29 @@ describe('ngMock', function() {
|
||||
|
||||
it('should assertEmpty', function(){
|
||||
try {
|
||||
$log.error(Error('MyError'));
|
||||
$log.warn(Error('MyWarn'));
|
||||
$log.info(Error('MyInfo'));
|
||||
$log.log(Error('MyLog'));
|
||||
$log.debug(Error('MyDebug'));
|
||||
$log.error(new Error('MyError'));
|
||||
$log.warn(new Error('MyWarn'));
|
||||
$log.info(new Error('MyInfo'));
|
||||
$log.log(new Error('MyLog'));
|
||||
$log.debug(new Error('MyDebug'));
|
||||
$log.assertEmpty();
|
||||
} catch (error) {
|
||||
error = error.message || error;
|
||||
expect(error).toMatch(/Error: MyError/m);
|
||||
expect(error).toMatch(/Error: MyWarn/m);
|
||||
expect(error).toMatch(/Error: MyInfo/m);
|
||||
expect(error).toMatch(/Error: MyLog/m);
|
||||
expect(error).toMatch(/Error: MyDebug/m);
|
||||
var err = error.message || error;
|
||||
expect(err).toMatch(/Error: MyError/m);
|
||||
expect(err).toMatch(/Error: MyWarn/m);
|
||||
expect(err).toMatch(/Error: MyInfo/m);
|
||||
expect(err).toMatch(/Error: MyLog/m);
|
||||
expect(err).toMatch(/Error: MyDebug/m);
|
||||
} finally {
|
||||
$log.reset();
|
||||
}
|
||||
});
|
||||
|
||||
it('should reset state', function(){
|
||||
$log.error(Error('MyError'));
|
||||
$log.warn(Error('MyWarn'));
|
||||
$log.info(Error('MyInfo'));
|
||||
$log.log(Error('MyLog'));
|
||||
$log.error(new Error('MyError'));
|
||||
$log.warn(new Error('MyWarn'));
|
||||
$log.info(new Error('MyInfo'));
|
||||
$log.log(new Error('MyLog'));
|
||||
$log.reset();
|
||||
var passed = false;
|
||||
try {
|
||||
@@ -345,7 +345,7 @@ describe('ngMock', function() {
|
||||
|
||||
it('should allow you to specify a number of iterations', inject(function($interval) {
|
||||
var counter = 0;
|
||||
$interval(function() {counter++}, 1000, 2);
|
||||
$interval(function() { counter++; }, 1000, 2);
|
||||
|
||||
$interval.flush(1000);
|
||||
expect(counter).toBe(1);
|
||||
@@ -406,7 +406,8 @@ describe('ngMock', function() {
|
||||
$interval.flush(1000);
|
||||
|
||||
expect(log).toEqual([
|
||||
'tick', 'promise update: 0', 'tick', 'promise update: 1', 'promise success: 2']);
|
||||
'tick', 'promise update: 0', 'tick', 'promise update: 1', 'promise success: 2'
|
||||
]);
|
||||
|
||||
}));
|
||||
|
||||
@@ -530,7 +531,8 @@ describe('ngMock', function() {
|
||||
log = '';
|
||||
}));
|
||||
|
||||
function logFn(text){ return function() {
|
||||
function logFn(text) {
|
||||
return function() {
|
||||
log += text +';';
|
||||
};
|
||||
}
|
||||
@@ -609,7 +611,7 @@ describe('ngMock', function() {
|
||||
it('should expose flush method that will flush the pending queue of tasks', inject(
|
||||
function($timeout) {
|
||||
var logger = [],
|
||||
logFn = function(msg) { return function() { logger.push(msg) }};
|
||||
logFn = function(msg) { return function() { logger.push(msg); }; };
|
||||
|
||||
$timeout(logFn('t1'));
|
||||
$timeout(logFn('t2'), 200);
|
||||
@@ -692,6 +694,7 @@ describe('ngMock', function() {
|
||||
}));
|
||||
|
||||
it('should serialize scope that has overridden "hasOwnProperty"', inject(function($rootScope, $sniffer){
|
||||
/* jshint -W001 */
|
||||
// MS IE8 just doesn't work for this kind of thing, since "for ... in" doesn't return
|
||||
// things like hasOwnProperty even if it is explicitly defined on the actual object!
|
||||
if ($sniffer.msie<=8) return;
|
||||
@@ -704,11 +707,11 @@ describe('ngMock', function() {
|
||||
|
||||
describe('angular.mock.clearDataCache', function() {
|
||||
function keys(obj) {
|
||||
var keys = [];
|
||||
var keysArr = [];
|
||||
for(var key in obj) {
|
||||
if (obj.hasOwnProperty(key)) keys.push(key);
|
||||
if (obj.hasOwnProperty(key)) keysArr.push(key);
|
||||
}
|
||||
return keys.sort();
|
||||
return keysArr.sort();
|
||||
}
|
||||
|
||||
function browserTrigger(element, eventType) {
|
||||
@@ -740,11 +743,11 @@ describe('ngMock', function() {
|
||||
// crazy IE9 requires div to be connected to render DOM for click event to work
|
||||
// mousemove works even when not connected. This is a heisen-bug since stepping
|
||||
// through the code makes the test pass. Viva IE!!!
|
||||
angular.element(document.body).append(div)
|
||||
angular.element(document.body).append(div);
|
||||
|
||||
div.on('click', function() { log += 'click1;'});
|
||||
div.on('click', function() { log += 'click2;'});
|
||||
div.on('mousemove', function() { log += 'mousemove;'});
|
||||
div.on('click', function() { log += 'click1;'; });
|
||||
div.on('click', function() { log += 'click2;'; });
|
||||
div.on('mousemove', function() { log += 'mousemove;'; });
|
||||
|
||||
browserTrigger(div, 'click');
|
||||
browserTrigger(div, 'mousemove');
|
||||
@@ -884,7 +887,7 @@ describe('ngMock', function() {
|
||||
}));
|
||||
|
||||
afterEach(function() {
|
||||
expect(log).toEqual('module;inject;')
|
||||
expect(log).toEqual('module;inject;');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1440,6 +1443,7 @@ describe('ngMock', function() {
|
||||
|
||||
|
||||
describe('MockHttpExpectation', function() {
|
||||
/* global MockHttpExpectation */
|
||||
|
||||
it('should accept url as regexp', function() {
|
||||
var exp = new MockHttpExpectation('GET', /^\/x/);
|
||||
|
||||
@@ -32,6 +32,7 @@ describe("resource", function() {
|
||||
});
|
||||
|
||||
describe('isValidDottedPath', function() {
|
||||
/* global isValidDottedPath: false */
|
||||
it('should support arbitrary dotted names', function() {
|
||||
expect(isValidDottedPath('')).toBe(false);
|
||||
expect(isValidDottedPath('1')).toBe(false);
|
||||
@@ -51,11 +52,12 @@ describe("resource", function() {
|
||||
});
|
||||
|
||||
describe('lookupDottedPath', function() {
|
||||
/* global lookupDottedPath: false */
|
||||
var data = {a: {b: 'foo', c: null}};
|
||||
|
||||
it('should throw for invalid path', function() {
|
||||
expect(function() {
|
||||
lookupDottedPath(data, '.ckck')
|
||||
lookupDottedPath(data, '.ckck');
|
||||
}).toThrowMinErr('$resource', 'badmember',
|
||||
'Dotted member path "@.ckck" is invalid.');
|
||||
});
|
||||
@@ -95,6 +97,7 @@ describe("resource", function() {
|
||||
|
||||
|
||||
describe('shallow copy', function() {
|
||||
/* global shallowClearAndCopy */
|
||||
it('should make a copy', function() {
|
||||
var original = {key:{}};
|
||||
var copy = shallowClearAndCopy(original);
|
||||
@@ -124,7 +127,7 @@ describe("resource", function() {
|
||||
|
||||
it('should omit properties from prototype chain', function() {
|
||||
var original, clone = {};
|
||||
function Func() {};
|
||||
function Func() {}
|
||||
Func.prototype.hello = "world";
|
||||
|
||||
original = new Func();
|
||||
@@ -235,9 +238,9 @@ describe("resource", function() {
|
||||
//so we need this test to make sure that we don't over-encode the params and break stuff like
|
||||
//buzz api which uses @self
|
||||
|
||||
var R = $resource('/Path/:a');
|
||||
$httpBackend.expect('GET', '/Path/doh@fo%20o?!do%26h=g%3Da+h&:bar=$baz@1').respond('{}');
|
||||
R.get({a: 'doh@fo o', ':bar': '$baz@1', '!do&h': 'g=a h'});
|
||||
var R = $resource('/Path/:a');
|
||||
$httpBackend.expect('GET', '/Path/doh@fo%20o?!do%26h=g%3Da+h&:bar=$baz@1').respond('{}');
|
||||
R.get({a: 'doh@fo o', ':bar': '$baz@1', '!do&h': 'g=a h'});
|
||||
});
|
||||
|
||||
|
||||
@@ -248,9 +251,9 @@ describe("resource", function() {
|
||||
});
|
||||
|
||||
it('should not encode string "null" to "+" in url params', function() {
|
||||
var R = $resource('/Path/:a');
|
||||
$httpBackend.expect('GET', '/Path/null').respond('{}');
|
||||
R.get({a: 'null'});
|
||||
var R = $resource('/Path/:a');
|
||||
$httpBackend.expect('GET', '/Path/null').respond('{}');
|
||||
R.get({a: 'null'});
|
||||
});
|
||||
|
||||
it('should allow relative paths in resource url', function () {
|
||||
@@ -350,9 +353,9 @@ describe("resource", function() {
|
||||
|
||||
|
||||
it('should throw an exception if a param is called "hasOwnProperty"', function() {
|
||||
expect(function() {
|
||||
expect(function() {
|
||||
$resource('/:hasOwnProperty').get();
|
||||
}).toThrowMinErr('$resource','badname', "hasOwnProperty is not a valid parameter name");
|
||||
}).toThrowMinErr('$resource','badname', "hasOwnProperty is not a valid parameter name");
|
||||
});
|
||||
|
||||
|
||||
@@ -388,7 +391,7 @@ describe("resource", function() {
|
||||
|
||||
it('should send correct headers', function() {
|
||||
$httpBackend.expectPUT('/CreditCard/123', undefined, function(headers) {
|
||||
return headers['If-None-Match'] == "*";
|
||||
return headers['If-None-Match'] == "*";
|
||||
}).respond({id:123});
|
||||
|
||||
CreditCard.conditionalPut({id: {key:123}});
|
||||
@@ -563,9 +566,12 @@ describe("resource", function() {
|
||||
|
||||
it('should support dynamic default parameters (action specific)', function() {
|
||||
var currentGroup = 'students',
|
||||
Person = $resource('/Person/:group/:id', {}, {
|
||||
fetch: {method: 'GET', params: {group: function() { return currentGroup; }}}
|
||||
});
|
||||
Person = $resource('/Person/:group/:id', {}, {
|
||||
fetch: {
|
||||
method: 'GET',
|
||||
params: {group: function() { return currentGroup; }}
|
||||
}
|
||||
});
|
||||
|
||||
$httpBackend.expect('GET', '/Person/students/fedor').respond({id: 'fedor', email: 'f@f.com'});
|
||||
|
||||
@@ -978,14 +984,14 @@ describe("resource", function() {
|
||||
it('should transform request/response', function() {
|
||||
var Person = $resource('/Person/:id', {}, {
|
||||
save: {
|
||||
method: 'POST',
|
||||
params: {id: '@id'},
|
||||
transformRequest: function(data) {
|
||||
return angular.toJson({ __id: data.id });
|
||||
},
|
||||
transformResponse: function(data) {
|
||||
return { id: data.__id };
|
||||
}
|
||||
method: 'POST',
|
||||
params: {id: '@id'},
|
||||
transformRequest: function(data) {
|
||||
return angular.toJson({ __id: data.id });
|
||||
},
|
||||
transformResponse: function(data) {
|
||||
return { id: data.__id };
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1194,14 +1200,14 @@ describe("resource", function() {
|
||||
|
||||
// url parameter in action, parameter not ending the string
|
||||
$httpBackend.expect('GET', '/Customer/123/pay').respond({id: 'abc'});
|
||||
var TypeItem = $resource('/foo/:type', {type: 'Order'}, {
|
||||
TypeItem = $resource('/foo/:type', {type: 'Order'}, {
|
||||
get: {
|
||||
method: 'GET',
|
||||
params: {type: 'Customer'},
|
||||
url: '/:type/:typeId/pay'
|
||||
}
|
||||
});
|
||||
var item = TypeItem.get({typeId: 123});
|
||||
item = TypeItem.get({typeId: 123});
|
||||
$httpBackend.flush();
|
||||
expect(item).toEqualData({id: 'abc'});
|
||||
});
|
||||
@@ -1269,7 +1275,7 @@ describe('resource', function() {
|
||||
expect(failureSpy).toHaveBeenCalled();
|
||||
expect(failureSpy.mostRecentCall.args[0]).toMatch(
|
||||
/^\[\$resource:badcfg\] Error in resource configuration. Expected response to contain an object but got an array/
|
||||
)
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
|
||||
@@ -228,7 +228,7 @@ describe('ngView', function() {
|
||||
|
||||
expect(elm.text()).toEqual('include: view: content');
|
||||
expect($route.current.templateUrl).toEqual('viewPartial.html');
|
||||
dealoc(elm)
|
||||
dealoc(elm);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -237,7 +237,7 @@ describe('ngView', function() {
|
||||
'templates were cached', function() {
|
||||
//this is a test for a regression that was introduced by making the ng-view cache sync
|
||||
function ParentCtrl($scope) {
|
||||
$scope.log.push('parent');
|
||||
$scope.log.push('parent');
|
||||
}
|
||||
|
||||
module(function($routeProvider) {
|
||||
@@ -312,7 +312,8 @@ describe('ngView', function() {
|
||||
var called = 0;
|
||||
// we want to assert only during first watch
|
||||
$rootScope.$watch(function() {
|
||||
if (!called++) expect(element.text()).toBe('');
|
||||
if (!called) expect(element.text()).toBe('');
|
||||
called++;
|
||||
});
|
||||
|
||||
$rootScope.$digest();
|
||||
@@ -347,7 +348,8 @@ describe('ngView', function() {
|
||||
|
||||
expect(element.text()).toBe('bound-value');
|
||||
expect(log).toEqual([
|
||||
'$routeChangeStart', 'init-ctrl', '$viewContentLoaded', '$routeChangeSuccess' ]);
|
||||
'$routeChangeStart', 'init-ctrl', '$viewContentLoaded', '$routeChangeSuccess'
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -441,7 +443,10 @@ describe('ngView', function() {
|
||||
module(function($routeProvider) {
|
||||
$routeProvider.when('/bar', {templateUrl: 'tpl.html', controller: createController('bar')});
|
||||
$routeProvider.when('/foo', {
|
||||
templateUrl: 'tpl.html', controller: createController('foo'), reloadOnSearch: false});
|
||||
templateUrl: 'tpl.html',
|
||||
controller: createController('foo'),
|
||||
reloadOnSearch: false
|
||||
});
|
||||
});
|
||||
|
||||
inject(function($templateCache, $location, $rootScope) {
|
||||
@@ -652,8 +657,8 @@ describe('ngView animations', function() {
|
||||
|
||||
beforeEach(module('ngRoute'));
|
||||
|
||||
function html(html) {
|
||||
$rootElement.html(html);
|
||||
function html(content) {
|
||||
$rootElement.html(content);
|
||||
body.append($rootElement);
|
||||
element = $rootElement.children().eq(0);
|
||||
return element;
|
||||
@@ -679,7 +684,7 @@ describe('ngView animations', function() {
|
||||
return function($templateCache) {
|
||||
$templateCache.put('/foo.html', [200, '<div>data</div>', {}]);
|
||||
$templateCache.put('/bar.html', [200, '<div>data2</div>', {}]);
|
||||
}
|
||||
};
|
||||
}));
|
||||
|
||||
describe('hooks', function() {
|
||||
@@ -741,7 +746,8 @@ describe('ngView animations', function() {
|
||||
var itemA = animationA.args[0];
|
||||
|
||||
expect(itemA).not.toEqual(itemB);
|
||||
}));
|
||||
})
|
||||
);
|
||||
|
||||
it('should render ngClass on ngView',
|
||||
inject(function($compile, $rootScope, $templateCache, $animate, $location, $timeout) {
|
||||
@@ -761,7 +767,7 @@ describe('ngView animations', function() {
|
||||
var animation = $animate.queue.shift();
|
||||
expect(animation.event).toBe('addClass');
|
||||
|
||||
var item = animation.element;
|
||||
item = animation.element;
|
||||
expect(item.hasClass('classy')).toBe(true);
|
||||
|
||||
$rootScope.klass = 'boring';
|
||||
@@ -785,99 +791,100 @@ describe('ngView animations', function() {
|
||||
expect($animate.queue.shift().event).toBe('addClass');
|
||||
|
||||
expect(item.hasClass('boring')).toBe(true);
|
||||
}));
|
||||
})
|
||||
);
|
||||
|
||||
it('should not double compile when the route changes', function() {
|
||||
it('should not double compile when the route changes', function() {
|
||||
|
||||
var window;
|
||||
module(function($routeProvider, $animateProvider, $provide) {
|
||||
$routeProvider.when('/foo', {template: '<div ng-repeat="i in [1,2]">{{i}}</div>'});
|
||||
$routeProvider.when('/bar', {template: '<div ng-repeat="i in [3,4]">{{i}}</div>'});
|
||||
$animateProvider.register('.my-animation', function() {
|
||||
return {
|
||||
leave: function(element, done) {
|
||||
done();
|
||||
}
|
||||
};
|
||||
});
|
||||
var window;
|
||||
module(function($routeProvider, $animateProvider, $provide) {
|
||||
$routeProvider.when('/foo', {template: '<div ng-repeat="i in [1,2]">{{i}}</div>'});
|
||||
$routeProvider.when('/bar', {template: '<div ng-repeat="i in [3,4]">{{i}}</div>'});
|
||||
$animateProvider.register('.my-animation', function() {
|
||||
return {
|
||||
leave: function(element, done) {
|
||||
done();
|
||||
}
|
||||
};
|
||||
});
|
||||
});
|
||||
|
||||
inject(function($rootScope, $compile, $location, $route, $timeout, $rootElement, $sniffer, $animate) {
|
||||
element = $compile(html('<div><ng:view onload="load()" class="my-animation"></ng:view></div>'))($rootScope);
|
||||
$animate.enabled(true);
|
||||
inject(function($rootScope, $compile, $location, $route, $timeout, $rootElement, $sniffer, $animate) {
|
||||
element = $compile(html('<div><ng:view onload="load()" class="my-animation"></ng:view></div>'))($rootScope);
|
||||
$animate.enabled(true);
|
||||
|
||||
$location.path('/foo');
|
||||
$rootScope.$digest();
|
||||
$location.path('/foo');
|
||||
$rootScope.$digest();
|
||||
|
||||
expect($animate.queue.shift().event).toBe('enter'); //ngView
|
||||
expect($animate.queue.shift().event).toBe('enter'); //repeat 1
|
||||
expect($animate.queue.shift().event).toBe('enter'); //repeat 2
|
||||
expect($animate.queue.shift().event).toBe('enter'); //ngView
|
||||
expect($animate.queue.shift().event).toBe('enter'); //repeat 1
|
||||
expect($animate.queue.shift().event).toBe('enter'); //repeat 2
|
||||
|
||||
expect(element.text()).toEqual('12');
|
||||
expect(element.text()).toEqual('12');
|
||||
|
||||
$location.path('/bar');
|
||||
$rootScope.$digest();
|
||||
$location.path('/bar');
|
||||
$rootScope.$digest();
|
||||
|
||||
expect($animate.queue.shift().event).toBe('enter'); //ngView new
|
||||
expect($animate.queue.shift().event).toBe('leave'); //ngView old
|
||||
expect($animate.queue.shift().event).toBe('enter'); //ngView new
|
||||
expect($animate.queue.shift().event).toBe('leave'); //ngView old
|
||||
|
||||
$rootScope.$digest();
|
||||
$rootScope.$digest();
|
||||
|
||||
expect($animate.queue.shift().event).toBe('enter'); //ngRepeat 3
|
||||
expect($animate.queue.shift().event).toBe('enter'); //ngRepeat 4
|
||||
expect($animate.queue.shift().event).toBe('enter'); //ngRepeat 3
|
||||
expect($animate.queue.shift().event).toBe('enter'); //ngRepeat 4
|
||||
|
||||
expect(element.text()).toEqual('34');
|
||||
expect(element.text()).toEqual('34');
|
||||
|
||||
function n(text) {
|
||||
return text.replace(/\r\n/m, '').replace(/\r\n/m, '');
|
||||
function n(text) {
|
||||
return text.replace(/\r\n/m, '').replace(/\r\n/m, '');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
it('should destroy the previous leave animation if a new one takes place', function() {
|
||||
module(function($provide) {
|
||||
$provide.value('$animate', {
|
||||
enabled : function() { return true; },
|
||||
leave : function() {
|
||||
//DOM operation left blank
|
||||
},
|
||||
enter : function(element, parent, after) {
|
||||
angular.element(after).after(element);
|
||||
}
|
||||
});
|
||||
});
|
||||
inject(function ($compile, $rootScope, $animate, $location) {
|
||||
var item;
|
||||
var $scope = $rootScope.$new();
|
||||
element = $compile(html(
|
||||
'<div>' +
|
||||
'<div ng-view></div>' +
|
||||
'</div>'
|
||||
))($scope);
|
||||
|
||||
it('should destroy the previous leave animation if a new one takes place', function() {
|
||||
module(function($provide) {
|
||||
$provide.value('$animate', {
|
||||
enabled : function() { return true; },
|
||||
leave : function() {
|
||||
//DOM operation left blank
|
||||
},
|
||||
enter : function(element, parent, after) {
|
||||
angular.element(after).after(element);
|
||||
}
|
||||
});
|
||||
$scope.$apply('value = true');
|
||||
|
||||
$location.path('/bar');
|
||||
$rootScope.$digest();
|
||||
|
||||
var destroyed, inner = element.children(0);
|
||||
inner.on('$destroy', function() {
|
||||
destroyed = true;
|
||||
});
|
||||
inject(function ($compile, $rootScope, $animate, $location) {
|
||||
var item;
|
||||
var $scope = $rootScope.$new();
|
||||
element = $compile(html(
|
||||
'<div>' +
|
||||
'<div ng-view></div>' +
|
||||
'</div>'
|
||||
))($scope);
|
||||
|
||||
$scope.$apply('value = true');
|
||||
$location.path('/foo');
|
||||
$rootScope.$digest();
|
||||
|
||||
$location.path('/bar');
|
||||
$rootScope.$digest();
|
||||
$location.path('/bar');
|
||||
$rootScope.$digest();
|
||||
|
||||
var destroyed, inner = element.children(0);
|
||||
inner.on('$destroy', function() {
|
||||
destroyed = true;
|
||||
});
|
||||
$location.path('/bar');
|
||||
$rootScope.$digest();
|
||||
|
||||
$location.path('/foo');
|
||||
$rootScope.$digest();
|
||||
|
||||
$location.path('/bar');
|
||||
$rootScope.$digest();
|
||||
|
||||
$location.path('/bar');
|
||||
$rootScope.$digest();
|
||||
|
||||
expect(destroyed).toBe(true);
|
||||
});
|
||||
expect(destroyed).toBe(true);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
describe('autoscroll', function () {
|
||||
@@ -978,6 +985,7 @@ describe('ngView animations', function() {
|
||||
|
||||
expect($animate.enter).toHaveBeenCalledOnce();
|
||||
expect(autoScrollSpy).toHaveBeenCalledOnce();
|
||||
}));
|
||||
}
|
||||
));
|
||||
});
|
||||
});
|
||||
|
||||
+11
-11
@@ -560,8 +560,8 @@ describe('$route', function() {
|
||||
|
||||
inject(function($route, $httpBackend, $location, $rootScope) {
|
||||
var log = '';
|
||||
$rootScope.$on('$routeChangeStart', function(e, next) { log += '$before(' + next.templateUrl + ');'});
|
||||
$rootScope.$on('$routeChangeSuccess', function(e, next) { log += '$after(' + next.templateUrl + ');'});
|
||||
$rootScope.$on('$routeChangeStart', function(e, next) { log += '$before(' + next.templateUrl + ');'; });
|
||||
$rootScope.$on('$routeChangeSuccess', function(e, next) { log += '$after(' + next.templateUrl + ');'; });
|
||||
|
||||
$httpBackend.expectGET('r1.html').respond('R1');
|
||||
$httpBackend.expectGET('r2.html').respond('R2');
|
||||
@@ -581,9 +581,9 @@ describe('$route', function() {
|
||||
});
|
||||
|
||||
it('should NOT load cross domain templates by default', function() {
|
||||
module(function($routeProvider) {
|
||||
$routeProvider.when('/foo', { templateUrl: 'http://example.com/foo.html' });
|
||||
});
|
||||
module(function($routeProvider) {
|
||||
$routeProvider.when('/foo', { templateUrl: 'http://example.com/foo.html' });
|
||||
});
|
||||
|
||||
inject(function ($route, $location, $rootScope) {
|
||||
$location.path('/foo');
|
||||
@@ -618,8 +618,8 @@ describe('$route', function() {
|
||||
|
||||
inject(function($route, $httpBackend, $location, $rootScope, $routeParams) {
|
||||
var log = '';
|
||||
$rootScope.$on('$routeChangeStart', function(e, next) { log += '$before' + angular.toJson($routeParams) + ';'});
|
||||
$rootScope.$on('$routeChangeSuccess', function(e, next) { log += '$after' + angular.toJson($routeParams) + ';'});
|
||||
$rootScope.$on('$routeChangeStart', function(e, next) { log += '$before' + angular.toJson($routeParams) + ';'; });
|
||||
$rootScope.$on('$routeChangeSuccess', function(e, next) { log += '$after' + angular.toJson($routeParams) + ';'; });
|
||||
|
||||
$httpBackend.whenGET('r1.html').respond('R1');
|
||||
$httpBackend.whenGET('r2.html').respond('R2');
|
||||
@@ -650,8 +650,8 @@ describe('$route', function() {
|
||||
|
||||
inject(function($route, $httpBackend, $location, $rootScope) {
|
||||
var log = '';
|
||||
$rootScope.$on('$routeChangeStart', function(e, next) { log += '$before(' + next.templateUrl + ');'});
|
||||
$rootScope.$on('$routeChangeSuccess', function(e, next) { log += '$after(' + next.templateUrl + ');'});
|
||||
$rootScope.$on('$routeChangeStart', function(e, next) { log += '$before(' + next.templateUrl + ');'; });
|
||||
$rootScope.$on('$routeChangeSuccess', function(e, next) { log += '$after(' + next.templateUrl + ');'; });
|
||||
|
||||
$httpBackend.expectGET('r1.html').respond('R1');
|
||||
$httpBackend.expectGET('r2.html').respond('R2');
|
||||
@@ -683,8 +683,8 @@ describe('$route', function() {
|
||||
$rootScope.$on('$routeChangeError', function(e, next, last, error) {
|
||||
log += '$failed(' + next.templateUrl + ', ' + error.status + ');';
|
||||
});
|
||||
$rootScope.$on('$routeChangeStart', function(e, next) { log += '$before(' + next.templateUrl + ');'});
|
||||
$rootScope.$on('$routeChangeSuccess', function(e, next) { log += '$after(' + next.templateUrl + ');'});
|
||||
$rootScope.$on('$routeChangeStart', function(e, next) { log += '$before(' + next.templateUrl + ');'; });
|
||||
$rootScope.$on('$routeChangeSuccess', function(e, next) { log += '$after(' + next.templateUrl + ');'; });
|
||||
|
||||
$httpBackend.expectGET('r1.html').respond(404, 'R1');
|
||||
$httpBackend.expectGET('r2.html').respond('R2');
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
'use strict';
|
||||
|
||||
describe('linky', function() {
|
||||
var linky;
|
||||
|
||||
@@ -27,8 +29,8 @@ describe('linky', function() {
|
||||
|
||||
it('should handle target:', function() {
|
||||
expect(linky("http://example.com", "_blank")).
|
||||
toEqual('<a target="_blank" href="http://example.com">http://example.com</a>')
|
||||
toEqual('<a target="_blank" href="http://example.com">http://example.com</a>');
|
||||
expect(linky("http://example.com", "someNamedIFrame")).
|
||||
toEqual('<a target="someNamedIFrame" href="http://example.com">http://example.com</a>')
|
||||
toEqual('<a target="someNamedIFrame" href="http://example.com">http://example.com</a>');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -16,32 +16,33 @@ describe('HTML', function() {
|
||||
});
|
||||
|
||||
describe('htmlParser', function() {
|
||||
/* global htmlParser */
|
||||
if (angular.isUndefined(window.htmlParser)) return;
|
||||
|
||||
var handler, start, text, comment;
|
||||
beforeEach(function() {
|
||||
handler = {
|
||||
start: function(tag, attrs, unary){
|
||||
start = {
|
||||
tag: tag,
|
||||
attrs: attrs,
|
||||
unary: unary
|
||||
};
|
||||
// Since different browsers handle newlines differently we trim
|
||||
// so that it is easier to write tests.
|
||||
angular.forEach(attrs, function(value, key) {
|
||||
attrs[key] = value.replace(/^\s*/, '').replace(/\s*$/, '')
|
||||
});
|
||||
},
|
||||
chars: function(text_){
|
||||
text = text_;
|
||||
},
|
||||
end:function(tag) {
|
||||
expect(tag).toEqual(start.tag);
|
||||
},
|
||||
comment:function(comment_) {
|
||||
comment = comment_;
|
||||
}
|
||||
start: function(tag, attrs, unary){
|
||||
start = {
|
||||
tag: tag,
|
||||
attrs: attrs,
|
||||
unary: unary
|
||||
};
|
||||
// Since different browsers handle newlines differently we trim
|
||||
// so that it is easier to write tests.
|
||||
angular.forEach(attrs, function(value, key) {
|
||||
attrs[key] = value.replace(/^\s*/, '').replace(/\s*$/, '');
|
||||
});
|
||||
},
|
||||
chars: function(text_){
|
||||
text = text_;
|
||||
},
|
||||
end:function(tag) {
|
||||
expect(tag).toEqual(start.tag);
|
||||
},
|
||||
comment:function(comment_) {
|
||||
comment = comment_;
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
@@ -191,10 +192,11 @@ describe('HTML', function() {
|
||||
});
|
||||
|
||||
it('should allow multiline strings', function() {
|
||||
expectHTML('\na\n').toEqual(' a\ ');
|
||||
expectHTML('\na\n').toEqual(' a ');
|
||||
});
|
||||
|
||||
describe('htmlSanitizerWriter', function() {
|
||||
/* global htmlSanitizeWriter: false */
|
||||
if (angular.isUndefined(window.htmlSanitizeWriter)) return;
|
||||
|
||||
var writer, html, uriValidator;
|
||||
@@ -371,11 +373,13 @@ describe('HTML', function() {
|
||||
});
|
||||
|
||||
it('should not be URI', function() {
|
||||
/* jshint scripturl: true */
|
||||
expect('javascript:alert').not.toBeValidUrl();
|
||||
});
|
||||
|
||||
describe('javascript URLs', function() {
|
||||
it('should ignore javascript:', function() {
|
||||
/* jshint scripturl: true */
|
||||
expect('JavaScript:abc').not.toBeValidUrl();
|
||||
expect(' \n Java\n Script:abc').not.toBeValidUrl();
|
||||
expect('http://JavaScript/my.js').toBeValidUrl();
|
||||
@@ -411,6 +415,7 @@ describe('HTML', function() {
|
||||
});
|
||||
|
||||
describe('sanitizeText', function() {
|
||||
/* global sanitizeText: false */
|
||||
it('should escape text', function() {
|
||||
expect(sanitizeText('a<div>&</div>c')).toEqual('a<div>&</div>c');
|
||||
});
|
||||
|
||||
@@ -5,7 +5,7 @@ describe('angular.scenario.Application', function() {
|
||||
var app, frames;
|
||||
|
||||
function callLoadHandlers(app) {
|
||||
var handler = app.getFrame_().triggerHandler('load')
|
||||
var handler = app.getFrame_().triggerHandler('load');
|
||||
}
|
||||
|
||||
beforeEach(function() {
|
||||
|
||||
@@ -71,7 +71,7 @@ describe('angular.scenario.Runner', function() {
|
||||
$window.it('1', angular.noop);
|
||||
$window.describe('B', function() {
|
||||
$window.beforeEach(function() { before.push('B'); });
|
||||
$window.afterEach(function() { after.push('B'); });
|
||||
$window.afterEach(function() { after.push('B'); });
|
||||
$window.it('2', angular.noop);
|
||||
$window.describe('C', function() {
|
||||
$window.beforeEach(function() { before.push('C'); });
|
||||
|
||||
@@ -39,6 +39,6 @@ describe("ScenarioSpec: Compilation", function() {
|
||||
var jQuery = angular.scenario.jQuery;
|
||||
expect(typeof jQuery).toEqual('function');
|
||||
expect(typeof jQuery('<div></div>').html).toEqual('function');
|
||||
})
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
+25
-25
@@ -241,27 +241,27 @@ describe("angular.scenario.dsl", function() {
|
||||
|
||||
it('should select option by exact name', function() {
|
||||
doc.append(
|
||||
'<select ng-model="test">' +
|
||||
' <option value=A>twenty one</option>' +
|
||||
' <option value=B selected>two</option>' +
|
||||
' <option value=C>thirty one</option>' +
|
||||
' <option value=D>one</option>' +
|
||||
'</select>'
|
||||
);
|
||||
$root.dsl.select('test').option('one');
|
||||
expect(doc.find('[ng-model="test"]').val()).toEqual('D');
|
||||
'<select ng-model="test">' +
|
||||
' <option value=A>twenty one</option>' +
|
||||
' <option value=B selected>two</option>' +
|
||||
' <option value=C>thirty one</option>' +
|
||||
' <option value=D>one</option>' +
|
||||
'</select>'
|
||||
);
|
||||
$root.dsl.select('test').option('one');
|
||||
expect(doc.find('[ng-model="test"]').val()).toEqual('D');
|
||||
});
|
||||
|
||||
it('should select option by name if no exact match and name contains value', function() {
|
||||
doc.append(
|
||||
'<select ng-model="test">' +
|
||||
' <option value=A>twenty one</option>' +
|
||||
' <option value=B selected>two</option>' +
|
||||
' <option value=C>thirty one</option>' +
|
||||
'</select>'
|
||||
);
|
||||
$root.dsl.select('test').option('one');
|
||||
expect(doc.find('[ng-model="test"]').val()).toEqual('A');
|
||||
'<select ng-model="test">' +
|
||||
' <option value=A>twenty one</option>' +
|
||||
' <option value=B selected>two</option>' +
|
||||
' <option value=C>thirty one</option>' +
|
||||
'</select>'
|
||||
);
|
||||
$root.dsl.select('test').option('one');
|
||||
expect(doc.find('[ng-model="test"]').val()).toEqual('A');
|
||||
});
|
||||
|
||||
it('should select multiple options', function() {
|
||||
@@ -283,14 +283,14 @@ describe("angular.scenario.dsl", function() {
|
||||
});
|
||||
|
||||
it('should fail to select an option that does not exist', function(){
|
||||
doc.append(
|
||||
'<select ng-model="test">' +
|
||||
' <option value=A>one</option>' +
|
||||
' <option value=B selected>two</option>' +
|
||||
'</select>'
|
||||
);
|
||||
$root.dsl.select('test').option('three');
|
||||
expect($root.futureError).toMatch(/not found/);
|
||||
doc.append(
|
||||
'<select ng-model="test">' +
|
||||
' <option value=A>one</option>' +
|
||||
' <option value=B selected>two</option>' +
|
||||
'</select>'
|
||||
);
|
||||
$root.dsl.select('test').option('three');
|
||||
expect($root.futureError).toMatch(/not found/);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
/* global using: false, binding: false, input: false, select: false, repeater: false */
|
||||
'use strict';
|
||||
|
||||
describe('widgets', function() {
|
||||
|
||||
@@ -109,7 +109,7 @@ describe('angular.scenario.output.html', function() {
|
||||
context.find('#describe-10 .tests > li .test-info .timer-result').
|
||||
each(function(index, timer) {
|
||||
expect(timer.innerHTML).toMatch(/ms$/);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('should include line if provided', function() {
|
||||
|
||||
@@ -220,7 +220,7 @@ var swipeTests = function(description, restrictBrowsers, startEvent, moveEvent,
|
||||
expect(eventFired).toEqual(true);
|
||||
}));
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
swipeTests('touch', /* restrictBrowers */ true, 'touchstart', 'touchmove', 'touchend');
|
||||
swipeTests('mouse', /* restrictBrowers */ false, 'mousedown', 'mousemove', 'mouseup');
|
||||
|
||||
@@ -385,7 +385,7 @@ var swipeTests = function(description, restrictBrowsers, startEvent, moveEvent,
|
||||
expect(events.end).not.toHaveBeenCalled();
|
||||
}));
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
swipeTests('touch', /* restrictBrowers */ true, 'touchstart', 'touchmove', 'touchend');
|
||||
swipeTests('mouse', /* restrictBrowers */ false, 'mousedown', 'mousemove', 'mouseup');
|
||||
|
||||
Reference in New Issue
Block a user