aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorMisko Hevery2010-08-18 16:04:40 -0700
committerMisko Hevery2010-08-18 16:04:40 -0700
commit1087270c95f6bbafd3715c9a5eecdafac79c9daa (patch)
tree7c0f0cfb433f69a11756c0b87c01e6927956394f /test
parentf09415d0de5d383efc9e2cb35d1323a5aac2371d (diff)
downloadangular.js-1087270c95f6bbafd3715c9a5eecdafac79c9daa.tar.bz2
added better handling of ng:format=number
Diffstat (limited to 'test')
-rw-r--r--test/testabilityPatch.js17
-rw-r--r--test/widgetsSpec.js38
2 files changed, 41 insertions, 14 deletions
diff --git a/test/testabilityPatch.js b/test/testabilityPatch.js
index e9a88b67..bbe2876e 100644
--- a/test/testabilityPatch.js
+++ b/test/testabilityPatch.js
@@ -178,9 +178,18 @@ error = noop;
function click(element) {
element = jqLite(element);
- if ( msie &&
- nodeName(element) == 'INPUT' && (lowercase(element.attr('type')) == 'radio' || lowercase(element.attr('type')) == 'checkbox')) {
- element[0].checked = ! element[0].checked;
+ var type = lowercase(element.attr('type'));
+ var name = lowercase(nodeName(element));
+ if (msie) {
+ if (name == 'input') {
+ if (type == 'radio' || type == 'checkbox') {
+ element[0].checked = ! element[0].checked;
+ }
+ }
+ }
+ if (name == 'option') {
+ JQLite.prototype.trigger.call(element.parent(), 'change');
+ } else {
+ JQLite.prototype.trigger.call(element, 'click');
}
- JQLite.prototype.trigger.call(element, 'click');
}
diff --git a/test/widgetsSpec.js b/test/widgetsSpec.js
index ad98e482..9134500a 100644
--- a/test/widgetsSpec.js
+++ b/test/widgetsSpec.js
@@ -338,17 +338,35 @@ describe("widget", function(){
});
- it('should support type="select-one"', function(){
- compile(
- '<select name="selection">' +
- '<option>A</option>' +
- '<option selected>B</option>' +
+ describe('select-one', function(){
+ it('should initialize to selected', function(){
+ compile(
+ '<select name="selection">' +
+ '<option>A</option>' +
+ '<option selected>B</option>' +
'</select>');
- expect(scope.selection).toEqual('B');
- scope.selection = 'A';
- scope.$eval();
- expect(scope.selection).toEqual('A');
- expect(element[0].childNodes[0].selected).toEqual(true);
+ expect(scope.selection).toEqual('B');
+ scope.selection = 'A';
+ scope.$eval();
+ expect(scope.selection).toEqual('A');
+ expect(element[0].childNodes[0].selected).toEqual(true);
+ });
+
+ it('should honor the value field in option', function(){
+ compile(
+ '<select name="selection" ng:format="number">' +
+ '<option value="{{$index}}" ng:repeat="name in [\'A\', \'B\']">{{name}}</option>' +
+ '</select>');
+ // childNodes[0] is repeater
+ expect(scope.selection).toEqual(undefined);
+
+ click(element[0].childNodes[1]);
+ expect(scope.selection).toEqual(0);
+
+ scope.selection = 1;
+ scope.$eval();
+ expect(element[0].childNodes[2].selected).toEqual(true);
+ });
});
it('should support type="select-multiple"', function(){