From 0e5a24c584d88b17297010676b8e0005b3545efd Mon Sep 17 00:00:00 2001 From: Igor Minar Date: Thu, 15 Sep 2011 00:47:15 +0200 Subject: fix(specs): jQuery now returns attr name instead of true/false for special attrs for special attrs like 'checked' or 'multiple', jquery now returns the name or undedefined. e.g. foo.attr('checked') => 'checked' || undefined The solution is a combination of updating our tests as well as switching over to prop() instead which properly returns true/false --- test/jqLiteSpec.js | 14 +++++++------- test/scenario/dslSpec.js | 16 ++++++++-------- test/widgetsSpec.js | 4 ++-- 3 files changed, 17 insertions(+), 17 deletions(-) (limited to 'test') diff --git a/test/jqLiteSpec.js b/test/jqLiteSpec.js index a7fded5c..b31b1664 100644 --- a/test/jqLiteSpec.js +++ b/test/jqLiteSpec.js @@ -150,18 +150,18 @@ describe('jqLite', function(){ expect(jqLite(b).attr('prop')).toBeFalsy(); }); - it('should read special attributes as boolean', function(){ + it('should read special attributes as strings', function(){ var select = jqLite('').attr('multiple')).toEqual(true); - expect(jqLite('').attr('multiple')).toEqual(true); + expect(select.attr('multiple')).toBeUndefined(); + expect(jqLite('').attr('multiple')).toBe('multiple'); + expect(jqLite(''); expect(_jQuery('input[name="test.input"]'). - attr('checked')).toBeTruthy(); + prop('checked')).toBe(true); var chain = $root.dsl.input('test.input'); chain.check(); expect(_jQuery('input[name="test.input"]'). - attr('checked')).toBeFalsy(); + prop('checked')).toBe(false); $window.angular.reset(); chain.check(); expect(_jQuery('input[name="test.input"]'). - attr('checked')).toBeTruthy(); + prop('checked')).toBe(true); }); it('should return error if checkbox did not match', function() { @@ -527,17 +527,17 @@ describe("angular.scenario.dsl", function() { '' ); // HACK! We don't know why this is sometimes false on chrome - _jQuery('input[name="0@test.input"][value="bar"]').attr('checked', true); + _jQuery('input[name="0@test.input"][value="bar"]').prop('checked', true); expect(_jQuery('input[name="0@test.input"][value="bar"]'). - attr('checked')).toBeTruthy(); + prop('checked')).toBe(true); expect(_jQuery('input[name="0@test.input"][value="foo"]'). - attr('checked')).toBeFalsy(); + prop('checked')).toBe(false); var chain = $root.dsl.input('test.input'); chain.select('foo'); expect(_jQuery('input[name="0@test.input"][value="bar"]'). - attr('checked')).toBeFalsy(); + prop('checked')).toBe(false); expect(_jQuery('input[name="0@test.input"][value="foo"]'). - attr('checked')).toBeTruthy(); + prop('checked')).toBe(true); }); it('should return error if radio button did not match', function() { diff --git a/test/widgetsSpec.js b/test/widgetsSpec.js index 6d6e47c6..6fccaa48 100644 --- a/test/widgetsSpec.js +++ b/test/widgetsSpec.js @@ -957,8 +957,8 @@ describe("widget", function(){ scope.selected = []; scope.$digest(); expect(select.find('option').length).toEqual(2); - expect(jqLite(select.find('option')[0]).attr('selected')).toEqual(false); - expect(jqLite(select.find('option')[1]).attr('selected')).toEqual(false); + expect(select.find('option')[0].selected).toBe(false); + expect(select.find('option')[1].selected).toBe(false); scope.selected.push(scope.values[1]); scope.$digest(); -- cgit v1.2.3