more tests fixed

This commit is contained in:
Misko Hevery
2010-03-30 14:55:04 -07:00
parent d2d356918b
commit a7d62dcb55
11 changed files with 194 additions and 152 deletions

View File

@@ -33,16 +33,18 @@ describe('scope/model', function(){
it('should watch an expression for change', function(){
var model = createScope();
model.oldValue = "";
var count = 0;
var nameCount = 0, evalCount = 0;
model.name = 'adam';
model.$watch('name', function(){ count ++; });
model.$watch('name', function(){ nameCount ++; });
model.$watch(function(){return model.name;}, function(newValue, oldValue){
this.newValue = newValue;
this.oldValue = oldValue;
});
model.$onEval(function(){evalCount ++;});
model.name = 'misko';
model.$eval();
expect(count).toEqual(2); // since watches trigger $eval
expect(nameCount).toEqual(1);
expect(evalCount).toEqual(1);
expect(model.newValue).toEqual('misko');
expect(model.oldValue).toEqual('adam');
});