<commit_before>enyo.kind({
	name: "AnimatorTest",
	kind: enyo.TestSuite,
	noDefer: true,
	testDeferLowPriorityTasks: function() {
		var finish = this.bindSafely("finish");
		var animation = new enyo.Animator({duration: 70});
		var c = new enyo.Component({
			executionOrder: [],
			executeHighPriorityJob: function() {
				this.executionOrder.push("high");
				this.high = true;
			},
			executeNormalPriorityJob: function() {
				this.executionOrder.push("normal");
				this.normal = true;
			},
			executeLowPriorityJob: function() {
				this.executionOrder.push("low");
				this.low = true;
			}
		});
		animation.play();

		c.startJob("LowPriorityJob", "executeLowPriorityJob", 1, 3); // gets deferred
		c.startJob("NormalPriorityJob", "executeNormalPriorityJob", 1); // is invoked immediately
		c.startJob("HighPriorityJob", "executeHighPriorityJob", 1, 8); // is invoked immediately

		setTimeout(function(){
			if(c.low){
				finish("low priority job execute despite being blocked by animation");
			}
			if(!c.normal){
				finish("normal priority job did not execute despite overriding priority");
			}
			if(!c.high){
				finish("high priority job did not execute despite overriding priority");
			}
		}, 10);

		setTimeout(function(){
			if(!c.low){
				finish("low priority job did not execute after animation has finished");
			} else {
				// check order of execution
				if( JSON.stringify(c.executionOrder) !== '["normal","high","low"]' ){
					finish("jobs did not execute in the correct order");
				}

				finish();
			}
		}, 90);
	}
});

//~ Test issue described in https://github.com/enyojs/enyo/commit/d76bca80195adedca4de61f197d7b452efe78b8c#commitcomment-4082791
//~ and fixed in https://github.com/enyojs/enyo/pull/449
enyo.kind({
	name: "AnimatorStartupTest",
	kind: enyo.TestSuite,
	noDefer: true,
	create: function(){
		this.inherited(arguments);

		var animation = new enyo.Animator({duration: 50});
		animation.play();

		this.c = new enyo.Component({
			counter: 0,
			executeStartUpJob: function(){
				this.counter++;
			}
		});
		this.c.startJob("startupjob", "executeStartUpJob", 1, 1);
	},
	testStartUpjobs: function() {
		setTimeout(function(){
			this.finish(this.c.counter ? "" : "Job didn't run even though the animation finished");
		}.bind(this), 60);
	}
});<commit_msg>Refactor AnimatorStartupTest to use Animator.onEnd instead of timeout<commit_after>enyo.kind({
	name: "AnimatorTest",
	kind: enyo.TestSuite,
	noDefer: true,
	testDeferLowPriorityTasks: function() {
		var finish = this.bindSafely("finish");
		var animation = new enyo.Animator({duration: 70});
		var c = new enyo.Component({
			executionOrder: [],
			executeHighPriorityJob: function() {
				this.executionOrder.push("high");
				this.high = true;
			},
			executeNormalPriorityJob: function() {
				this.executionOrder.push("normal");
				this.normal = true;
			},
			executeLowPriorityJob: function() {
				this.executionOrder.push("low");
				this.low = true;
			}
		});
		animation.play();

		c.startJob("LowPriorityJob", "executeLowPriorityJob", 1, 3); // gets deferred
		c.startJob("NormalPriorityJob", "executeNormalPriorityJob", 1); // is invoked immediately
		c.startJob("HighPriorityJob", "executeHighPriorityJob", 1, 8); // is invoked immediately

		setTimeout(function(){
			if(c.low){
				finish("low priority job execute despite being blocked by animation");
			}
			if(!c.normal){
				finish("normal priority job did not execute despite overriding priority");
			}
			if(!c.high){
				finish("high priority job did not execute despite overriding priority");
			}
		}, 10);

		setTimeout(function(){
			if(!c.low){
				finish("low priority job did not execute after animation has finished");
			} else {
				// check order of execution
				if( JSON.stringify(c.executionOrder) !== '["normal","high","low"]' ){
					finish("jobs did not execute in the correct order");
				}

				finish();
			}
		}, 90);
	}
});

//~ Test issue described in https://github.com/enyojs/enyo/commit/d76bca80195adedca4de61f197d7b452efe78b8c#commitcomment-4082791
//~ and fixed in https://github.com/enyojs/enyo/pull/449
enyo.kind({
	name: "AnimatorStartupTest",
	kind: enyo.TestSuite,
	noDefer: true,
	create: function(){
		this.inherited(arguments);

		this.animation = new enyo.Animator({duration: 50});
		this.animation.play();
		this.c = new enyo.Component({
			counter: 0,
			executeStartUpJob: function(){
				this.counter++;
			}
		});
		this.c.startJob("startupjob", "executeStartUpJob", 1, 1);
	},
	testStartUpjobs: function() {
		this.animation.onEnd = this.bindSafely("animationFinished");
	},
	animationFinished: function(){
		this.finish(this.c.counter ? "" : "Job didn't run even though the animation finished");
	},
});
{'fraction_non_alphanumeric': 0.15076013513513514, 'fraction_numerical': 0.01984797297297297, 'mean_word_length': 4.044728434504792, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5092564', 'n_tokens_mistral': 1812, 'n_tokens_neox': 1496, 'n_words': 347}