aboutsummaryrefslogtreecommitdiffstats
path: root/test/markupSpec.js
diff options
context:
space:
mode:
authorMisko Hevery2011-02-03 12:25:51 -0800
committerMisko Hevery2011-02-03 13:25:01 -0800
commitb6a01bd27dbcd2f9c9df917ecc96b8a2bd88413d (patch)
tree9ae08321a3741520014eac4d751a23ac39ab5f7e /test/markupSpec.js
parentaaaad298ac6447497b1b86edac5b0d9b092625a2 (diff)
downloadangular.js-b6a01bd27dbcd2f9c9df917ecc96b8a2bd88413d.tar.bz2
fixed population of value attribute on option
The value attribute must be populated manually, since different browsers default to different value of option when not explicitly defined.
Diffstat (limited to 'test/markupSpec.js')
-rw-r--r--test/markupSpec.js36
1 files changed, 33 insertions, 3 deletions
diff --git a/test/markupSpec.js b/test/markupSpec.js
index f78112d7..f629378d 100644
--- a/test/markupSpec.js
+++ b/test/markupSpec.js
@@ -41,9 +41,39 @@ describe("markups", function(){
expect(element.attr('src')).toEqual("http://server/a/b.png");
});
- it('should populate value attribute on OPTION', function(){
- compile('<select name="x"><option>a</option></select>');
- expect(sortedHtml(element).replace(' selected="true"', '')).toEqual('<select name="x"><option value="a">a</option></select>');
+ describe('OPTION value', function(){
+ beforeEach(function(){
+ this.addMatchers({
+ toHaveValue: function(expected){
+ this.message = function(){
+ return 'Expected "' + sortedHtml(this.actual) + '" to have value="' + expected + '".';
+ };
+
+ return this.actual.html().indexOf('value="' + expected + '"') != -1;
+ }
+ });
+ });
+
+ it('should populate value attribute on OPTION', function(){
+ compile('<select name="x"><option>abc</option></select>');
+ expect(element).toHaveValue('abc');
+ });
+
+ it('should ignore value if already exists', function(){
+ compile('<select name="x"><option value="abc">xyz</option></select>');
+ expect(element).toHaveValue('abc');
+ });
+
+ it('should set value even if newlines present', function(){
+ compile('<select name="x"><option attr="\ntext\n" \n>\nabc\n</option></select>');
+ expect(element).toHaveValue('\nabc\n');
+ });
+
+ it('should set value even if self closing HTML', function(){
+ compile('<select name="x"><option>\n</option></select>');
+ expect(element).toHaveValue('\n');
+ });
+
});
it('should bind href', function() {