Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2e3a972

Browse files
Alexander Hardingcaitp
Alexander Harding
authored andcommitted
test($compile): add tests for <option> or <optgroup> tags as root template nodes
1 parent ddb8081 commit 2e3a972

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

test/ng/compileSpec.js

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -541,6 +541,14 @@ describe('$compile', function() {
541541
replace: true,
542542
template: '<tfoot><tr><td>TD</td></tr></tfoot>'
543543
}));
544+
directive('replaceWithOption', valueFn({
545+
replace: true,
546+
template: '<option>OPTION</option>'
547+
}));
548+
directive('replaceWithOptgroup', valueFn({
549+
replace: true,
550+
template: '<optgroup>OPTGROUP</optgroup>'
551+
}));
544552
}));
545553

546554

@@ -746,6 +754,20 @@ describe('$compile', function() {
746754
}).not.toThrow();
747755
expect(nodeName_(element)).toMatch(/tfoot/i);
748756
}));
757+
758+
it('should support templates with root <option> tags', inject(function($compile, $rootScope) {
759+
expect(function() {
760+
element = $compile('<div replace-with-option></div>')($rootScope);
761+
}).not.toThrow();
762+
expect(nodeName_(element)).toMatch(/option/i);
763+
}));
764+
765+
it('should support templates with root <optgroup> tags', inject(function($compile, $rootScope) {
766+
expect(function() {
767+
element = $compile('<div replace-with-optgroup></div>')($rootScope);
768+
}).not.toThrow();
769+
expect(nodeName_(element)).toMatch(/optgroup/i);
770+
}));
749771
});
750772

751773

@@ -867,6 +889,14 @@ describe('$compile', function() {
867889
replace: true,
868890
templateUrl: 'tfoot.html'
869891
}));
892+
directive('replaceWithOption', valueFn({
893+
replace: true,
894+
templateUrl: 'option.html'
895+
}));
896+
directive('replaceWithOptgroup', valueFn({
897+
replace: true,
898+
templateUrl: 'optgroup.html'
899+
}));
870900
}
871901
));
872902

@@ -1556,6 +1586,24 @@ describe('$compile', function() {
15561586
$rootScope.$digest();
15571587
expect(nodeName_(element)).toMatch(/tfoot/i);
15581588
}));
1589+
1590+
it('should support templates with root <option> tags', inject(function($compile, $rootScope, $templateCache) {
1591+
$templateCache.put('option.html', '<option>OPTION</option>');
1592+
expect(function() {
1593+
element = $compile('<div replace-with-option></div>')($rootScope);
1594+
}).not.toThrow();
1595+
$rootScope.$digest();
1596+
expect(nodeName_(element)).toMatch(/option/i);
1597+
}));
1598+
1599+
it('should support templates with root <optgroup> tags', inject(function($compile, $rootScope, $templateCache) {
1600+
$templateCache.put('optgroup.html', '<optgroup>OPTGROUP</optgroup>');
1601+
expect(function() {
1602+
element = $compile('<div replace-with-optgroup></div>')($rootScope);
1603+
}).not.toThrow();
1604+
$rootScope.$digest();
1605+
expect(nodeName_(element)).toMatch(/optgroup/i);
1606+
}));
15591607
});
15601608

15611609

0 commit comments

Comments
 (0)