diff options
| -rw-r--r-- | example/widgets.html | 34 | ||||
| -rw-r--r-- | scenario/widgets.html | 12 | ||||
| -rw-r--r-- | src/jqLite.js | 1 | ||||
| -rw-r--r-- | test/BinderTest.js | 4 | ||||
| -rw-r--r-- | test/CompilerSpec.js | 4 | ||||
| -rw-r--r-- | test/directivesSpec.js | 8 | ||||
| -rw-r--r-- | test/testabilityPatch.js | 6 | ||||
| -rw-r--r-- | test/widgetsSpec.js | 6 |
8 files changed, 29 insertions, 46 deletions
diff --git a/example/widgets.html b/example/widgets.html deleted file mode 100644 index 525b35b9..00000000 --- a/example/widgets.html +++ /dev/null @@ -1,34 +0,0 @@ -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> -<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> - <head> - <script type="text/javascript" src="../src/angular-bootstrap.js"></script> - <script type="text/javascript"> - function asyncValidate(value, callback){ - var x = value.length % 2 ? null: "even"; - //callback(x); - _(callback).delay(1000, x); - } - </script> - <link rel="StyleSheet" type="text/css" href="../css/angular.css"/> - </head> - <body onload="angular.compile(document).$init()"> - - <input type="checkbox" name="form.checked" ng-format="boolean" value="true" checked="checked" /> - <input ng-show="form.checked" name="form.required" ng-required/> - <hr/> - <input name="form.list" ng-format="list" ng-required/> - <input name="form.list" ng-format="list" /> - <hr/> - <input type="checkbox" name="form.boolean" ng-format="boolean" value="true" checked="checked" /> - <input type="checkbox" name="form.boolean" ng-format="boolean" value="true" /> - <hr/> - <select name="select"> - <option>A</option> - <option selected>B</option> - </select> - <pre> -form={{form}} -$invalidWidgets.length={{$invalidWidgets.length}} - </pre> - </body> -</html> diff --git a/scenario/widgets.html b/scenario/widgets.html index 6cb8df05..ab27e490 100644 --- a/scenario/widgets.html +++ b/scenario/widgets.html @@ -2,7 +2,7 @@ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <link rel="stylesheet" type="text/css" href="style.css"></link> - <!--<script type="text/javascript" src="../lib/jquery/jquery-1.4.2.js"></script>--> + <script type="text/javascript" src="../lib/jquery/jquery-1.4.2.js"></script> <script type="text/javascript" src="../src/angular-bootstrap.js#autobind"></script> </head> <body ng-init="$window.$scope = this"> @@ -82,6 +82,16 @@ </td> <td>button={{button}}</td> </tr> + <tr><th colspan="3">Repeaters</th></tr> + <tr> + <td>ng-repeat</td> + <td> + <ul> + <li ng-repeat="name in ['misko', 'adam']">{{name}}</li> + </ul> + </td> + <td></td> + </tr> </table> </body> </html> diff --git a/src/jqLite.js b/src/jqLite.js index 9aa4f2c7..e9407987 100644 --- a/src/jqLite.js +++ b/src/jqLite.js @@ -92,6 +92,7 @@ JQLite.prototype = { }); }, + //TODO: remove trigger: function(type) { var evnt = document.createEvent('MouseEvent'); evnt.initMouseEvent(type, true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null); diff --git a/test/BinderTest.js b/test/BinderTest.js index 660ad78c..c792f10b 100644 --- a/test/BinderTest.js +++ b/test/BinderTest.js @@ -706,13 +706,13 @@ BinderTest.prototype.testItShouldSelectTheCorrectRadioBox = function() { var female = jqLite(c.node[0].childNodes[0]); var male = jqLite(c.node[0].childNodes[1]); - female.click(); + trigger(female, 'click'); assertEquals("female", c.scope.sex); assertEquals(true, female[0].checked); assertEquals(false, male[0].checked); assertEquals("female", female.val()); - male.click(); + trigger(male, 'click'); assertEquals("male", c.scope.sex); assertEquals(false, female[0].checked); assertEquals(true, male[0].checked); diff --git a/test/CompilerSpec.js b/test/CompilerSpec.js index 9922070f..b9529e6e 100644 --- a/test/CompilerSpec.js +++ b/test/CompilerSpec.js @@ -72,7 +72,7 @@ describe('compiler', function(){ var scope = compile('<span hello="misko" stop="true"><span hello="adam"/></span>'); expect(log).toEqual("hello misko"); }); - + it('should allow creation of templates', function(){ directives.duplicate = function(expr, element){ element.replaceWith(document.createComment("marker")); @@ -97,7 +97,7 @@ describe('compiler', function(){ if (text == 'middle') { expect(textNode.text()).toEqual(text); parentNode.attr('hello', text); - textNode.text('replaced'); + textNode[0].textContent = 'replaced'; } }); var scope = compile('before<span>middle</span>after'); diff --git a/test/directivesSpec.js b/test/directivesSpec.js index 0a7e3c18..7504bf6b 100644 --- a/test/directivesSpec.js +++ b/test/directivesSpec.js @@ -142,19 +142,19 @@ describe("directives", function(){ it('should ng-show', function(){ var scope = compile('<div ng-hide="hide"></div>'); scope.$eval(); - expect(element.css('display')).toEqual(''); + expect(isVisible(element)).toEqual(true); scope.$set('hide', true); scope.$eval(); - expect(element.css('display')).toEqual('none'); + expect(isVisible(element)).toEqual(false); }); it('should ng-hide', function(){ var scope = compile('<div ng-show="show"></div>'); scope.$eval(); - expect(element.css('display')).toEqual('none'); + expect(isVisible(element)).toEqual(false); scope.$set('show', true); scope.$eval(); - expect(element.css('display')).toEqual(''); + expect(isVisible(element)).toEqual(true); }); it('should ng-controller', function(){ diff --git a/test/testabilityPatch.js b/test/testabilityPatch.js index dc67ddec..475784ad 100644 --- a/test/testabilityPatch.js +++ b/test/testabilityPatch.js @@ -27,6 +27,12 @@ extend(angular, { }); +function trigger(element, type) { + var evnt = document.createEvent('MouseEvent'); + evnt.initMouseEvent(type, true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null); + (element[0] || element).dispatchEvent(evnt); +} + function sortedHtml(element) { var html = ""; (function toString(node) { diff --git a/test/widgetsSpec.js b/test/widgetsSpec.js index 1669aa68..a68176e7 100644 --- a/test/widgetsSpec.js +++ b/test/widgetsSpec.js @@ -115,10 +115,10 @@ describe("input widget", function(){ it('should type="checkbox"', function(){ compile('<input type="checkbox" name="checkbox" checked ng-change="action = true"/>'); expect(scope.checkbox).toEqual(true); - element.click(); + trigger(element, 'click'); expect(scope.checkbox).toEqual(false); expect(scope.action).toEqual(true); - element.click(); + trigger(element, 'click'); expect(scope.checkbox).toEqual(true); }); @@ -142,7 +142,7 @@ describe("input widget", function(){ expect(b.checked).toEqual(true); expect(scope.clicked).not.toBeDefined(); - jqLite(a).click(); + trigger(a, 'click'); expect(scope.chose).toEqual('A'); expect(scope.clicked).toEqual(1); }); |
