2011-07-17 08:05:43 +00:00
|
|
|
'use strict';
|
|
|
|
|
|
2011-10-07 18:27:49 +00:00
|
|
|
describe("ScenarioSpec: Compilation", function() {
|
2010-12-02 04:29:54 +00:00
|
|
|
var scope;
|
2011-01-19 23:42:11 +00:00
|
|
|
|
2011-10-07 18:27:49 +00:00
|
|
|
beforeEach(function() {
|
2010-12-02 04:29:54 +00:00
|
|
|
scope = null;
|
2010-01-23 23:54:58 +00:00
|
|
|
});
|
2011-01-19 23:42:11 +00:00
|
|
|
|
2011-10-07 18:27:49 +00:00
|
|
|
afterEach(function() {
|
2010-12-02 04:29:54 +00:00
|
|
|
dealoc(scope);
|
2010-01-23 23:54:58 +00:00
|
|
|
});
|
2011-01-19 23:42:11 +00:00
|
|
|
|
2011-10-07 18:27:49 +00:00
|
|
|
describe('compilation', function() {
|
|
|
|
|
it("should compile dom node and return scope", function() {
|
2010-12-02 04:29:54 +00:00
|
|
|
var node = jqLite('<div ng:init="a=1">{{b=a+1}}</div>')[0];
|
2011-02-25 22:03:02 +00:00
|
|
|
scope = angular.compile(node)();
|
2011-08-10 20:15:43 +00:00
|
|
|
scope.$digest();
|
2010-12-02 04:29:54 +00:00
|
|
|
expect(scope.a).toEqual(1);
|
|
|
|
|
expect(scope.b).toEqual(2);
|
|
|
|
|
});
|
2011-01-19 23:42:11 +00:00
|
|
|
|
2011-10-07 18:27:49 +00:00
|
|
|
it("should compile jQuery node and return scope", function() {
|
2011-02-25 22:03:02 +00:00
|
|
|
scope = compile(jqLite('<div>{{a=123}}</div>'))();
|
2011-08-10 20:15:43 +00:00
|
|
|
scope.$digest();
|
2010-12-02 04:29:54 +00:00
|
|
|
expect(jqLite(scope.$element).text()).toEqual('123');
|
|
|
|
|
});
|
2011-01-19 23:42:11 +00:00
|
|
|
|
2011-10-07 18:27:49 +00:00
|
|
|
it("should compile text node and return scope", function() {
|
2011-02-25 22:03:02 +00:00
|
|
|
scope = angular.compile('<div>{{a=123}}</div>')();
|
2011-08-10 20:15:43 +00:00
|
|
|
scope.$digest();
|
2010-12-02 04:29:54 +00:00
|
|
|
expect(jqLite(scope.$element).text()).toEqual('123');
|
|
|
|
|
});
|
2010-01-23 23:54:58 +00:00
|
|
|
});
|
2011-01-19 23:42:11 +00:00
|
|
|
});
|