From 843bd355d25ebf2369aec79f98cb6704d38497e9 Mon Sep 17 00:00:00 2001
From: Misko Hevery
Date: Fri, 9 Apr 2010 16:20:15 -0700
Subject: various bug fixes
---
test/ApiTest.js | 4 ++++
test/ValidatorsTest.js | 2 +-
test/markupSpec.js | 5 +++++
test/servicesSpec.js | 14 ++++++++++++++
test/widgetsSpec.js | 9 +++++++--
5 files changed, 31 insertions(+), 3 deletions(-)
(limited to 'test')
diff --git a/test/ApiTest.js b/test/ApiTest.js
index 19860822..5d85987b 100644
--- a/test/ApiTest.js
+++ b/test/ApiTest.js
@@ -250,3 +250,7 @@ ApiTest.prototype.testStringFromUTC = function(){
assertEquals("2003-09-10T13:02:03Z", angular.Date.toString(date));
assertEquals("str", angular.String.toDate("str"));
};
+
+ApiTest.prototype.testObjectShouldHaveExtend = function(){
+ assertEquals(angular.Object.extend, extend);
+};
diff --git a/test/ValidatorsTest.js b/test/ValidatorsTest.js
index 2b2f6753..17c67d38 100644
--- a/test/ValidatorsTest.js
+++ b/test/ValidatorsTest.js
@@ -12,7 +12,7 @@ ValidatorTest.prototype.testItShouldHaveThisSet = function() {
scope.$init();
assertEquals('misko', validator.first);
assertEquals('hevery', validator.last);
- assertSame(scope, validator._this);
+ assertSame(scope, validator._this.__proto__);
delete angular.validator.myValidator;
scope.$element.remove();
};
diff --git a/test/markupSpec.js b/test/markupSpec.js
index e416b8ea..a1112490 100644
--- a/test/markupSpec.js
+++ b/test/markupSpec.js
@@ -47,6 +47,11 @@ describe("markups", function(){
expect(element.html()).toEqual('');
});
+ it('should process all bindings when we have leading space', function(){
+ compile(' {{a}}
{{b}}');
+ expect(sortedHtml(scope.$element)).toEqual('
');
+ });
+
});
diff --git a/test/servicesSpec.js b/test/servicesSpec.js
index b7dfe4c8..91cc1f0e 100644
--- a/test/servicesSpec.js
+++ b/test/servicesSpec.js
@@ -42,6 +42,20 @@ describe("services", function(){
expect(scope.$location.toString()).toEqual('file:///Users/Shared/misko/work/angular.js/scenario/widgets.html#');
});
+ it('should update url on hash change', function(){
+ scope.$location.parse('http://server/#path?a=b');
+ scope.$location.hash = '';
+ expect(scope.$location.toString()).toEqual('http://server/#');
+ expect(scope.$location.hashPath).toEqual('');
+ });
+
+ it('should update url on hashPath change', function(){
+ scope.$location.parse('http://server/#path?a=b');
+ scope.$location.hashPath = '';
+ expect(scope.$location.toString()).toEqual('http://server/#?a=b');
+ expect(scope.$location.hash).toEqual('?a=b');
+ });
+
xit('should add stylesheets', function(){
scope.$document = {
getElementsByTagName: function(name){
diff --git a/test/widgetsSpec.js b/test/widgetsSpec.js
index b48656f9..c6158c37 100644
--- a/test/widgetsSpec.js
+++ b/test/widgetsSpec.js
@@ -207,13 +207,18 @@ describe("input widget", function(){
describe('ng:switch', function(){
it("should match urls", function(){
- var scope = compile('{{name}}
');
+ var scope = compile('{{params.name}}
');
scope.url = '/Book/Moby';
scope.$init();
-// jstestdriver.console.log('text');
expect(scope.$element.text()).toEqual('Moby');
});
+ it("should match sandwich ids", function(){
+ var scope = {};
+ var match = angular.widget['NG:SWITCH'].route.call(scope, '/a/123/b', '/a/:id');
+ expect(match).toBeFalsy();
+ });
+
it('should call init on switch', function(){
var scope = compile('{{name}}
');
scope.url = 'a';
--
cgit v1.2.3