mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-05-09 15:24:43 +00:00
test(ng-include): add ng-include=src test
This commit is contained in:
parent
5e3db61b1d
commit
4e6b065a2f
1 changed files with 15 additions and 2 deletions
|
|
@ -30,10 +30,23 @@ describe('ng-include', function() {
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|
||||||
|
it('should support ng-include="src" syntax', inject(putIntoCache('myUrl', '{{name}}'),
|
||||||
|
function($rootScope, $compile) {
|
||||||
|
element = jqLite('<div ng-include="url"></div>');
|
||||||
|
jqLite(document.body).append(element);
|
||||||
|
element = $compile(element)($rootScope);
|
||||||
|
$rootScope.name = 'Alibaba';
|
||||||
|
$rootScope.url = 'myUrl';
|
||||||
|
$rootScope.$digest();
|
||||||
|
expect(element.text()).toEqual('Alibaba');
|
||||||
|
jqLite(document.body).html('');
|
||||||
|
}));
|
||||||
|
|
||||||
|
|
||||||
it('should remove previously included text if a falsy value is bound to src', inject(
|
it('should remove previously included text if a falsy value is bound to src', inject(
|
||||||
putIntoCache('myUrl', '{{name}}'),
|
putIntoCache('myUrl', '{{name}}'),
|
||||||
function($rootScope, $compile, $browser) {
|
function($rootScope, $compile) {
|
||||||
element = jqLite('<div ng-include="url" scope="childScope"></div>');
|
element = jqLite('<ng:include src="url" scope="childScope"></ng:include>');
|
||||||
element = $compile(element)($rootScope);
|
element = $compile(element)($rootScope);
|
||||||
$rootScope.childScope = $rootScope.$new();
|
$rootScope.childScope = $rootScope.$new();
|
||||||
$rootScope.childScope.name = 'igor';
|
$rootScope.childScope.name = 'igor';
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue