test($compile): add tests for <option> or <optgroup> tags as root template nodes

This commit is contained in:
Alexander Harding
2014-04-01 14:45:44 -05:00
committed by Caitlin Potter
parent ba66c4f3cc
commit 81395ac298

View File

@@ -541,6 +541,14 @@ describe('$compile', function() {
replace: true,
template: '<tfoot><tr><td>TD</td></tr></tfoot>'
}));
directive('replaceWithOption', valueFn({
replace: true,
template: '<option>OPTION</option>'
}));
directive('replaceWithOptgroup', valueFn({
replace: true,
template: '<optgroup>OPTGROUP</optgroup>'
}));
}));
@@ -746,6 +754,20 @@ describe('$compile', function() {
}).not.toThrow();
expect(nodeName_(element)).toMatch(/tfoot/i);
}));
it('should support templates with root <option> tags', inject(function($compile, $rootScope) {
expect(function() {
element = $compile('<div replace-with-option></div>')($rootScope);
}).not.toThrow();
expect(nodeName_(element)).toMatch(/option/i);
}));
it('should support templates with root <optgroup> tags', inject(function($compile, $rootScope) {
expect(function() {
element = $compile('<div replace-with-optgroup></div>')($rootScope);
}).not.toThrow();
expect(nodeName_(element)).toMatch(/optgroup/i);
}));
});
@@ -867,6 +889,14 @@ describe('$compile', function() {
replace: true,
templateUrl: 'tfoot.html'
}));
directive('replaceWithOption', valueFn({
replace: true,
templateUrl: 'option.html'
}));
directive('replaceWithOptgroup', valueFn({
replace: true,
templateUrl: 'optgroup.html'
}));
}
));
@@ -1556,6 +1586,24 @@ describe('$compile', function() {
$rootScope.$digest();
expect(nodeName_(element)).toMatch(/tfoot/i);
}));
it('should support templates with root <option> tags', inject(function($compile, $rootScope, $templateCache) {
$templateCache.put('option.html', '<option>OPTION</option>');
expect(function() {
element = $compile('<div replace-with-option></div>')($rootScope);
}).not.toThrow();
$rootScope.$digest();
expect(nodeName_(element)).toMatch(/option/i);
}));
it('should support templates with root <optgroup> tags', inject(function($compile, $rootScope, $templateCache) {
$templateCache.put('optgroup.html', '<optgroup>OPTGROUP</optgroup>');
expect(function() {
element = $compile('<div replace-with-optgroup></div>')($rootScope);
}).not.toThrow();
$rootScope.$digest();
expect(nodeName_(element)).toMatch(/optgroup/i);
}));
});