Rename deprecated wasCalled() -> toHaveBeenCalled() in all specs

As well as wasNotCalled(), wasCalledWith(), wasNotCalledWith()
This commit is contained in:
Vojta Jina 2011-05-31 10:32:54 +02:00
parent b2f5299e0e
commit 2e5199997c
10 changed files with 36 additions and 36 deletions

View file

@ -59,18 +59,18 @@ describe('browser', function(){
it('should process callbacks immedietly with no outstanding requests', function(){
var callback = jasmine.createSpy('callback');
browser.notifyWhenNoOutstandingRequests(callback);
expect(callback).wasCalled();
expect(callback).toHaveBeenCalled();
});
it('should queue callbacks with outstanding requests', function(){
var callback = jasmine.createSpy('callback');
browser.xhr('GET', '/url', null, noop);
browser.notifyWhenNoOutstandingRequests(callback);
expect(callback).not.wasCalled();
expect(callback).not.toHaveBeenCalled();
xhr.readyState = 4;
xhr.onreadystatechange();
expect(callback).wasCalled();
expect(callback).toHaveBeenCalled();
});
});
@ -83,7 +83,7 @@ describe('browser', function(){
log += code + ':' + data + ';';
});
browser.notifyWhenNoOutstandingRequests(callback);
expect(callback).not.wasCalled();
expect(callback).not.toHaveBeenCalled();
expect(scripts.length).toEqual(1);
var script = scripts[0];
script.remove = function(){
@ -93,7 +93,7 @@ describe('browser', function(){
expect(url[0]).toEqual('http://example.org/path');
expect(typeof fakeWindow[url[1]]).toEqual($function);
fakeWindow[url[1]]('data');
expect(callback).wasCalled();
expect(callback).toHaveBeenCalled();
expect(log).toEqual('remove();200:data;');
expect(typeof fakeWindow[url[1]]).toEqual('undefined');
});
@ -172,10 +172,10 @@ describe('browser', function(){
it('should update outstandingRequests counter', function() {
var callback = jasmine.createSpy('callback');
browser.defer(callback);
expect(callback).not.wasCalled();
expect(callback).not.toHaveBeenCalled();
fakeSetTimeout.flush();
expect(callback).wasCalled();
expect(callback).toHaveBeenCalled();
});
});

View file

@ -140,10 +140,10 @@ describe('json', function(){
var spy = this.spyOn(JSON, 'parse').andCallThrough();
expect(fromJson('{}')).toEqual({});
expect(spy).wasNotCalled();
expect(spy).not.toHaveBeenCalled();
expect(fromJson('{}', true)).toEqual({});
expect(spy).wasCalled();
expect(spy).toHaveBeenCalled();
});

View file

@ -78,10 +78,10 @@ describe("resource", function() {
var cc = CreditCard.save({name:'misko'}, callback);
nakedExpect(cc).toEqual({name:'misko'});
expect(callback).wasNotCalled();
expect(callback).not.toHaveBeenCalled();
xhr.flush();
nakedExpect(cc).toEqual({id:123, name:'misko'});
expect(callback).wasCalledWith(cc);
expect(callback).toHaveBeenCalledWith(cc);
});
it("should read resource", function(){
@ -89,10 +89,10 @@ describe("resource", function() {
var cc = CreditCard.get({id:123}, callback);
expect(cc instanceof CreditCard).toBeTruthy();
nakedExpect(cc).toEqual({});
expect(callback).wasNotCalled();
expect(callback).not.toHaveBeenCalled();
xhr.flush();
nakedExpect(cc).toEqual({id:123, number:'9876'});
expect(callback).wasCalledWith(cc);
expect(callback).toHaveBeenCalledWith(cc);
});
it("should read partial resource", function(){
@ -106,7 +106,7 @@ describe("resource", function() {
expect(cc.number).not.toBeDefined();
cc.$get(callback);
xhr.flush();
expect(callback).wasCalledWith(cc);
expect(callback).toHaveBeenCalledWith(cc);
expect(cc.number).toEqual('9876');
});
@ -115,7 +115,7 @@ describe("resource", function() {
var cc = CreditCard.save({id:{key:123}, name:'misko'}, callback);
nakedExpect(cc).toEqual({id:{key:123}, name:'misko'});
expect(callback).wasNotCalled();
expect(callback).not.toHaveBeenCalled();
xhr.flush();
});
@ -124,10 +124,10 @@ describe("resource", function() {
var ccs = CreditCard.query({key:'value'}, callback);
expect(ccs).toEqual([]);
expect(callback).wasNotCalled();
expect(callback).not.toHaveBeenCalled();
xhr.flush();
nakedExpect(ccs).toEqual([{id:1}, {id:2}]);
expect(callback).wasCalledWith(ccs);
expect(callback).toHaveBeenCalledWith(ccs);
});
it("should have all arguments optional", function(){
@ -143,14 +143,14 @@ describe("resource", function() {
xhr.expectDELETE("/CreditCard/123").respond(200, {});
CreditCard.remove({id:123}, callback);
expect(callback).wasNotCalled();
expect(callback).not.toHaveBeenCalled();
xhr.flush();
nakedExpect(callback.mostRecentCall.args).toEqual([{}]);
callback.reset();
xhr.expectDELETE("/CreditCard/333").respond(204, null);
CreditCard.remove({id:333}, callback);
expect(callback).wasNotCalled();
expect(callback).not.toHaveBeenCalled();
xhr.flush();
nakedExpect(callback.mostRecentCall.args).toEqual([{}]);
});
@ -181,7 +181,7 @@ describe("resource", function() {
nakedExpect(cc).toEqual({name:'misko'});
xhr.flush();
nakedExpect(cc).toEqual({id:123});
expect(callback).wasCalledWith(cc);
expect(callback).toHaveBeenCalledWith(cc);
});
it('should not mutate the resource object if response contains no body', function(){

View file

@ -62,7 +62,7 @@ describe('scope/model', function(){
var onEval = jasmine.createSpy('onEval');
model.$onEval(onEval);
model.$eval('');
expect(onEval).wasNotCalled();
expect(onEval).not.toHaveBeenCalled();
});
it('should ignore none string/function', function(){

View file

@ -131,10 +131,10 @@ describe('ValidatorTest', function(){
var spy = jasmine.createSpy();
asynchronous.call(self, "kai", spy);
expect(spy).wasNotCalled();
expect(spy).not.toHaveBeenCalled();
asynchronous.call(self, "misko", spy);
expect(spy).wasCalled();
expect(spy).toHaveBeenCalled();
});
it("should ignore old callbacks, and not remove spinner", function(){
@ -156,7 +156,7 @@ describe('ValidatorTest', function(){
scope.updateFn = jasmine.createSpy();
scope.name = 'misko';
scope.$eval();
expect(scope.asyncFn).wasCalledWith('misko', scope.asyncFn.mostRecentCall.args[1]);
expect(scope.asyncFn).toHaveBeenCalledWith('misko', scope.asyncFn.mostRecentCall.args[1]);
assertTrue(scope.$element.hasClass('ng-input-indicator-wait'));
scope.asyncFn.mostRecentCall.args[1]('myError', {id: 1234, data:'data'});
assertFalse(scope.$element.hasClass('ng-input-indicator-wait'));

View file

@ -43,10 +43,10 @@ describe('$defer', function() {
var eval = this.spyOn(scope, '$eval').andCallThrough();
$defer(function() {});
expect(eval).wasNotCalled();
expect(eval).not.toHaveBeenCalled();
$browser.defer.flush();
expect(eval).wasCalled();
expect(eval).toHaveBeenCalled();
eval.reset(); //reset the spy;
@ -61,10 +61,10 @@ describe('$defer', function() {
var eval = this.spyOn(scope, '$eval').andCallThrough();
$defer(function() {throw "Test Error";});
expect(eval).wasNotCalled();
expect(eval).not.toHaveBeenCalled();
$browser.defer.flush();
expect(eval).wasCalled();
expect(eval).toHaveBeenCalled();
});
it('should allow you to specify the delay time', function(){

View file

@ -57,10 +57,10 @@ describe('$xhr.bulk', function() {
$xhrBulk.flush(function(){ log += 'DONE';});
$browserXhr.flush();
expect($xhrError).wasCalled();
expect($xhrError).toHaveBeenCalled();
var cb = $xhrError.mostRecentCall.args[0].callback;
expect(typeof cb).toEqual($function);
expect($xhrError).wasCalledWith(
expect($xhrError).toHaveBeenCalledWith(
{url:'/req1', method:'GET', data:null, callback:cb},
{status:404, response:'NotFound'});

View file

@ -128,17 +128,17 @@ describe('$xhr.cache', function() {
$browserXhr.expectGET('/url').respond('+');
cache('GET', '/url', null, callback);
expect(eval).wasNotCalled();
expect(eval).not.toHaveBeenCalled();
$browserXhr.flush();
expect(eval).wasCalled();
expect(eval).toHaveBeenCalled();
eval.reset(); //reset the spy
cache('GET', '/url', null, callback);
expect(eval).wasNotCalled();
expect(eval).not.toHaveBeenCalled();
$browser.defer.flush();
expect(eval).wasCalled();
expect(eval).toHaveBeenCalled();
});
});

View file

@ -29,7 +29,7 @@ describe('$xhr.error', function() {
$browserXhr.flush();
var cb = $xhrError.mostRecentCall.args[0].callback;
expect(typeof cb).toEqual($function);
expect($xhrError).wasCalledWith(
expect($xhrError).toHaveBeenCalledWith(
{url:'/req', method:'POST', data:'MyData', callback:cb},
{status:500, body:'MyError'});
});

View file

@ -60,7 +60,7 @@ describe('$xhr', function() {
$xhr('GET', '/reqGET', null, function(){ throw "MyException"; });
$browserXhr.flush();
expect($log.error).wasCalledWith("MyException");
expect($log.error).toHaveBeenCalledWith("MyException");
});