various bug fixes

This commit is contained in:
Misko Hevery
2010-04-09 16:20:15 -07:00
parent 41a5c408c2
commit 843bd355d2
18 changed files with 304 additions and 165 deletions

View File

@@ -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);
};

View File

@@ -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();
};

View File

@@ -47,6 +47,11 @@ describe("markups", function(){
expect(element.html()).toEqual('<option value="A">A</option>');
});
it('should process all bindings when we have leading space', function(){
compile('<a> {{a}}<br/>{{b}}</a>');
expect(sortedHtml(scope.$element)).toEqual('<a> <span ng-bind="a"></span><br></br><span ng-bind="b"></span></a>');
});
});

View File

@@ -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){

View File

@@ -207,13 +207,18 @@ describe("input widget", function(){
describe('ng:switch', function(){
it("should match urls", function(){
var scope = compile('<ng:switch on="url" using="route"><div ng-switch-when="/Book/:name">{{name}}</div></ng:include>');
var scope = compile('<ng:switch on="url" using="route:params"><div ng-switch-when="/Book/:name">{{params.name}}</div></ng:include>');
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('<ng:switch on="url" change="name=\'works\'"><div ng-switch-when="a">{{name}}</div></ng:include>');
scope.url = 'a';