From 9998b8dcbb2674ac680fd6598aea0840e69c0e1b Mon Sep 17 00:00:00 2001 From: Kai Compagner Date: Wed, 14 Jul 2010 12:08:55 -0700 Subject: fix undefine style --- test/directivesSpec.js | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'test') diff --git a/test/directivesSpec.js b/test/directivesSpec.js index df0b5b94..ef4814bf 100644 --- a/test/directivesSpec.js +++ b/test/directivesSpec.js @@ -174,6 +174,13 @@ describe("directives", function(){ expect(element.css('color')).toEqual('red'); }); + it('should silently ignore undefined ng:style', function() { + var scope = compile('
'); + scope.$eval(); + dump(sortedHtml(element)); + expect(element.hasClass('ng-exception')).toBeFalsy(); + }); + it('should ng:show', function(){ var scope = compile('
'); scope.$eval(); -- cgit v1.2.3 From 412f05977c41fbda46278b637c4d1a84996d48d1 Mon Sep 17 00:00:00 2001 From: Misko Hevery Date: Wed, 11 Aug 2010 11:17:55 -0700 Subject: removed google charts and few other filters, switched to simple optimization for compiler --- test/FiltersTest.js | 73 ----------------------------------------------------- 1 file changed, 73 deletions(-) (limited to 'test') diff --git a/test/FiltersTest.js b/test/FiltersTest.js index 903a7a2f..d5484fd0 100644 --- a/test/FiltersTest.js +++ b/test/FiltersTest.js @@ -41,54 +41,6 @@ FiltersTest.prototype.testJson = function () { assertEquals(toJson({a:"b"}, true), angular.filter.json.call({$element:jqLite('
')}, {a:"b"})); }; -FiltersTest.prototype.testPackageTracking = function () { - var assert = function(title, trackingNo) { - var val = angular.filter.trackPackage(trackingNo, title); - assertNotNull("Did Not Match: " + trackingNo, val); - assertEquals(title + ": " + trim(trackingNo), val.text()); - assertNotNull(val.attr('href')); - }; - assert('UPS', ' 1Z 999 999 99 9999 999 9 '); - assert('UPS', '1ZW5w5220379084747'); - - assert('FedEx', '418822131061812'); - assert('FedEx', '9612019 5935 3267 2473 738'); - assert('FedEx', '9612019593532672473738'); - assert('FedEx', '235354667129449'); - assert('FedEx', '915368880571'); - assert('FedEx', '901712142390'); - assert('FedEx', '297391510063413'); - - assert('USPS', '9101 8052 1390 7402 4335 49'); - assert('USPS', '9101010521297963339560'); - assert('USPS', '9102901001301038667029'); - assert('USPS', '910 27974 4490 3000 8916 56'); - assert('USPS', '9102801438635051633253'); -}; - -FiltersTest.prototype.testLink = function() { - var assert = function(text, url, obj){ - var val = angular.filter.link(obj); - assertEquals('' + text + '', sortedHtml(val)); - }; - assert("url", "url", "url"); - assert("hello", "url", {text:"hello", url:"url"}); - assert("a@b.com", "mailto:a@b.com", "a@b.com"); -}; - -FiltersTest.prototype.testImage = function(){ - assertEquals(null, angular.filter.image()); - assertEquals(null, angular.filter.image({})); - assertEquals(null, angular.filter.image("")); - assertEquals('http://localhost/abc', angular.filter.image({url:"http://localhost/abc"}).attr('src')); -}; - -FiltersTest.prototype.testQRcode = function() { - assertEquals( - 'http://chart.apis.google.com/chart?chl=Hello%20world&chs=200x200&cht=qr', - angular.filter.qrcode('Hello world').attr('src')); -}; - FiltersTest.prototype.testLowercase = function() { assertEquals('abc', angular.filter.lowercase('AbC')); assertEquals(null, angular.filter.lowercase(null)); @@ -99,30 +51,6 @@ FiltersTest.prototype.testUppercase = function() { assertEquals(null, angular.filter.uppercase(null)); }; -FiltersTest.prototype.testLineCount = function() { - assertEquals(1, angular.filter.linecount(null)); - assertEquals(1, angular.filter.linecount('')); - assertEquals(1, angular.filter.linecount('a')); - assertEquals(2, angular.filter.linecount('a\nb')); - assertEquals(3, angular.filter.linecount('a\nb\nc')); -}; - -FiltersTest.prototype.testIf = function() { - assertEquals('A', angular.filter['if']('A', true)); - assertEquals(undefined, angular.filter['if']('A', false)); -}; - -FiltersTest.prototype.testUnless = function() { - assertEquals('A', angular.filter.unless('A', false)); - assertEquals(undefined, angular.filter.unless('A', true)); -}; - -FiltersTest.prototype.testGoogleChartApiEncode = function() { - assertEquals( - 'http://chart.apis.google.com/chart?chl=Hello world&chs=200x200&cht=qr', - angular.filter.googleChartApi.encode({cht:"qr", chl:"Hello world"}).attr('src')); -}; - FiltersTest.prototype.testHtml = function() { var html = angular.filter.html("acd"); expect(html instanceof HTML).toBeTruthy(); @@ -140,4 +68,3 @@ FiltersTest.prototype.testLinky = function() { assertEquals(undefined, linky(undefined)); }; - -- cgit v1.2.3 From 3d5719cd44868f89352ebbedd0e1b1f2575520cb Mon Sep 17 00:00:00 2001 From: Misko Hevery Date: Wed, 11 Aug 2010 11:44:12 -0700 Subject: removed undocumented/unneeded methods from Array API --- test/ApiTest.js | 73 --------------------------------------------------------- 1 file changed, 73 deletions(-) (limited to 'test') diff --git a/test/ApiTest.js b/test/ApiTest.js index 4035cdbb..9f09773d 100644 --- a/test/ApiTest.js +++ b/test/ApiTest.js @@ -18,27 +18,6 @@ ApiTest.prototype.testItShouldReturnSize = function(){ assertEquals(1, angular.Array.size([0])); }; -ApiTest.prototype.testIncludeIf = function() { - var array = []; - var obj = {}; - - angular.Array.includeIf(array, obj, true); - angular.Array.includeIf(array, obj, true); - assertTrue(includes(array, obj)); - assertEquals(1, array.length); - - angular.Array.includeIf(array, obj, false); - assertFalse(includes(array, obj)); - assertEquals(0, array.length); - - angular.Array.includeIf(array, obj, 'x'); - assertTrue(includes(array, obj)); - assertEquals(1, array.length); - angular.Array.includeIf(array, obj, ''); - assertFalse(includes(array, obj)); - assertEquals(0, array.length); -}; - ApiTest.prototype.testSum = function(){ assertEquals(3, angular.Array.sum([{a:"1"}, {a:"2"}], 'a')); }; @@ -48,13 +27,6 @@ ApiTest.prototype.testSumContainingNaN = function(){ assertEquals(1, angular.Array.sum([{a:1}, {a:Number.NaN}], function($){return $.a;})); }; -ApiTest.prototype.testInclude = function(){ - assertTrue(angular.Array.include(['a'], 'a')); - assertTrue(angular.Array.include(['a', 'b'], 'a')); - assertTrue(!angular.Array.include(['c'], 'a')); - assertTrue(!angular.Array.include(['c', 'b'], 'a')); -}; - ApiTest.prototype.testIndex = function(){ assertEquals(angular.Array.indexOf(['a'], 'a'), 0); assertEquals(angular.Array.indexOf(['a', 'b'], 'a'), 0); @@ -80,14 +52,6 @@ ApiTest.prototype.testRemove = function(){ assertEquals(items.length, 0); }; -ApiTest.prototype.testFindById = function() { - var items = [{$id:1}, {$id:2}, {$id:3}]; - assertNull(angular.Array.findById(items, 0)); - assertEquals(items[0], angular.Array.findById(items, 1)); - assertEquals(items[1], angular.Array.findById(items, 2)); - assertEquals(items[2], angular.Array.findById(items, 3)); -}; - ApiTest.prototype.testFilter = function() { var items = ["MIsKO", {name:"shyam"}, ["adam"], 1234]; assertEquals(4, angular.Array.filter(items, "").length); @@ -161,16 +125,6 @@ ApiTest.prototype.testCount = function() { assertEquals(1, angular.Array.count(array, 'name=="a"')); }; -ApiTest.prototype.testFind = function() { - var array = [{name:'a'},{name:'b'},{name:''}]; - var obj = {}; - - assertEquals(undefined, angular.Array.find(array, 'false')); - assertEquals('default', angular.Array.find(array, 'false', 'default')); - assertEquals('a', angular.Array.find(array, 'name == "a"').name); - assertEquals('', angular.Array.find(array, 'name == ""').name); -}; - ApiTest.prototype.testItShouldSortArray = function() { assertEquals([2,15], angular.Array.orderBy([15,2])); assertEquals(["a","B", "c"], angular.Array.orderBy(["c","B", "a"])); @@ -211,33 +165,6 @@ ApiTest.prototype.testQuoteUnicode = function(){ assertEquals('"abc\\u00a0def"', angular.String.quoteUnicode('abc\u00A0def')); }; -ApiTest.prototype.testMerge = function() { - var array = [{name:"misko"}]; - angular.Array.merge(array, 0, {name:"", email:"email1"}); - angular.Array.merge(array, 1, {name:"adam", email:"email2"}); - assertJsonEquals([{"email":"email1","name":"misko"},{"email":"email2","name":"adam"}], array); -}; - -ApiTest.prototype.testOrderByToggle = function() { - var orderByToggle = angular.Array.orderByToggle; - var predicate = []; - assertEquals(['+a'], orderByToggle(predicate, 'a')); - assertEquals(['-a'], orderByToggle(predicate, 'a')); - - assertEquals(['-a', '-b'], orderByToggle(['-b', 'a'], 'a')); -}; - -ApiTest.prototype.testOrderByToggle = function() { - var orderByDirection = angular.Array.orderByDirection; - assertEquals("", orderByDirection(['+a','b'], 'x')); - assertEquals("", orderByDirection(['+a','b'], 'b')); - assertEquals('ng-ascend', orderByDirection(['a','b'], 'a')); - assertEquals('ng-ascend', orderByDirection(['+a','b'], 'a')); - assertEquals('ng-descend', orderByDirection(['-a','b'], 'a')); - assertEquals('up', orderByDirection(['+a','b'], 'a', 'up', 'down')); - assertEquals('down', orderByDirection(['-a','b'], 'a', 'up', 'down')); -}; - ApiTest.prototype.testDateToUTC = function(){ var date = new Date("Sep 10 2003 13:02:03 GMT"); assertEquals("date", angular.Object.typeOf(date)); -- cgit v1.2.3 From 669d8241b2ea61122aee3e45f67694e65596a2dd Mon Sep 17 00:00:00 2001 From: Shyam Seshadri Date: Sat, 14 Aug 2010 00:31:06 +0800 Subject: Pull in Rajat's changes to add click and url checking dsl --- test/scenario/DSLSpec.js | 45 +++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 43 insertions(+), 2 deletions(-) (limited to 'test') diff --git a/test/scenario/DSLSpec.js b/test/scenario/DSLSpec.js index c8e30917..9bf6d31d 100644 --- a/test/scenario/DSLSpec.js +++ b/test/scenario/DSLSpec.js @@ -6,10 +6,12 @@ describe("DSL", function() { setUpContext(); executeFuture = function(future, html, callback) { lastDocument = _jQuery('
' + html + '
'); + lastFrame = _jQuery(''); _jQuery(document.body).append(lastDocument); var specThis = { testWindow: window, testDocument: lastDocument, + testFrame: lastFrame, jQuery: _jQuery }; future.behavior.call(specThis, callback || noop); @@ -39,6 +41,38 @@ describe("DSL", function() { }); }); + describe('browser', function() { + var browser = angular.scenario.dsl.browser; + it('shoud return true if location with empty hash provided is same ' + + 'as location of the page', function() { + browser.location.href = "http://server"; + expect(browser.location.toEqual("http://server")).toEqual(true); + }); + it('shoud return true if location with hash provided is same ' + + 'as location of the page', function() { + browser.location.href = "http://server"; + browser.location.hash = "hashPath"; + expect(browser.location.toEqual("http://server/#/hashPath")) + .toEqual(true); + }); + it('should return true if the location provided is the same as which ' + + 'browser navigated to', function() { + var future = browser.navigateTo("http://server/#/hashPath"); + expect(future.name).toEqual("Navigate to: http://server/#/hashPath"); + executeFuture(future, ''); + expect(browser.location.toEqual("http://server/#/hashPath")) + .toEqual(true); + expect(browser.location.toEqual("http://server/")) + .toEqual(false); + + future = browser.navigateTo("http://server/"); + expect(future.name).toEqual("Navigate to: http://server/"); + executeFuture(future, ''); + expect(browser.location.toEqual("http://server/")) + .toEqual(true); + }); + }); + describe('repeater', function() { var repeater = angular.scenario.dsl.repeater; @@ -125,7 +159,7 @@ describe("DSL", function() { expect(future.fulfilled).toBeTruthy(); } it('should find elements on the page and provide jquery api', function() { - var future = element('.reports-detail'); + var future = element('.reports-detail').find(); expect(future.name).toEqual("Find element '.reports-detail'"); timeTravel(future); expect(future.value.text()). @@ -134,11 +168,18 @@ describe("DSL", function() { toEqual('Description : Details...'); }); it('should find elements with angular syntax', function() { - var future = element('{{report.description}}'); + var future = element('{{report.description}}').find(); expect(future.name).toEqual("Find element '{{report.description}}'"); timeTravel(future); expect(future.value.text()).toEqual('Details...'); expect(future.value.attr('ng:bind')).toEqual('report.description'); }); + it('should be able to click elements', function(){ + var future = element('.link-class').click(); + expect(future.name).toEqual("Click element '.link-class'"); + executeFuture(future, html, function(value) { future.fulfill(value); }); + expect(future.fulfilled).toBeTruthy(); + // TODO(rajat): look for some side effect from click happening? + }); }); }); -- cgit v1.2.3 From 1f230bf3f55fc8541423dfa9fc0bc91f50c000a3 Mon Sep 17 00:00:00 2001 From: Shyam Seshadri Date: Sat, 14 Aug 2010 00:45:56 +0800 Subject: Revert click dsl, since what is returned by element is a jquery object --- test/scenario/DSLSpec.js | 7 ------- 1 file changed, 7 deletions(-) (limited to 'test') diff --git a/test/scenario/DSLSpec.js b/test/scenario/DSLSpec.js index 9bf6d31d..ccd9e32b 100644 --- a/test/scenario/DSLSpec.js +++ b/test/scenario/DSLSpec.js @@ -174,12 +174,5 @@ describe("DSL", function() { expect(future.value.text()).toEqual('Details...'); expect(future.value.attr('ng:bind')).toEqual('report.description'); }); - it('should be able to click elements', function(){ - var future = element('.link-class').click(); - expect(future.name).toEqual("Click element '.link-class'"); - executeFuture(future, html, function(value) { future.fulfill(value); }); - expect(future.fulfilled).toBeTruthy(); - // TODO(rajat): look for some side effect from click happening? - }); }); }); -- cgit v1.2.3 From 9260f4867a6d1aaa51585a3efac9d315b74eae53 Mon Sep 17 00:00:00 2001 From: Shyam Seshadri Date: Sat, 14 Aug 2010 01:11:11 +0800 Subject: Fix broken tests for element dsl --- test/scenario/DSLSpec.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'test') diff --git a/test/scenario/DSLSpec.js b/test/scenario/DSLSpec.js index ccd9e32b..552e6211 100644 --- a/test/scenario/DSLSpec.js +++ b/test/scenario/DSLSpec.js @@ -159,7 +159,7 @@ describe("DSL", function() { expect(future.fulfilled).toBeTruthy(); } it('should find elements on the page and provide jquery api', function() { - var future = element('.reports-detail').find(); + var future = element('.reports-detail'); expect(future.name).toEqual("Find element '.reports-detail'"); timeTravel(future); expect(future.value.text()). @@ -168,7 +168,7 @@ describe("DSL", function() { toEqual('Description : Details...'); }); it('should find elements with angular syntax', function() { - var future = element('{{report.description}}').find(); + var future = element('{{report.description}}'); expect(future.name).toEqual("Find element '{{report.description}}'"); timeTravel(future); expect(future.value.text()).toEqual('Details...'); -- cgit v1.2.3 From 60eeeb9f20be3220dbb891abef848fe3754437da Mon Sep 17 00:00:00 2001 From: Shyam Seshadri Date: Sat, 14 Aug 2010 03:05:50 +0800 Subject: Provide all jquery functions as futures --- test/scenario/DSLSpec.js | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) (limited to 'test') diff --git a/test/scenario/DSLSpec.js b/test/scenario/DSLSpec.js index 552e6211..f8606641 100644 --- a/test/scenario/DSLSpec.js +++ b/test/scenario/DSLSpec.js @@ -159,20 +159,27 @@ describe("DSL", function() { expect(future.fulfilled).toBeTruthy(); } it('should find elements on the page and provide jquery api', function() { - var future = element('.reports-detail'); - expect(future.name).toEqual("Find element '.reports-detail'"); + var future = element('.reports-detail').text(); + expect(future.name).toEqual("Element '.reports-detail'.text()"); timeTravel(future); - expect(future.value.text()). + expect(future.value). toEqual('Description : Details...Date created: 01/01/01'); - expect(future.value.find('.desc').text()). - toEqual('Description : Details...'); +// expect(future.value.find('.desc').text()). +// toEqual('Description : Details...'); }); it('should find elements with angular syntax', function() { - var future = element('{{report.description}}'); - expect(future.name).toEqual("Find element '{{report.description}}'"); + var future = element('{{report.description}}').text(); + expect(future.name).toEqual("Element '{{report.description}}'.text()"); timeTravel(future); - expect(future.value.text()).toEqual('Details...'); - expect(future.value.attr('ng:bind')).toEqual('report.description'); + expect(future.value).toEqual('Details...'); +// expect(future.value.attr('ng:bind')).toEqual('report.description'); + }); + it('should be able to click elements', function(){ + var future = element('.link-class').click(); + expect(future.name).toEqual("Element '.link-class'.click()"); + executeFuture(future, html, function(value) { future.fulfill(value); }); + expect(future.fulfilled).toBeTruthy(); + // TODO(rajat): look for some side effect from click happening? }); }); }); -- cgit v1.2.3 From 26b5ae410970aab022452b5f0aa7f01a3963623a Mon Sep 17 00:00:00 2001 From: Misko Hevery Date: Sat, 14 Aug 2010 10:29:50 -0700 Subject: fix __proto__ for ie. --- test/JsonTest.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'test') diff --git a/test/JsonTest.js b/test/JsonTest.js index d077c0df..f6da26b5 100644 --- a/test/JsonTest.js +++ b/test/JsonTest.js @@ -75,11 +75,11 @@ JsonTest.prototype.testItShouldPreventRecursion = function () { }; JsonTest.prototype.testItShouldSerializeOnlyOwnProperties = function() { - var parent = { p: 'p'}; - var child = { c: 'c'}; - child.__proto__ = parent; - assertEquals('{"c":"c"}', angular.toJson(child)); -} + var parent = createScope(); + var child = createScope(parent); + child.c = 'c'; + expect(angular.toJson(child)).toEqual('{"c":"c"}'); +}; JsonTest.prototype.testItShouldSerializeSameObjectsMultipleTimes = function () { var obj = {a:'b'}; -- cgit v1.2.3