diff options
Diffstat (limited to 'test')
| -rw-r--r-- | test/BinderTest.js | 4 | ||||
| -rw-r--r-- | test/scenario/dslSpec.js | 42 | ||||
| -rw-r--r-- | test/testabilityPatch.js | 19 | ||||
| -rw-r--r-- | test/widgetsSpec.js | 16 |
4 files changed, 17 insertions, 64 deletions
diff --git a/test/BinderTest.js b/test/BinderTest.js index 5d72206d..daaaeffe 100644 --- a/test/BinderTest.js +++ b/test/BinderTest.js @@ -589,13 +589,13 @@ BinderTest.prototype.testItShouldSelectTheCorrectRadioBox = function() { var female = jqLite(c.node[0].childNodes[0]); var male = jqLite(c.node[0].childNodes[1]); - click(female); + browserTrigger(female); assertEquals("female", c.scope.sex); assertEquals(true, female[0].checked); assertEquals(false, male[0].checked); assertEquals("female", female.val()); - click(male); + browserTrigger(male); assertEquals("male", c.scope.sex); assertEquals(false, female[0].checked); assertEquals(true, male[0].checked); diff --git a/test/scenario/dslSpec.js b/test/scenario/dslSpec.js index a30fe165..dd489d86 100644 --- a/test/scenario/dslSpec.js +++ b/test/scenario/dslSpec.js @@ -10,24 +10,6 @@ AngularMock.prototype.reset = function() { this.log = []; }; -AngularMock.prototype.element = function(node) { - this.log.push('element(' + node.nodeName.toLowerCase() + ')'); - var mock = this; - return { - selector: '', - attr: function(name, value) { - mock.log.push('attr(' + name + (angular.isDefined(value) ? ',' + value : '') + ')'); - return _jQuery.fn.attr.apply(_jQuery(node), arguments); - }, - trigger: function(type) { - mock.log.push('element().trigger(' + type + ')'); - //TODO(esprehn): See the HACK!! in the SpecRunner. This avoids - // triggering the second part of the hack in tests - delete this.selector; - } - }; -}; - AngularMock.prototype.$browser = function() { this.log.push('$brower()'); return this; @@ -181,7 +163,7 @@ describe("angular.scenario.dsl", function() { $root.dsl.select('test').options('A', 'B'); expect(_jQuery('[name="test"]').val()).toEqual(['A','B']); }); - + it('should fail to select multiple options on non-multiple select', function() { doc.append('<select name="test"></select>'); $root.dsl.select('test').options('A', 'B'); @@ -198,7 +180,7 @@ describe("angular.scenario.dsl", function() { }); $root.dsl.element('a').click(); }); - + it('should get attribute', function() { doc.append('<div id="test" class="foo"></div>'); $root.dsl.element('#test').attr('class'); @@ -210,13 +192,13 @@ describe("angular.scenario.dsl", function() { $root.dsl.element('#test').attr('class', 'bam'); expect(doc.find('div').attr('class')).toEqual('bam'); }); - + it('should get val', function() { doc.append('<input value="bar">'); $root.dsl.element('input').val(); expect($root.futureResult).toEqual('bar'); }); - + it('should set val', function() { doc.append('<input value="bar">'); $root.dsl.element('input').val('baz'); @@ -259,7 +241,7 @@ describe("angular.scenario.dsl", function() { $root.dsl.binding('foo.bar'); expect($root.futureResult).toEqual('some value'); }); - + it('should select binding in template by name', function() { doc.append('<pre ng:bind-template="foo {{bar}} baz">foo some baz</pre>'); $root.dsl.binding('bar'); @@ -271,7 +253,7 @@ describe("angular.scenario.dsl", function() { expect($root.futureError).toMatch(/did not match/); }); }); - + describe('Using', function() { it('should prefix selector in $document.elements()', function() { var chain; @@ -281,8 +263,6 @@ describe("angular.scenario.dsl", function() { ); chain = $root.dsl.using('div#test2'); chain.input('test.input').enter('foo'); - expect($window.angular.log).toContain('element(input)'); - expect($window.angular.log).toContain('element().trigger(change)'); var inputs = _jQuery('input[name="test.input"]'); expect(inputs.first().val()).toEqual('something'); expect(inputs.last().val()).toEqual('foo'); @@ -294,8 +274,6 @@ describe("angular.scenario.dsl", function() { doc.append('<input name="test.input" value="something">'); var chain = $root.dsl.input('test.input'); chain.enter('foo'); - expect($window.angular.log).toContain('element(input)'); - expect($window.angular.log).toContain('element().trigger(change)'); expect(_jQuery('input[name="test.input"]').val()).toEqual('foo'); }); @@ -311,14 +289,10 @@ describe("angular.scenario.dsl", function() { attr('checked')).toBeTruthy(); var chain = $root.dsl.input('test.input'); chain.check(); - expect($window.angular.log).toContain('element(input)'); - expect($window.angular.log).toContain('element().trigger(click)'); expect(_jQuery('input[name="test.input"]'). attr('checked')).toBeFalsy(); $window.angular.reset(); chain.check(); - expect($window.angular.log).toContain('element(input)'); - expect($window.angular.log).toContain('element().trigger(click)'); expect(_jQuery('input[name="test.input"]'). attr('checked')).toBeTruthy(); }); @@ -342,8 +316,6 @@ describe("angular.scenario.dsl", function() { attr('checked')).toBeFalsy(); var chain = $root.dsl.input('test.input'); chain.select('foo'); - expect($window.angular.log).toContain('element(input)'); - expect($window.angular.log).toContain('element().trigger(click)'); expect(_jQuery('input[name="0@test.input"][value="bar"]'). attr('checked')).toBeFalsy(); expect(_jQuery('input[name="0@test.input"][value="foo"]'). @@ -356,6 +328,6 @@ describe("angular.scenario.dsl", function() { expect($root.futureError).toMatch(/did not match/); }); }); - + }); }); diff --git a/test/testabilityPatch.js b/test/testabilityPatch.js index 59d8f4ac..247faa19 100644 --- a/test/testabilityPatch.js +++ b/test/testabilityPatch.js @@ -189,25 +189,6 @@ function assertThrows(error, fn){ log = noop; error = noop; -function click(element) { - element = jqLite(element); - 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') { - element.parent().val(element.val()); - JQLite.prototype.trigger.call(element.parent(), 'change'); - } else { - JQLite.prototype.trigger.call(element, 'click'); - } -} - function rethrow(e) { if(e) { throw e; diff --git a/test/widgetsSpec.js b/test/widgetsSpec.js index 31596a48..cc254eff 100644 --- a/test/widgetsSpec.js +++ b/test/widgetsSpec.js @@ -128,10 +128,10 @@ describe("widget", function(){ it('should support type="checkbox"', function(){ compile('<input type="checkBox" name="checkbox" checked ng:change="action = true"/>'); expect(scope.checkbox).toEqual(true); - click(element); + browserTrigger(element); expect(scope.checkbox).toEqual(false); expect(scope.action).toEqual(true); - click(element); + browserTrigger(element); expect(scope.checkbox).toEqual(true); }); @@ -151,7 +151,7 @@ describe("widget", function(){ expect(scope.state).toEqual("Worked"); expect(scope.$element[0].checked).toEqual(true); - click(scope.$element); + browserTrigger(scope.$element); expect(scope.state).toEqual("Failed"); expect(scope.$element[0].checked).toEqual(false); @@ -278,13 +278,13 @@ describe("widget", function(){ it('should call ng:change on button click', function(){ compile('<input type="button" value="Click Me" ng:change="clicked = true"/>'); - click(element); + browserTrigger(element); expect(scope.$get('clicked')).toEqual(true); }); it('should support button alias', function(){ compile('<button ng:change="clicked = true">Click Me</button>'); - click(element); + browserTrigger(element); expect(scope.$get('clicked')).toEqual(true); }); @@ -310,7 +310,7 @@ describe("widget", function(){ expect(b.checked).toEqual(true); expect(scope.clicked).not.toBeDefined(); - click(a); + browserTrigger(a); expect(scope.chose).toEqual('A'); expect(scope.clicked).toEqual(1); }); @@ -363,7 +363,7 @@ describe("widget", function(){ // childNodes[0] is repeater comment expect(scope.selection).toEqual(undefined); - click(element[0].childNodes[2]); + browserTrigger(element[0].childNodes[2], 'change'); expect(scope.selection).toEqual(1); scope.selection = 2; @@ -423,7 +423,7 @@ describe("widget", function(){ it('should report error on ng:change exception', function(){ compile('<button ng:change="a-2=x">click</button>'); - click(element); + browserTrigger(element); expect(element.hasClass('ng-exception')).toBeTruthy(); }); }); |
