' +
@@ -494,8 +494,8 @@ describe('Binder', function() {
})
);
- it('ItShouldSelectTheCorrectRadioBox', inject(function($rootScope) {
- var element = angular.compile(
+ it('ItShouldSelectTheCorrectRadioBox', inject(function($rootScope, $compile) {
+ var element = $compile(
'
' +
'
' +
'
' +
@@ -516,8 +516,8 @@ describe('Binder', function() {
assertEquals("male", male.val());
}));
- it('ItShouldRepeatOnHashes', inject(function($rootScope) {
- var element = angular.compile(
+ it('ItShouldRepeatOnHashes', inject(function($rootScope, $compile) {
+ var element = $compile(
'
')($rootScope);
@@ -530,8 +530,8 @@ describe('Binder', function() {
sortedHtml(element));
}));
- it('ItShouldFireChangeListenersBeforeUpdate', inject(function($rootScope) {
- var element = angular.compile('
')($rootScope);
+ it('ItShouldFireChangeListenersBeforeUpdate', inject(function($rootScope, $compile) {
+ var element = $compile('
')($rootScope);
$rootScope.name = "";
$rootScope.$watch("watched", "name=123");
$rootScope.watched = "change";
@@ -542,8 +542,8 @@ describe('Binder', function() {
sortedHtml(element));
}));
- it('ItShouldHandleMultilineBindings', inject(function($rootScope) {
- var element = angular.compile('
{{\n 1 \n + \n 2 \n}}
')($rootScope);
+ it('ItShouldHandleMultilineBindings', inject(function($rootScope, $compile) {
+ var element = $compile('
{{\n 1 \n + \n 2 \n}}
')($rootScope);
$rootScope.$apply();
assertEquals("3", element.text());
}));
diff --git a/test/ResourceSpec.js b/test/ResourceSpec.js
index 75d81a89..928b4f6c 100644
--- a/test/ResourceSpec.js
+++ b/test/ResourceSpec.js
@@ -221,8 +221,8 @@ describe("resource", function() {
nakedExpect(visa).toEqual({id:123});
}));
- it('should excersize full stack', inject(function($rootScope, $browser, $resource) {
- angular.compile('
')($rootScope);
+ it('should excersize full stack', inject(function($rootScope, $browser, $resource, $compile) {
+ $compile('
')($rootScope);
var Person = $resource('/Person/:id');
$browser.xhr.expectGET('/Person/123').respond('\n{\n"name":\n"misko"\n}\n');
var person = Person.get({id:123});
@@ -230,8 +230,8 @@ describe("resource", function() {
expect(person.name).toEqual('misko');
}));
- it('should return the same object when verifying the cache', inject(function($rootScope) {
- angular.compile('
')($rootScope);
+ it('should return the same object when verifying the cache', inject(function($rootScope, $compile) {
+ $compile('
')($rootScope);
var $browser = $rootScope.$service('$browser');
var $resource = $rootScope.$service('$resource');
var Person = $resource('/Person/:id', null, {query: {method:'GET', isArray: true, verifyCache: true}});
diff --git a/test/ScenarioSpec.js b/test/ScenarioSpec.js
index d33e880d..986e2121 100644
--- a/test/ScenarioSpec.js
+++ b/test/ScenarioSpec.js
@@ -2,22 +2,22 @@
describe("ScenarioSpec: Compilation", function() {
describe('compilation', function() {
- it("should compile dom node and return scope", inject(function($rootScope) {
+ it("should compile dom node and return scope", inject(function($rootScope, $compile) {
var node = jqLite('
{{b=a+1}}
')[0];
- angular.compile(node)($rootScope);
+ $compile(node)($rootScope);
$rootScope.$digest();
expect($rootScope.a).toEqual(1);
expect($rootScope.b).toEqual(2);
}));
- it("should compile jQuery node and return scope", inject(function($rootScope) {
- var element = compile(jqLite('
{{a=123}}
'))($rootScope);
+ it("should compile jQuery node and return scope", inject(function($rootScope, $compile) {
+ var element = $compile(jqLite('
{{a=123}}
'))($rootScope);
$rootScope.$digest();
expect(jqLite(element).text()).toEqual('123');
}));
- it("should compile text node and return scope", inject(function($rootScope) {
- var element = angular.compile('
{{a=123}}
')($rootScope);
+ it("should compile text node and return scope", inject(function($rootScope, $compile) {
+ var element = $compile('
{{a=123}}
')($rootScope);
$rootScope.$digest();
expect(jqLite(element).text()).toEqual('123');
}));
diff --git a/test/directivesSpec.js b/test/directivesSpec.js
index eb74d227..96d0993b 100644
--- a/test/directivesSpec.js
+++ b/test/directivesSpec.js
@@ -2,14 +2,14 @@
describe("directive", function() {
- it("should ng:init", inject(function($rootScope) {
- var element = angular.compile('
')($rootScope);
+ it("should ng:init", inject(function($rootScope, $compile) {
+ var element = $compile('
')($rootScope);
expect($rootScope.a).toEqual(123);
}));
describe('ng:bind', function() {
- it('should set text', inject(function($rootScope) {
- var element = angular.compile('
')($rootScope);
+ it('should set text', inject(function($rootScope, $compile) {
+ var element = $compile('
')($rootScope);
expect(element.text()).toEqual('');
$rootScope.a = 'misko';
$rootScope.$digest();
@@ -17,8 +17,8 @@ describe("directive", function() {
expect(element.text()).toEqual('misko');
}));
- it('should set text to blank if undefined', inject(function($rootScope) {
- var element = angular.compile('
')($rootScope);
+ it('should set text to blank if undefined', inject(function($rootScope, $compile) {
+ var element = $compile('
')($rootScope);
$rootScope.a = 'misko';
$rootScope.$digest();
expect(element.text()).toEqual('misko');
@@ -27,76 +27,76 @@ describe("directive", function() {
expect(element.text()).toEqual('');
}));
- it('should set html', inject(function($rootScope) {
- var element = angular.compile('
')($rootScope);
+ it('should set html', inject(function($rootScope, $compile) {
+ var element = $compile('
')($rootScope);
$rootScope.html = '
hello
';
$rootScope.$digest();
expect(lowercase(element.html())).toEqual('
hello
');
}));
- it('should set unsafe html', inject(function($rootScope) {
- var element = angular.compile('
')($rootScope);
+ it('should set unsafe html', inject(function($rootScope, $compile) {
+ var element = $compile('
')($rootScope);
$rootScope.html = '
hello
';
$rootScope.$digest();
expect(lowercase(element.html())).toEqual('
hello
');
}));
- it('should set element element', inject(function($rootScope) {
+ it('should set element element', inject(function($rootScope, $compile) {
angularFilter.myElement = function() {
return jqLite('
hello ');
};
- var element = angular.compile('
')($rootScope);
+ var element = $compile('
')($rootScope);
$rootScope.$digest();
expect(lowercase(element.html())).toEqual('
hello ');
}));
- it('should have $element set to current bind element', inject(function($rootScope) {
+ it('should have $element set to current bind element', inject(function($rootScope, $compile) {
angularFilter.myFilter = function() {
this.$element.addClass("filter");
return 'HELLO';
};
- var element = angular.compile('
')($rootScope);
+ var element = $compile('
')($rootScope);
$rootScope.$digest();
expect(sortedHtml(element)).toEqual('
');
}));
- it('should suppress rendering of falsy values', inject(function($rootScope) {
- var element = angular.compile('
{{ null }}{{ undefined }}{{ "" }}-{{ 0 }}{{ false }}
')($rootScope);
+ it('should suppress rendering of falsy values', inject(function($rootScope, $compile) {
+ var element = $compile('
{{ null }}{{ undefined }}{{ "" }}-{{ 0 }}{{ false }}
')($rootScope);
$rootScope.$digest();
expect(element.text()).toEqual('-0false');
}));
- it('should render object as JSON ignore $$', inject(function($rootScope) {
- var element = angular.compile('
{{ {key:"value", $$key:"hide"} }}
')($rootScope);
+ it('should render object as JSON ignore $$', inject(function($rootScope, $compile) {
+ var element = $compile('
{{ {key:"value", $$key:"hide"} }}
')($rootScope);
$rootScope.$digest();
expect(fromJson(element.text())).toEqual({key:'value'});
}));
});
describe('ng:bind-template', function() {
- it('should ng:bind-template', inject(function($rootScope) {
- var element = angular.compile('
')($rootScope);
+ it('should ng:bind-template', inject(function($rootScope, $compile) {
+ var element = $compile('
')($rootScope);
$rootScope.name = 'Misko';
$rootScope.$digest();
expect(element.hasClass('ng-binding')).toEqual(true);
expect(element.text()).toEqual('Hello Misko!');
}));
- it('should have $element set to current bind element', inject(function($rootScope) {
+ it('should have $element set to current bind element', inject(function($rootScope, $compile) {
var innerText;
angularFilter.myFilter = function(text) {
innerText = innerText || this.$element.text();
return text;
};
- var element = angular.compile('
beforeINNER after
')($rootScope);
+ var element = $compile('
beforeINNER after
')($rootScope);
$rootScope.$digest();
expect(element.text()).toEqual("beforeHELLOafter");
expect(innerText).toEqual('INNER');
}));
- it('should render object as JSON ignore $$', inject(function($rootScope) {
- var element = angular.compile('
{{ {key:"value", $$key:"hide"} }} ')($rootScope);
+ it('should render object as JSON ignore $$', inject(function($rootScope, $compile) {
+ var element = $compile('
{{ {key:"value", $$key:"hide"} }} ')($rootScope);
$rootScope.$digest();
expect(fromJson(element.text())).toEqual({key:'value'});
}));
@@ -104,22 +104,22 @@ describe("directive", function() {
});
describe('ng:bind-attr', function() {
- it('should bind attributes', inject(function($rootScope) {
- var element = angular.compile('
')($rootScope);
+ it('should bind attributes', inject(function($rootScope, $compile) {
+ var element = $compile('
')($rootScope);
$rootScope.$digest();
expect(element.attr('src')).toEqual('http://localhost/mysrc');
expect(element.attr('alt')).toEqual('myalt');
}));
- it('should not pretty print JSON in attributes', inject(function($rootScope) {
- var element = angular.compile('
')($rootScope);
+ it('should not pretty print JSON in attributes', inject(function($rootScope, $compile) {
+ var element = $compile('
')($rootScope);
$rootScope.$digest();
expect(element.attr('alt')).toEqual('{"a":1}');
}));
});
- it('should remove special attributes on false', inject(function($rootScope) {
- var element = angular.compile('
')($rootScope);
+ it('should remove special attributes on false', inject(function($rootScope, $compile) {
+ var element = $compile('
')($rootScope);
var input = element[0];
expect(input.disabled).toEqual(false);
expect(input.readOnly).toEqual(false);
@@ -136,8 +136,8 @@ describe("directive", function() {
}));
describe('ng:click', function() {
- it('should get called on a click', inject(function($rootScope) {
- var element = angular.compile('
')($rootScope);
+ it('should get called on a click', inject(function($rootScope, $compile) {
+ var element = $compile('
')($rootScope);
$rootScope.$digest();
expect($rootScope.clicked).toBeFalsy();
@@ -145,8 +145,8 @@ describe("directive", function() {
expect($rootScope.clicked).toEqual(true);
}));
- it('should stop event propagation', inject(function($rootScope) {
- var element = angular.compile('
')($rootScope);
+ it('should stop event propagation', inject(function($rootScope, $compile) {
+ var element = $compile('
')($rootScope);
$rootScope.$digest();
expect($rootScope.outer).not.toBeDefined();
expect($rootScope.inner).not.toBeDefined();
@@ -161,8 +161,8 @@ describe("directive", function() {
describe('ng:submit', function() {
- it('should get called on form submit', inject(function($rootScope) {
- var element = angular.compile('
')($rootScope);
$rootScope.$digest();
@@ -174,8 +174,8 @@ describe("directive", function() {
});
describe('ng:class', function() {
- it('should add new and remove old classes dynamically', inject(function($rootScope) {
- var element = angular.compile('
')($rootScope);
+ it('should add new and remove old classes dynamically', inject(function($rootScope, $compile) {
+ var element = $compile('
')($rootScope);
$rootScope.dynClass = 'A';
$rootScope.$digest();
expect(element.hasClass('existing')).toBe(true);
@@ -195,8 +195,8 @@ describe("directive", function() {
}));
- it('should support adding multiple classes via an array', inject(function($rootScope) {
- var element = angular.compile('
')($rootScope);
+ it('should support adding multiple classes via an array', inject(function($rootScope, $compile) {
+ var element = $compile('
')($rootScope);
$rootScope.$digest();
expect(element.hasClass('existing')).toBeTruthy();
expect(element.hasClass('A')).toBeTruthy();
@@ -204,8 +204,8 @@ describe("directive", function() {
}));
- it('should support adding multiple classes via a space delimited string', inject(function($rootScope) {
- var element = angular.compile('
')($rootScope);
+ it('should support adding multiple classes via a space delimited string', inject(function($rootScope, $compile) {
+ var element = $compile('
')($rootScope);
$rootScope.$digest();
expect(element.hasClass('existing')).toBeTruthy();
expect(element.hasClass('A')).toBeTruthy();
@@ -213,8 +213,8 @@ describe("directive", function() {
}));
- it('should preserve class added post compilation with pre-existing classes', inject(function($rootScope) {
- var element = angular.compile('
')($rootScope);
+ it('should preserve class added post compilation with pre-existing classes', inject(function($rootScope, $compile) {
+ var element = $compile('
')($rootScope);
$rootScope.dynClass = 'A';
$rootScope.$digest();
expect(element.hasClass('existing')).toBe(true);
@@ -230,8 +230,8 @@ describe("directive", function() {
}));
- it('should preserve class added post compilation without pre-existing classes"', inject(function($rootScope) {
- var element = angular.compile('
')($rootScope);
+ it('should preserve class added post compilation without pre-existing classes"', inject(function($rootScope, $compile) {
+ var element = $compile('
')($rootScope);
$rootScope.dynClass = 'A';
$rootScope.$digest();
expect(element.hasClass('A')).toBe(true);
@@ -246,8 +246,8 @@ describe("directive", function() {
}));
- it('should preserve other classes with similar name"', inject(function($rootScope) {
- var element = angular.compile('
')($rootScope);
+ it('should preserve other classes with similar name"', inject(function($rootScope, $compile) {
+ var element = $compile('
')($rootScope);
$rootScope.dynCls = 'panel';
$rootScope.$digest();
$rootScope.dynCls = 'foo';
@@ -256,16 +256,16 @@ describe("directive", function() {
}));
- it('should not add duplicate classes', inject(function($rootScope) {
- var element = angular.compile('
')($rootScope);
+ it('should not add duplicate classes', inject(function($rootScope, $compile) {
+ var element = $compile('
')($rootScope);
$rootScope.dynCls = 'panel';
$rootScope.$digest();
expect(element[0].className).toBe('panel bar ng-directive');
}));
- it('should remove classes even if it was specified via class attribute', inject(function($rootScope) {
- var element = angular.compile('
')($rootScope);
+ it('should remove classes even if it was specified via class attribute', inject(function($rootScope, $compile) {
+ var element = $compile('
')($rootScope);
$rootScope.dynCls = 'panel';
$rootScope.$digest();
$rootScope.dynCls = 'window';
@@ -274,8 +274,8 @@ describe("directive", function() {
}));
- it('should remove classes even if they were added by another code', inject(function($rootScope) {
- var element = angular.compile('
')($rootScope);
+ it('should remove classes even if they were added by another code', inject(function($rootScope, $compile) {
+ var element = $compile('
')($rootScope);
$rootScope.dynCls = 'foo';
$rootScope.$digest();
element.addClass('foo');
@@ -285,8 +285,8 @@ describe("directive", function() {
}));
- it('should convert undefined and null values to an empty string', inject(function($rootScope) {
- var element = angular.compile('
')($rootScope);
+ it('should convert undefined and null values to an empty string', inject(function($rootScope, $compile) {
+ var element = $compile('
')($rootScope);
$rootScope.dynCls = [undefined, null];
$rootScope.$digest();
expect(element[0].className).toBe('ng-directive');
@@ -294,8 +294,8 @@ describe("directive", function() {
});
- it('should ng:class odd/even', inject(function($rootScope) {
- var element = angular.compile('
')($rootScope);
+ it('should ng:class odd/even', inject(function($rootScope, $compile) {
+ var element = $compile('')($rootScope);
$rootScope.$digest();
var e1 = jqLite(element[0].childNodes[1]);
var e2 = jqLite(element[0].childNodes[2]);
@@ -306,8 +306,8 @@ describe("directive", function() {
}));
- it('should allow both ng:class and ng:class-odd/even on the same element', inject(function($rootScope) {
- var element = angular.compile('' +
+ it('should allow both ng:class and ng:class-odd/even on the same element', inject(function($rootScope, $compile) {
+ var element = $compile('' +
' ' +
'')($rootScope);
@@ -324,8 +324,8 @@ describe("directive", function() {
}));
- it('should allow both ng:class and ng:class-odd/even with multiple classes', inject(function($rootScope) {
- var element = angular.compile('' +
+ it('should allow both ng:class and ng:class-odd/even with multiple classes', inject(function($rootScope, $compile) {
+ var element = $compile('' +
' ' +
'')($rootScope);
@@ -351,15 +351,15 @@ describe("directive", function() {
describe('ng:style', function() {
- it('should set', inject(function($rootScope) {
- var element = angular.compile('
')($rootScope);
+ it('should set', inject(function($rootScope, $compile) {
+ var element = $compile('
')($rootScope);
$rootScope.$digest();
expect(element.css('height')).toEqual('40px');
}));
- it('should silently ignore undefined style', inject(function($rootScope) {
- var element = angular.compile('
')($rootScope);
+ it('should silently ignore undefined style', inject(function($rootScope, $compile) {
+ var element = $compile('
')($rootScope);
$rootScope.$digest();
expect(element.hasClass('ng-exception')).toBeFalsy();
}));
@@ -368,7 +368,7 @@ describe("directive", function() {
describe('preserving styles set before and after compilation', function() {
var scope, preCompStyle, preCompVal, postCompStyle, postCompVal, element;
- beforeEach(inject(function($rootScope) {
+ beforeEach(inject(function($rootScope, $compile) {
preCompStyle = 'width';
preCompVal = '300px';
postCompStyle = 'height';
@@ -376,7 +376,7 @@ describe("directive", function() {
element = jqLite('
');
element.css(preCompStyle, preCompVal);
jqLite(document.body).append(element);
- angular.compile(element)($rootScope);
+ $compile(element)($rootScope);
scope = $rootScope;
scope.styleObj = {'margin-top': '44px'};
scope.$apply();
@@ -431,9 +431,9 @@ describe("directive", function() {
describe('ng:show', function() {
- it('should show and hide an element', inject(function($rootScope) {
+ it('should show and hide an element', inject(function($rootScope, $compile) {
var element = jqLite('
');
- var element = angular.compile(element)($rootScope);
+ var element = $compile(element)($rootScope);
$rootScope.$digest();
expect(isCssVisible(element)).toEqual(false);
$rootScope.exp = true;
@@ -442,9 +442,9 @@ describe("directive", function() {
}));
- it('should make hidden element visible', inject(function($rootScope) {
+ it('should make hidden element visible', inject(function($rootScope, $compile) {
var element = jqLite('
');
- var element = angular.compile(element)($rootScope);
+ var element = $compile(element)($rootScope);
expect(isCssVisible(element)).toBe(false);
$rootScope.exp = true;
$rootScope.$digest();
@@ -453,9 +453,9 @@ describe("directive", function() {
});
describe('ng:hide', function() {
- it('should hide an element', inject(function($rootScope) {
+ it('should hide an element', inject(function($rootScope, $compile) {
var element = jqLite('
');
- var element = angular.compile(element)($rootScope);
+ var element = $compile(element)($rootScope);
expect(isCssVisible(element)).toBe(true);
$rootScope.exp = true;
$rootScope.$digest();
@@ -485,13 +485,13 @@ describe("directive", function() {
window.temp = undefined;
});
- it('should bind', inject(function($rootScope) {
- var element = angular.compile('
')($rootScope);
+ it('should bind', inject(function($rootScope, $compile) {
+ var element = $compile('
')($rootScope);
expect($rootScope.greeter.greeting).toEqual('hello');
expect($rootScope.greeter.greet('misko')).toEqual('hello misko!');
}));
- it('should support nested controllers', inject(function($rootScope) {
+ it('should support nested controllers', inject(function($rootScope, $compile) {
temp.ChildGreeter = function() {
this.greeting = 'hey';
this.$root.childGreeter = this;
@@ -501,7 +501,7 @@ describe("directive", function() {
return this.greeting + ' dude' + this.suffix;
}
};
- var element = angular.compile('')($rootScope);
+ var element = $compile('')($rootScope);
expect($rootScope.greeting).not.toBeDefined();
expect($rootScope.greeter.greeting).toEqual('hello');
expect($rootScope.greeter.greet('misko')).toEqual('hello misko!');
@@ -512,33 +512,33 @@ describe("directive", function() {
expect(element.text()).toEqual('hey dude!');
}));
- it('should infer injection arguments', inject(function($rootScope) {
+ it('should infer injection arguments', inject(function($rootScope, $compile) {
temp.MyController = function($xhr){
this.$root.someService = $xhr;
};
- var element = angular.compile('
')($rootScope);
+ var element = $compile('
')($rootScope);
expect($rootScope.someService).toBe($rootScope.$service('$xhr'));
}));
});
describe('ng:cloak', function() {
- it('should get removed when an element is compiled', inject(function($rootScope) {
+ it('should get removed when an element is compiled', inject(function($rootScope, $compile) {
var element = jqLite('
');
expect(element.attr('ng:cloak')).toBe('');
- angular.compile(element);
+ $compile(element);
expect(element.attr('ng:cloak')).toBeUndefined();
}));
- it('should remove ng-cloak class from a compiled element', inject(function($rootScope) {
+ it('should remove ng-cloak class from a compiled element', inject(function($rootScope, $compile) {
var element = jqLite('
');
expect(element.hasClass('foo')).toBe(true);
expect(element.hasClass('ng-cloak')).toBe(true);
expect(element.hasClass('bar')).toBe(true);
- angular.compile(element);
+ $compile(element);
expect(element.hasClass('foo')).toBe(true);
expect(element.hasClass('ng-cloak')).toBe(false);
diff --git a/test/markupSpec.js b/test/markupSpec.js
index d97dbcb5..c23cc62d 100644
--- a/test/markupSpec.js
+++ b/test/markupSpec.js
@@ -2,16 +2,16 @@
describe("markups", function() {
- it('should translate {{}} in text', inject(function($rootScope) {
- var element = angular.compile('hello {{name}}!
')($rootScope)
+ it('should translate {{}} in text', inject(function($rootScope, $compile) {
+ var element = $compile('hello {{name}}!
')($rootScope)
expect(sortedHtml(element)).toEqual('hello !
');
$rootScope.name = 'Misko';
$rootScope.$digest();
expect(sortedHtml(element)).toEqual('hello Misko !
');
}));
- it('should translate {{}} in terminal nodes', inject(function($rootScope) {
- var element = angular.compile('Greet {{name}}! ')($rootScope)
+ it('should translate {{}} in terminal nodes', inject(function($rootScope, $compile) {
+ var element = $compile('Greet {{name}}! ')($rootScope)
$rootScope.$digest();
expect(sortedHtml(element).replace(' selected="true"', '')).
toEqual('' +
@@ -25,8 +25,8 @@ describe("markups", function() {
' ');
}));
- it('should translate {{}} in attributes', inject(function($rootScope) {
- var element = angular.compile('
')($rootScope)
+ it('should translate {{}} in attributes', inject(function($rootScope, $compile) {
+ var element = $compile('
')($rootScope)
expect(element.attr('ng:bind-attr')).toEqual('{"src":"http://server/{{path}}.png"}');
$rootScope.path = 'a/b';
$rootScope.$digest();
@@ -55,37 +55,37 @@ describe("markups", function() {
});
- it('should populate value attribute on OPTION', inject(function($rootScope) {
- var element = angular.compile('abc ')($rootScope)
+ it('should populate value attribute on OPTION', inject(function($rootScope, $compile) {
+ var element = $compile('abc ')($rootScope)
expect(element).toHaveValue('abc');
}));
- it('should ignore value if already exists', inject(function($rootScope) {
- var element = angular.compile('xyz ')($rootScope)
+ it('should ignore value if already exists', inject(function($rootScope, $compile) {
+ var element = $compile('xyz ')($rootScope)
expect(element).toHaveValue('abc');
}));
- it('should set value even if newlines present', inject(function($rootScope) {
- var element = angular.compile('\nabc\n ')($rootScope)
+ it('should set value even if newlines present', inject(function($rootScope, $compile) {
+ var element = $compile('\nabc\n ')($rootScope)
expect(element).toHaveValue('\nabc\n');
}));
- it('should set value even if self closing HTML', inject(function($rootScope) {
+ it('should set value even if self closing HTML', inject(function($rootScope, $compile) {
// IE removes the \n from option, which makes this test pointless
if (msie) return;
- var element = angular.compile('\n ')($rootScope)
+ var element = $compile('\n ')($rootScope)
expect(element).toHaveValue('\n');
}));
});
- it('should bind href', inject(function($rootScope) {
- var element = angular.compile(' ')($rootScope)
+ it('should bind href', inject(function($rootScope, $compile) {
+ var element = $compile(' ')($rootScope)
expect(sortedHtml(element)).toEqual(' ');
}));
- it('should bind disabled', inject(function($rootScope) {
- var element = angular.compile('Button ')($rootScope)
+ it('should bind disabled', inject(function($rootScope, $compile) {
+ var element = $compile('Button ')($rootScope)
$rootScope.isDisabled = false;
$rootScope.$digest();
expect(element.attr('disabled')).toBeFalsy();
@@ -94,8 +94,8 @@ describe("markups", function() {
expect(element.attr('disabled')).toBeTruthy();
}));
- it('should bind checked', inject(function($rootScope) {
- var element = angular.compile(' ')($rootScope)
+ it('should bind checked', inject(function($rootScope, $compile) {
+ var element = $compile(' ')($rootScope)
$rootScope.isChecked = false;
$rootScope.$digest();
expect(element.attr('checked')).toBeFalsy();
@@ -104,8 +104,8 @@ describe("markups", function() {
expect(element.attr('checked')).toBeTruthy();
}));
- it('should bind selected', inject(function($rootScope) {
- var element = angular.compile('Greetings! ')($rootScope)
+ it('should bind selected', inject(function($rootScope, $compile) {
+ var element = $compile('Greetings! ')($rootScope)
jqLite(document.body).append(element)
$rootScope.isSelected=false;
$rootScope.$digest();
@@ -115,8 +115,8 @@ describe("markups", function() {
expect(element.children()[1].selected).toBeTruthy();
}));
- it('should bind readonly', inject(function($rootScope) {
- var element = angular.compile(' ')($rootScope)
+ it('should bind readonly', inject(function($rootScope, $compile) {
+ var element = $compile(' ')($rootScope)
$rootScope.isReadonly=false;
$rootScope.$digest();
expect(element.attr('readOnly')).toBeFalsy();
@@ -125,8 +125,8 @@ describe("markups", function() {
expect(element.attr('readOnly')).toBeTruthy();
}));
- it('should bind multiple', inject(function($rootScope) {
- var element = angular.compile(' ')($rootScope)
+ it('should bind multiple', inject(function($rootScope, $compile) {
+ var element = $compile(' ')($rootScope)
$rootScope.isMultiple=false;
$rootScope.$digest();
expect(element.attr('multiple')).toBeFalsy();
@@ -135,57 +135,57 @@ describe("markups", function() {
expect(element.attr('multiple')).toBeTruthy();
}));
- it('should bind src', inject(function($rootScope) {
- var element = angular.compile('
')($rootScope)
+ it('should bind src', inject(function($rootScope, $compile) {
+ var element = $compile('
')($rootScope)
$rootScope.url = 'http://localhost/';
$rootScope.$digest();
expect(element.attr('src')).toEqual('http://localhost/');
}));
- it('should bind href and merge with other attrs', inject(function($rootScope) {
- var element = angular.compile(' ')($rootScope)
+ it('should bind href and merge with other attrs', inject(function($rootScope, $compile) {
+ var element = $compile(' ')($rootScope)
expect(sortedHtml(element)).toEqual(' ');
}));
- it('should bind Text with no Bindings', inject(function() {
+ it('should bind Text with no Bindings', inject(function($compile) {
var $rootScope;
function newScope (){
return $rootScope = angular.injector()('$rootScope');
}
forEach(['checked', 'disabled', 'multiple', 'readonly', 'selected'], function(name) {
- var element = angular.compile('
')(newScope())
+ var element = $compile('
')(newScope())
expect(element.attr('ng:bind-attr')).toBe('{"' + name +'":"some"}');
$rootScope.$digest();
expect(element.attr(name)).toBe(name);
dealoc(element);
});
- var element = angular.compile('
')(newScope())
+ var element = $compile('
')(newScope())
$rootScope.$digest();
expect(sortedHtml(element)).toEqual('
');
dealoc(element);
- var element = angular.compile('
')(newScope())
+ var element = $compile('
')(newScope())
$rootScope.$digest();
expect(sortedHtml(element)).toEqual('
');
dealoc(element);
}));
- it('should Parse Text With No Bindings', inject(function($rootScope) {
+ it('should Parse Text With No Bindings', inject(function($rootScope, $compile) {
var parts = parseBindings("a");
assertEquals(parts.length, 1);
assertEquals(parts[0], "a");
assertTrue(!binding(parts[0]));
}));
- it('should Parse Empty Text', inject(function($rootScope) {
+ it('should Parse Empty Text', inject(function($rootScope, $compile) {
var parts = parseBindings("");
assertEquals(parts.length, 1);
assertEquals(parts[0], "");
assertTrue(!binding(parts[0]));
}));
- it('should Parse Inner Binding', inject(function($rootScope) {
+ it('should Parse Inner Binding', inject(function($rootScope, $compile) {
var parts = parseBindings("a{{b}}C");
assertEquals(parts.length, 3);
assertEquals(parts[0], "a");
@@ -196,7 +196,7 @@ describe("markups", function() {
assertTrue(!binding(parts[2]));
}));
- it('should Parse Ending Binding', inject(function($rootScope) {
+ it('should Parse Ending Binding', inject(function($rootScope, $compile) {
var parts = parseBindings("a{{b}}");
assertEquals(parts.length, 2);
assertEquals(parts[0], "a");
@@ -205,7 +205,7 @@ describe("markups", function() {
assertEquals(binding(parts[1]), "b");
}));
- it('should Parse Begging Binding', inject(function($rootScope) {
+ it('should Parse Begging Binding', inject(function($rootScope, $compile) {
var parts = parseBindings("{{b}}c");
assertEquals(parts.length, 2);
assertEquals(parts[0], "{{b}}");
@@ -214,14 +214,14 @@ describe("markups", function() {
assertTrue(!binding(parts[1]));
}));
- it('should Parse Loan Binding', inject(function($rootScope) {
+ it('should Parse Loan Binding', inject(function($rootScope, $compile) {
var parts = parseBindings("{{b}}");
assertEquals(parts.length, 1);
assertEquals(parts[0], "{{b}}");
assertEquals(binding(parts[0]), "b");
}));
- it('should Parse Two Bindings', inject(function($rootScope) {
+ it('should Parse Two Bindings', inject(function($rootScope, $compile) {
var parts = parseBindings("{{b}}{{c}}");
assertEquals(parts.length, 2);
assertEquals(parts[0], "{{b}}");
@@ -230,7 +230,7 @@ describe("markups", function() {
assertEquals(binding(parts[1]), "c");
}));
- it('should Parse Two Bindings With Text In Middle', inject(function($rootScope) {
+ it('should Parse Two Bindings With Text In Middle', inject(function($rootScope, $compile) {
var parts = parseBindings("{{b}}x{{c}}");
assertEquals(parts.length, 3);
assertEquals(parts[0], "{{b}}");
@@ -241,7 +241,7 @@ describe("markups", function() {
assertEquals(binding(parts[2]), "c");
}));
- it('should Parse Multiline', inject(function($rootScope) {
+ it('should Parse Multiline', inject(function($rootScope, $compile) {
var parts = parseBindings('"X\nY{{A\nB}}C\nD"');
assertTrue(!!binding('{{A\nB}}'));
assertEquals(parts.length, 3);
@@ -250,7 +250,7 @@ describe("markups", function() {
assertEquals(parts[2], 'C\nD"');
}));
- it('should Has Binding', inject(function($rootScope) {
+ it('should Has Binding', inject(function($rootScope, $compile) {
assertTrue(hasBindings(parseBindings("{{a}}")));
assertTrue(!hasBindings(parseBindings("a")));
assertTrue(hasBindings(parseBindings("{{b}}x{{c}}")));
diff --git a/test/service/compilerSpec.js b/test/service/compilerSpec.js
index 2dec1396..4e0dbed6 100644
--- a/test/service/compilerSpec.js
+++ b/test/service/compilerSpec.js
@@ -1,10 +1,12 @@
'use strict';
describe('compiler', function() {
- var compiler, markup, attrMarkup, directives, widgets, compile, log, scope;
+ var compiler, textMmarkup, attrMarkup, directives, widgets, compile, log, $rootScope;
- beforeEach(inject(function($rootScope) {
- log = "";
+ beforeEach(inject(function(service){
+ textMmarkup = [];
+ attrMarkup = [];
+ widgets = extensionMap({}, 'widget');
directives = {
hello: function(expression, element){
log += "hello ";
@@ -23,29 +25,25 @@ describe('compiler', function() {
}
};
- markup = [];
- attrMarkup = [];
- widgets = extensionMap({}, 'widget');
- compiler = new Compiler(markup, attrMarkup, directives, widgets);
- compile = function(html){
- var e = jqLite("" + html + "
");
- compiler.compile(e)($rootScope);
- return scope = $rootScope;
- };
+ log = "";
+ service('$textMarkup', valueFn(textMmarkup));
+ service('$attrMarkup', valueFn(attrMarkup));
+ service('$directive', valueFn(directives));
+ service('$widget', valueFn(widgets));
}));
- it('should not allow compilation of multiple roots', function() {
+ it('should not allow compilation of multiple roots', inject(function($rootScope, $compile) {
expect(function() {
- compiler.compile('A
');
+ $compile('A
');
}).toThrow("Cannot compile multiple element roots: " + ie("A
"));
function ie(text) {
return msie < 9 ? uppercase(text) : text;
}
- });
+ }));
- it('should recognize a directive', inject(function($rootScope) {
+ it('should recognize a directive', inject(function($rootScope, $compile) {
var e = jqLite('
');
directives.directive = function(expression, element){
log += "found";
@@ -55,42 +53,42 @@ describe('compiler', function() {
log += ":init";
};
};
- var template = compiler.compile(e);
+ var linkFn = $compile(e);
expect(log).toEqual("found");
- scope = template($rootScope);
+ linkFn($rootScope);
expect(e.hasClass('ng-directive')).toEqual(true);
expect(log).toEqual("found:init");
}));
- it('should recurse to children', function() {
- scope = compile('
');
+ it('should recurse to children', inject(function($rootScope, $compile) {
+ $compile('
')($rootScope);
expect(log).toEqual("hello misko");
- });
+ }));
- it('should observe scope', function() {
- scope = compile(' ');
+ it('should observe scope', inject(function($rootScope, $compile) {
+ $compile(' ')($rootScope);
expect(log).toEqual("");
- scope.$digest();
- scope.name = 'misko';
- scope.$digest();
- scope.$digest();
- scope.name = 'adam';
- scope.$digest();
- scope.$digest();
+ $rootScope.$digest();
+ $rootScope.name = 'misko';
+ $rootScope.$digest();
+ $rootScope.$digest();
+ $rootScope.name = 'adam';
+ $rootScope.$digest();
+ $rootScope.$digest();
expect(log).toEqual(":misko:adam");
- });
+ }));
- it('should prevent descend', function() {
+ it('should prevent descend', inject(function($rootScope, $compile) {
directives.stop = function() { this.descend(false); };
- scope = compile(' ');
+ $compile(' ')($rootScope);
expect(log).toEqual("hello misko");
- });
+ }));
- it('should allow creation of templates', inject(function($rootScope) {
+ it('should allow creation of templates', inject(function($rootScope, $compile) {
directives.duplicate = function(expr, element){
element.replaceWith(document.createComment("marker"));
element.removeAttr("duplicate");
@@ -103,32 +101,32 @@ describe('compiler', function() {
});
};
};
- scope = compile('beforex after');
- expect(sortedHtml(scope.$element)).
+ $compile('beforex after
')($rootScope);
+ expect(sortedHtml($rootScope.$element)).
toEqual('' +
'before<#comment>#comment>' +
'after' +
'
');
- scope.value = 1;
- scope.$digest();
- expect(sortedHtml(scope.$element)).
+ $rootScope.value = 1;
+ $rootScope.$digest();
+ expect(sortedHtml($rootScope.$element)).
toEqual('' +
'before<#comment>#comment>' +
'x ' +
'after' +
'
');
- scope.value = 2;
- scope.$digest();
- expect(sortedHtml(scope.$element)).
+ $rootScope.value = 2;
+ $rootScope.$digest();
+ expect(sortedHtml($rootScope.$element)).
toEqual('' +
'before<#comment>#comment>' +
'x ' +
'x ' +
'after' +
'
');
- scope.value = 3;
- scope.$digest();
- expect(sortedHtml(scope.$element)).
+ $rootScope.value = 3;
+ $rootScope.$digest();
+ expect(sortedHtml($rootScope.$element)).
toEqual('' +
'before<#comment>#comment>' +
'
x ' +
@@ -139,21 +137,22 @@ describe('compiler', function() {
}));
- it('should process markup before directives', function() {
- markup.push(function(text, textNode, parentNode) {
+ it('should process markup before directives', inject(function($rootScope, $compile) {
+ textMmarkup.push(function(text, textNode, parentNode) {
if (text == 'middle') {
expect(textNode.text()).toEqual(text);
parentNode.attr('hello', text);
textNode[0].nodeValue = 'replaced';
}
});
- scope = compile('before
middle after');
- expect(sortedHtml(scope.$element[0], true)).toEqual('
beforereplaced after
');
+ $compile('
beforemiddle after
')($rootScope);
+ expect(sortedHtml($rootScope.$element[0], true)).
+ toEqual('
beforereplaced after
');
expect(log).toEqual("hello middle");
- });
+ }));
- it('should replace widgets', function() {
+ it('should replace widgets', inject(function($rootScope, $compile) {
widgets['NG:BUTTON'] = function(element) {
expect(element.hasClass('ng-widget')).toEqual(true);
element.replaceWith('
button
');
@@ -161,13 +160,13 @@ describe('compiler', function() {
log += 'init';
};
};
- scope = compile('
push me ');
- expect(lowercase(scope.$element[0].innerHTML)).toEqual('
button
');
+ $compile('
push me
')($rootScope);
+ expect(lowercase($rootScope.$element[0].innerHTML)).toEqual('
button
');
expect(log).toEqual('init');
- });
+ }));
- it('should use the replaced element after calling widget', function() {
+ it('should use the replaced element after calling widget', inject(function($rootScope, $compile) {
widgets['H1'] = function(element) {
// HTML elements which are augmented by acting as widgets, should not be marked as so
expect(element.hasClass('ng-widget')).toEqual(false);
@@ -177,17 +176,17 @@ describe('compiler', function() {
this.directives(true);
return noop;
};
- markup.push(function(text, textNode, parent){
+ textMmarkup.push(function(text, textNode, parent){
if (text == '{{1+2}}')
parent.text('3');
});
- scope = compile('
ignore me ');
- expect(scope.$element.text()).toEqual('3');
- });
+ $compile('
ignore me ')($rootScope);
+ expect($rootScope.$element.text()).toEqual('3');
+ }));
- it('should allow multiple markups per text element', function() {
- markup.push(function(text, textNode, parent){
+ it('should allow multiple markups per text element', inject(function($rootScope, $compile) {
+ textMmarkup.push(function(text, textNode, parent){
var index = text.indexOf('---');
if (index > -1) {
textNode.after(text.substring(index + 3));
@@ -196,7 +195,7 @@ describe('compiler', function() {
textNode.remove();
}
});
- markup.push(function(text, textNode, parent){
+ textMmarkup.push(function(text, textNode, parent){
var index = text.indexOf('===');
if (index > -1) {
textNode.after(text.substring(index + 3));
@@ -205,14 +204,13 @@ describe('compiler', function() {
textNode.remove();
}
});
- scope = compile('A---B---C===D');
- expect(sortedHtml(scope.$element)).toEqual('
');
- });
+ $compile('
A---B---C===D
')($rootScope);
+ expect(sortedHtml($rootScope.$element)).toEqual('
');
+ }));
- it('should add class for namespace elements', function() {
- scope = compile('
abc ');
- var space = jqLite(scope.$element[0].firstChild);
- expect(space.hasClass('ng-space')).toEqual(true);
- });
+ it('should add class for namespace elements', inject(function($rootScope, $compile) {
+ var element = $compile('
abc ')($rootScope);
+ expect(element.hasClass('ng-space')).toEqual(true);
+ }));
});
diff --git a/test/testabilityPatch.js b/test/testabilityPatch.js
index 3d964149..154db7d0 100644
--- a/test/testabilityPatch.js
+++ b/test/testabilityPatch.js
@@ -125,7 +125,6 @@ function inject(){
function resetAngularPublic() {
extend(angular, {
'element': jqLite,
- 'compile': compile,
'copy': copy,
'extend': extend,
'equals': equals,
diff --git a/test/widget/formSpec.js b/test/widget/formSpec.js
index a30f21eb..7a92dbf4 100644
--- a/test/widget/formSpec.js
+++ b/test/widget/formSpec.js
@@ -8,17 +8,17 @@ describe('form', function() {
});
- it('should attach form to DOM', inject(function($rootScope) {
+ it('should attach form to DOM', inject(function($rootScope, $compile) {
doc = angular.element('
');
- angular.compile(doc)($rootScope);
+ $compile(doc)($rootScope);
expect($rootScope.myForm).toBeTruthy();
expect(doc.data('$form')).toBeTruthy();
expect(doc.data('$form')).toEqual($rootScope.myForm);
}));
- it('should have ng-valide/ng-invalid style', inject(function($rootScope) {
+ it('should have ng-valide/ng-invalid style', inject(function($rootScope, $compile) {
doc = angular.element('
');
inputElement = formElement.find('input');
- angular.compile(doc)(scope);
+ $compile(doc)(scope);
form = formElement.inheritedData('$form');
};
@@ -90,16 +94,16 @@ describe('widget: input', function() {
});
- it('should change non-html5 types to text', inject(function($rootScope) {
+ it('should change non-html5 types to text', inject(function($rootScope, $compile) {
doc = angular.element('
');
- angular.compile(doc)($rootScope);
+ $compile(doc)($rootScope);
expect(doc.find('input').attr('type')).toEqual('text');
}));
- it('should not change html5 types to text', inject(function($rootScope) {
+ it('should not change html5 types to text', inject(function($rootScope, $compile) {
doc = angular.element('
');
- angular.compile(doc)($rootScope);
+ $compile(doc)($rootScope);
expect(doc.find('input')[0].getAttribute('type')).toEqual('number');
}));
});
@@ -454,7 +458,7 @@ describe('widget: input', function() {
describe('scope declaration', function() {
- it('should read the declaration from scope', inject(function($rootScope) {
+ it('should read the declaration from scope', inject(function($rootScope, $compile) {
var input, $formFactory;
element = angular.element('
');
$rootScope.MyType = function($f, i) {
@@ -463,18 +467,18 @@ describe('widget: input', function() {
};
$rootScope.MyType.$inject = ['$formFactory'];
- angular.compile(element)($rootScope);
+ $compile(element)($rootScope);
expect($formFactory).toBe($rootScope.$service('$formFactory'));
expect(input[0]).toBe(element[0]);
}));
- it('should throw an error of Controller not declared in scope', inject(function($rootScope) {
+ it('should throw an error of Controller not declared in scope', inject(function($rootScope, $compile) {
var input, $formFactory;
element = angular.element('
');
var error;
try {
- angular.compile(element)($rootScope);
+ $compile(element)($rootScope);
error = 'no error thrown';
} catch (e) {
error = e;
@@ -577,9 +581,9 @@ describe('widget: input', function() {
{'ng:maxlength': 3});
- it('should throw an error when scope pattern can\'t be found', inject(function($rootScope) {
+ it('should throw an error when scope pattern can\'t be found', inject(function($rootScope, $compile) {
var el = jqLite('
');
- angular.compile(el)($rootScope);
+ $compile(el)($rootScope);
el.val('xx');
browserTrigger(el, 'keydown');
diff --git a/test/widget/selectSpec.js b/test/widget/selectSpec.js
index 31e5223d..5d92e674 100644
--- a/test/widget/selectSpec.js
+++ b/test/widget/selectSpec.js
@@ -3,7 +3,7 @@
describe('select', function() {
var compile = null, element = null, scope = null;
- beforeEach(inject(function($rootScope) {
+ beforeEach(inject(function($compile, $rootScope) {
scope = $rootScope;
element = null;
compile = function(html, parent) {
@@ -13,7 +13,7 @@ describe('select', function() {
} else {
element = jqLite(html);
}
- angular.compile(element)($rootScope);
+ $compile(element)($rootScope);
scope.$apply();
return scope;
};
diff --git a/test/widgetsSpec.js b/test/widgetsSpec.js
index 1a4c5e6c..d2204540 100644
--- a/test/widgetsSpec.js
+++ b/test/widgetsSpec.js
@@ -1,9 +1,10 @@
'use strict';
describe("widget", function() {
- describe('ng:switch', inject(function($rootScope) {
- it('should switch on value change', inject(function($rootScope) {
- var element = angular.compile('
' +
+ describe('ng:switch', inject(function($rootScope, $compile) {
+ it('should switch on value change', inject(function($rootScope, $compile) {
+ var element = $compile(
+ '' +
'first:{{name}}
' +
'second:{{name}}
' +
'true:{{name}}
' +
@@ -27,8 +28,8 @@ describe("widget", function() {
}));
- it('should switch on switch-when-default', inject(function($rootScope) {
- var element = angular.compile(
+ it('should switch on switch-when-default', inject(function($rootScope, $compile) {
+ var element = $compile(
'' +
'one
' +
'other
' +
@@ -41,8 +42,8 @@ describe("widget", function() {
}));
- it('should call change on switch', inject(function($rootScope) {
- var element = angular.compile(
+ it('should call change on switch', inject(function($rootScope, $compile) {
+ var element = $compile(
'' +
'{{name}}
' +
' ')($rootScope);
@@ -54,10 +55,10 @@ describe("widget", function() {
}));
- describe('ng:include', inject(function($rootScope) {
- it('should include on external file', inject(function($rootScope) {
+ describe('ng:include', inject(function($rootScope, $compile) {
+ it('should include on external file', inject(function($rootScope, $compile) {
var element = jqLite(' ');
- var element = angular.compile(element)($rootScope);
+ var element = $compile(element)($rootScope);
$rootScope.childScope = $rootScope.$new();
$rootScope.childScope.name = 'misko';
$rootScope.url = 'myUrl';
@@ -67,9 +68,9 @@ describe("widget", function() {
}));
- it('should remove previously included text if a falsy value is bound to src', inject(function($rootScope) {
+ it('should remove previously included text if a falsy value is bound to src', inject(function($rootScope, $compile) {
var element = jqLite(' ');
- var element = angular.compile(element)($rootScope);
+ var element = $compile(element)($rootScope);
$rootScope.childScope = $rootScope.$new();
$rootScope.childScope.name = 'igor';
$rootScope.url = 'myUrl';
@@ -85,9 +86,9 @@ describe("widget", function() {
}));
- it('should allow this for scope', inject(function($rootScope) {
+ it('should allow this for scope', inject(function($rootScope, $compile) {
var element = jqLite(' ');
- var element = angular.compile(element)($rootScope);
+ var element = $compile(element)($rootScope);
$rootScope.url = 'myUrl';
$rootScope.$service('$xhr.cache').data.myUrl = {value:'{{"abc"}}'};
$rootScope.$digest();
@@ -101,9 +102,9 @@ describe("widget", function() {
}));
- it('should evaluate onload expression when a partial is loaded', inject(function($rootScope) {
+ it('should evaluate onload expression when a partial is loaded', inject(function($rootScope, $compile) {
var element = jqLite(' ');
- var element = angular.compile(element)($rootScope);
+ var element = $compile(element)($rootScope);
expect($rootScope.loaded).not.toBeDefined();
@@ -115,9 +116,9 @@ describe("widget", function() {
}));
- it('should destroy old scope', inject(function($rootScope) {
+ it('should destroy old scope', inject(function($rootScope, $compile) {
var element = jqLite(' ');
- var element = angular.compile(element)($rootScope);
+ var element = $compile(element)($rootScope);
expect($rootScope.$$childHead).toBeFalsy();
@@ -133,13 +134,13 @@ describe("widget", function() {
}));
- describe('a', inject(function($rootScope) {
- it('should prevent default action to be executed when href is empty', inject(function($rootScope) {
+ describe('a', inject(function($rootScope, $compile) {
+ it('should prevent default action to be executed when href is empty', inject(function($rootScope, $compile) {
var orgLocation = document.location.href,
preventDefaultCalled = false,
event;
- var element = angular.compile('empty link ')($rootScope);
+ var element = $compile('empty link ')($rootScope);
if (msie < 9) {
@@ -169,9 +170,9 @@ describe("widget", function() {
}));
- describe('@ng:repeat', inject(function($rootScope) {
- it('should ng:repeat over array', inject(function($rootScope) {
- var element = angular.compile(
+ describe('@ng:repeat', inject(function($rootScope, $compile) {
+ it('should ng:repeat over array', inject(function($rootScope, $compile) {
+ var element = $compile(
'')($rootScope);
@@ -197,8 +198,8 @@ describe("widget", function() {
expect(element.text()).toEqual('brad;');
}));
- it('should ng:repeat over object', inject(function($rootScope) {
- var element = angular.compile(
+ it('should ng:repeat over object', inject(function($rootScope, $compile) {
+ var element = $compile(
'')($rootScope);
@@ -207,12 +208,12 @@ describe("widget", function() {
expect(element.text()).toEqual('misko:swe;shyam:set;');
}));
- it('should not ng:repeat over parent properties', inject(function($rootScope) {
+ it('should not ng:repeat over parent properties', inject(function($rootScope, $compile) {
var Class = function() {};
Class.prototype.abc = function() {};
Class.prototype.value = 'abc';
- var element = angular.compile(
+ var element = $compile(
'')($rootScope);
@@ -222,16 +223,16 @@ describe("widget", function() {
expect(element.text()).toEqual('name:value;');
}));
- it('should error on wrong parsing of ng:repeat', inject(function($rootScope) {
+ it('should error on wrong parsing of ng:repeat', inject(function($rootScope, $compile) {
expect(function() {
- var element = angular.compile('')($rootScope);
+ var element = $compile('')($rootScope);
}).toThrow("Expected ng:repeat in form of '_item_ in _collection_' but got 'i dont parse'.");
$logMock.error.logs.shift();
}));
- it('should expose iterator offset as $index when iterating over arrays', inject(function($rootScope) {
- var element = angular.compile(
+ it('should expose iterator offset as $index when iterating over arrays', inject(function($rootScope, $compile) {
+ var element = $compile(
'')($rootScope);
@@ -240,8 +241,8 @@ describe("widget", function() {
expect(element.text()).toEqual('misko0|shyam1|frodo2|');
}));
- it('should expose iterator offset as $index when iterating over objects', inject(function($rootScope) {
- var element = angular.compile(
+ it('should expose iterator offset as $index when iterating over objects', inject(function($rootScope, $compile) {
+ var element = $compile(
'')($rootScope);
@@ -250,9 +251,8 @@ describe("widget", function() {
expect(element.text()).toEqual('frodo:f0|misko:m1|shyam:s2|');
}));
- it('should expose iterator position as $position when iterating over arrays',
- inject(function($rootScope) {
- var element = angular.compile(
+ it('should expose iterator position as $position when iterating over arrays', inject(function($rootScope, $compile) {
+ var element = $compile(
'')($rootScope);
@@ -270,8 +270,8 @@ describe("widget", function() {
expect(element.text()).toEqual('misko:first|shyam:last|');
}));
- it('should expose iterator position as $position when iterating over objects', inject(function($rootScope) {
- var element = angular.compile(
+ it('should expose iterator position as $position when iterating over objects', inject(function($rootScope, $compile) {
+ var element = $compile(
'' +
'' +
' ' +
@@ -286,8 +286,8 @@ describe("widget", function() {
expect(element.text()).toEqual('misko:m:first|shyam:s:last|');
}));
- it('should ignore $ and $$ properties', inject(function($rootScope) {
- var element = angular.compile('')($rootScope);
+ it('should ignore $ and $$ properties', inject(function($rootScope, $compile) {
+ var element = $compile('')($rootScope);
$rootScope.items = ['a', 'b', 'c'];
$rootScope.items.$$hashkey = 'xxx';
$rootScope.items.$root = 'yyy';
@@ -296,8 +296,8 @@ describe("widget", function() {
expect(element.text()).toEqual('a|b|c|');
}));
- it('should repeat over nested arrays', inject(function($rootScope) {
- var element = angular.compile(
+ it('should repeat over nested arrays', inject(function($rootScope, $compile) {
+ var element = $compile(
'' +
'' +
'{{group}}|
X' +
@@ -309,8 +309,8 @@ describe("widget", function() {
expect(element.text()).toEqual('a|b|Xc|d|X');
}));
- it('should ignore non-array element properties when iterating over an array', inject(function($rootScope) {
- var element = angular.compile('')($rootScope);
+ it('should ignore non-array element properties when iterating over an array', inject(function($rootScope, $compile) {
+ var element = $compile('')($rootScope);
$rootScope.array = ['a', 'b', 'c'];
$rootScope.array.foo = '23';
$rootScope.array.bar = function() {};
@@ -319,8 +319,8 @@ describe("widget", function() {
expect(element.text()).toBe('a|b|c|');
}));
- it('should iterate over non-existent elements of a sparse array', inject(function($rootScope) {
- var element = angular.compile('')($rootScope);
+ it('should iterate over non-existent elements of a sparse array', inject(function($rootScope, $compile) {
+ var element = $compile('')($rootScope);
$rootScope.array = ['a', 'b'];
$rootScope.array[4] = 'c';
$rootScope.array[6] = 'd';
@@ -333,8 +333,8 @@ describe("widget", function() {
describe('stability', function() {
var a, b, c, d, lis, element;
- beforeEach(inject(function($rootScope) {
- element = angular.compile(
+ beforeEach(inject(function($rootScope, $compile) {
+ element = $compile(
'')($rootScope);
@@ -348,7 +348,7 @@ describe("widget", function() {
lis = element.find('li');
}));
- it('should preserve the order of elements', inject(function($rootScope) {
+ it('should preserve the order of elements', inject(function($rootScope, $compile) {
$rootScope.items = [a, c, d];
$rootScope.$digest();
var newElements = element.find('li');
@@ -357,7 +357,7 @@ describe("widget", function() {
expect(newElements[2]).not.toEqual(lis[1]);
}));
- it('should support duplicates', inject(function($rootScope) {
+ it('should support duplicates', inject(function($rootScope, $compile) {
$rootScope.items = [a, a, b, c];
$rootScope.$digest();
var newElements = element.find('li');
@@ -382,7 +382,7 @@ describe("widget", function() {
expect(newElements[3]).toEqual(lis[3]);
}));
- it('should remove last item when one duplicate instance is removed', inject(function($rootScope) {
+ it('should remove last item when one duplicate instance is removed', inject(function($rootScope, $compile) {
$rootScope.items = [a, a, a];
$rootScope.$digest();
lis = element.find('li');
@@ -395,7 +395,7 @@ describe("widget", function() {
expect(newElements[1]).toEqual(lis[1]);
}));
- it('should reverse items when the collection is reversed', inject(function($rootScope) {
+ it('should reverse items when the collection is reversed', inject(function($rootScope, $compile) {
$rootScope.items = [a, b, c];
$rootScope.$digest();
lis = element.find('li');
@@ -413,8 +413,8 @@ describe("widget", function() {
describe('@ng:non-bindable', function() {
- it('should prevent compilation of the owning element and its children', inject(function($rootScope) {
- var element = angular.compile('
')($rootScope);
+ it('should prevent compilation of the owning element and its children', inject(function($rootScope, $compile) {
+ var element = $compile('
')($rootScope);
$rootScope.name = 'misko';
$rootScope.$digest();
expect(element.text()).toEqual('');
@@ -424,19 +424,19 @@ describe("widget", function() {
describe('ng:view', function() {
var element;
- beforeEach(inject(function($rootScope) {
- element = angular.compile(' ')($rootScope);
+ beforeEach(inject(function($rootScope, $compile) {
+ element = $compile(' ')($rootScope);
}));
- it('should do nothing when no routes are defined', inject(function($rootScope, $location) {
+ it('should do nothing when no routes are defined', inject(function($rootScope, $compile, $location) {
$location.path('/unknown');
$rootScope.$digest();
expect(element.text()).toEqual('');
}));
- it('should load content via xhr when route changes', inject(function($rootScope, $browser, $location, $route) {
+ it('should load content via xhr when route changes', inject(function($rootScope, $compile, $browser, $location, $route) {
$route.when('/foo', {template: 'myUrl1'});
$route.when('/bar', {template: 'myUrl2'});
@@ -456,7 +456,7 @@ describe("widget", function() {
}));
it('should remove all content when location changes to an unknown route',
- inject(function($rootScope, $location, $browser, $route) {
+ inject(function($rootScope, $compile, $location, $browser, $route) {
$route.when('/foo', {template: 'myUrl1'});
$location.path('/foo');
@@ -471,7 +471,7 @@ describe("widget", function() {
}));
it('should chain scopes and propagate evals to the child scope',
- inject(function($rootScope, $location, $browser, $route) {
+ inject(function($rootScope, $compile, $location, $browser, $route) {
$route.when('/foo', {template: 'myUrl1'});
$rootScope.parentVar = 'parent';
@@ -496,7 +496,7 @@ describe("widget", function() {
var $route = injector('$route');
$route.when('/foo', {controller: angular.noop, template: 'viewPartial.html'});
- var element = angular.compile(
+ var element = injector('$compile')(
'' +
'include: ' +
'
')(myApp);
@@ -512,8 +512,8 @@ describe("widget", function() {
}));
it('should initialize view template after the view controller was initialized even when ' +
- 'templates were cached', inject(function($rootScope, $location, $browser, $route) {
- // this is a test for a regression that was introduced by making the ng:view cache sync
+ 'templates were cached', inject(function($rootScope, $compile, $location, $browser, $route) {
+ //this is a test for a regression that was introduced by making the ng:view cache sync
$route.when('/foo', {controller: ParentCtrl, template: 'viewPartial.html'});
@@ -576,8 +576,8 @@ describe("widget", function() {
describe('deal with pluralized strings without offset', function() {
var element;
- beforeEach(inject(function($rootScope) {
- element = angular.compile(
+ beforeEach(inject(function($rootScope, $compile) {
+ element = $compile(
'')($rootScope);
}));
- it('should show single/plural strings', inject(function($rootScope) {
+ it('should show single/plural strings', inject(function($rootScope, $compile) {
$rootScope.email = 0;
$rootScope.$digest();
expect(element.text()).toBe('You have no new email');
@@ -624,7 +624,7 @@ describe("widget", function() {
}));
- it('should show single/plural strings with mal-formed inputs', inject(function($rootScope) {
+ it('should show single/plural strings with mal-formed inputs', inject(function($rootScope, $compile) {
$rootScope.email = '';
$rootScope.$digest();
expect(element.text()).toBe('');
@@ -665,8 +665,8 @@ describe("widget", function() {
describe('deal with pluralized strings with offset', function() {
- it('should show single/plural strings with offset', inject(function($rootScope) {
- var element = angular.compile(
+ it('should show single/plural strings with offset', inject(function($rootScope, $compile) {
+ var element = $compile(
"