Sha256: be42c0378b0f938a5c3985fc3d9c7a700bde6d5399c0892b587b6338c5a0b126

Contents?: true

Size: 1.58 KB

Versions: 13

Compression:

Stored size: 1.58 KB

Contents

// ========================================================================
// SC.Timer Base Tests
// ========================================================================
/*globals module test ok isObj equals expects */

module("SC.Timer.fireTime + SC.Timer.performAction ",{
  	setup: function() {
    	objectA = {} ;
    	objectB = {} ;
		
		object = SC.Object.create({			
			performActionProp:'',
		  	callAction:function(){
		    	this.set('performActionProp','performAction');
		    }	
		});	
  	}

});

test("performAction() should call the specified method ",function(){
	var timerObj;
    timerObj = SC.Timer.create(); //created a timer object
 	timerObj.action = object.callAction();	
	timerObj.performAction();
	equals('performAction',object.performActionProp);
});



test("fireTime() should return the next time the timer should fire", function(){
	var timerObj;	
	
	timerObj = SC.Timer.create();

	equals(-1,timerObj.fireTime(),'for isValid YES');	
	equals(-1,timerObj.fireTime(),'for startTime not set');	
	
	timerObj.startTime = 10;
	timerObj.interval = 10;	
	timerObj.lastFireTime = 5;
	equals(20,timerObj.fireTime(),'next fire time');	
	
});

test("fire() should call the action", function() {
	var count = 0;
	SC.RunLoop.begin() ;
	var start = SC.RunLoop.currentRunLoop.get('startTime') ;
	var t = SC.Timer.schedule({
		target: this,
		action: function() {
			count++;
		},
		interval: 100
	});
	t.fire();
	SC.RunLoop.end() ;
	stop(2500) ; // stops the test runner, fails after 2500ms
	setTimeout(function() {
		equals(2, count) ;
		window.start() ; // starts the test runner
		}, 1500);
});



Version data entries

13 entries across 13 versions & 2 rubygems

Version Path
sproutit-sproutcore-1.0.0.20090408130025 frameworks/sproutcore/frameworks/foundation/tests/system/timer/performAction.js
sproutit-sproutcore-1.0.0.20090416161445 frameworks/sproutcore/frameworks/foundation/tests/system/timer/performAction.js
sproutit-sproutcore-1.0.0.20090720093355 frameworks/sproutcore/frameworks/foundation/tests/system/timer/performAction.js
sproutit-sproutcore-1.0.0.20090720202429 frameworks/sproutcore/frameworks/foundation/tests/system/timer/performAction.js
sproutit-sproutcore-1.0.0.20090721125122 frameworks/sproutcore/frameworks/foundation/tests/system/timer/performAction.js
sproutit-sproutcore-1.0.126 frameworks/sproutcore/frameworks/foundation/tests/system/timer/performAction.js
sproutit-sproutcore-1.0.20090721145251 frameworks/sproutcore/frameworks/foundation/tests/system/timer/performAction.js
sproutit-sproutcore-1.0.20090721145280 frameworks/sproutcore/frameworks/foundation/tests/system/timer/performAction.js
sproutit-sproutcore-1.0.20090721145281 frameworks/sproutcore/frameworks/foundation/tests/system/timer/performAction.js
sproutit-sproutcore-1.0.20090721145282 frameworks/sproutcore/frameworks/foundation/tests/system/timer/performAction.js
sproutit-sproutcore-1.0.20090721145285 frameworks/sproutcore/frameworks/foundation/tests/system/timer/performAction.js
sproutit-sproutcore-1.0.203 frameworks/sproutcore/frameworks/foundation/tests/system/timer/performAction.js
sproutcore-1.0.1003 frameworks/sproutcore/frameworks/foundation/tests/system/timer/performAction.js