blob: e91e0b981986f330367582c3600196ed5fd4fe9e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
'use strict';
describe("ScenarioSpec: Compilation", function(){
var scope;
beforeEach(function(){
scope = null;
});
afterEach(function(){
dealoc(scope);
});
describe('compilation', function(){
it("should compile dom node and return scope", function(){
var node = jqLite('<div ng:init="a=1">{{b=a+1}}</div>')[0];
scope = angular.compile(node)();
scope.$digest();
expect(scope.a).toEqual(1);
expect(scope.b).toEqual(2);
});
it("should compile jQuery node and return scope", function(){
scope = compile(jqLite('<div>{{a=123}}</div>'))();
scope.$digest();
expect(jqLite(scope.$element).text()).toEqual('123');
});
it("should compile text node and return scope", function(){
scope = angular.compile('<div>{{a=123}}</div>')();
scope.$digest();
expect(jqLite(scope.$element).text()).toEqual('123');
});
});
describe("configuration", function(){
it("should take location object", function(){
var url = "http://server/#?book=moby";
scope = angular.compile("<div>{{$location}}</div>")();
var $location = scope.$service('$location');
var $browser = scope.$service('$browser');
expect($location.hashSearch.book).toBeUndefined();
$browser.setUrl(url);
$browser.poll();
expect($location.hashSearch.book).toEqual('moby');
});
});
});
|