<commit_before>/**
* Copyright (c) 2015 NAVER Corp.
* egjs projects are licensed under the MIT license
*/

module("Component Test");

var TestClass = eg.Class.extend(eg.Component,{
	"construct" : function(option){
		this.options = option;
	}
});
function noop() {}

module("on method", {
	setup : function(){
		this.oClass = new TestClass();
	}
});

test("Basic test",function(){
	//Given
	//When
	var returnVal = this.oClass.on("returnTest", noop);
	//Then
	strictEqual(returnVal, this.oClass, "When custom event added by on(), return value must be instance itself");
});

test("Add event handler by Object type",function(){
	//Given
	//When
	var returnVal = this.oClass.on({
		"test2" : noop,
		"test3" : noop
	});

	this.oClass.on({
		"test2" : noop,
		"test3" : noop
	});

	this.oClass.on('test3', noop);
	//Then
	strictEqual(returnVal.eventHandler.test2.length,2,"Event handler must added to 'test2'.");
	strictEqual(returnVal.eventHandler.test3.length,3,"Event handler must added to 'test3'");
	strictEqual(returnVal, this.oClass, "When custom event added by Object type, return value must be instance itself.");
});

test("Add event handler by invalid type",function(){
	//Given
	function getPropertyCount(obj) {
		var count = 0;
		for(var prop in obj) {
			if(this.hasOwnProperty(prop)) {
				// remove constructor (es6) in case of phantomjs
				if(prop !== "constructor") {
					count = count + 1;
				}
			}
		}
		return count;
	}
	//When
	var returnVal1 = this.oClass.on("test_string");<commit_msg>test(Component): call hasOwnProperty on window for IE8<commit_after>/**
* Copyright (c) 2015 NAVER Corp.
* egjs projects are licensed under the MIT license
*/

module("Component Test");

var TestClass = eg.Class.extend(eg.Component,{
	"construct" : function(option){
		this.options = option;
	}
});
function noop() {}

module("on method", {
	setup : function(){
		this.oClass = new TestClass();
	}
});

test("Basic test",function(){
	//Given
	//When
	var returnVal = this.oClass.on("returnTest", noop);
	//Then
	strictEqual(returnVal, this.oClass, "When custom event added by on(), return value must be instance itself");
});

test("Add event handler by Object type",function(){
	//Given
	//When
	var returnVal = this.oClass.on({
		"test2" : noop,
		"test3" : noop
	});

	this.oClass.on({
		"test2" : noop,
		"test3" : noop
	});

	this.oClass.on('test3', noop);
	//Then
	strictEqual(returnVal.eventHandler.test2.length,2,"Event handler must added to 'test2'.");
	strictEqual(returnVal.eventHandler.test3.length,3,"Event handler must added to 'test3'");
	strictEqual(returnVal, this.oClass, "When custom event added by Object type, return value must be instance itself.");
});

test("Add event handler by invalid type",function(){
	//Given
	function getPropertyCount(obj) {
		var count = 0;
		for(var prop in obj) {
			if(Object.prototype.hasOwnProperty.call(this, prop)) {
				// remove constructor (es6) in case of phantomjs
				if(prop !== "constructor") {
					count = count + 1;
				}
			}
		}
		return count;
	}
	//When
	var returnVal1 = this.oClass.on("test_string");
{'fraction_non_alphanumeric': 0.15574302401038287, 'fraction_numerical': 0.012654120700843608, 'mean_word_length': 4.054098360655738, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, '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': '338675', 'n_tokens_mistral': 1112, 'n_tokens_neox': 1030, 'n_words': 286}