<commit_before>(function($) {

var suite = Echo.Tests.Unit.Button = function() {};

suite.prototype.info = {
	"className": "Echo.Button",
	"functions": [
		"update",
		"render"
	]
};

suite.prototype.tests = {};

suite.prototype.tests.commonWorkflow = {
	"check": function() {
		var target = document.getElementById("qunit-fixture");
		$(target).empty();
		
		var element = $("<button>").appendTo(target);
		var button = new Echo.Button(element, {
			"label": "FirstLabel"
		});
		QUnit.ok($(target).html().match(/FirstLabel/),
			 "Checking that label is displayed");
		QUnit.ok(!element.attr('disabled'),
			"Checking that button is enabled by default");
		QUnit.ok(!$(target).html().match(/icon/),
			"Checking that icon CSS class is not added by default");
		
		var css = ".ui-test-icon { background: url(" + Echo.Loader.getURL("sdk/images/loading.gif") + "); height: 16px; width: 16px; }";
		Echo.Utils.addCSS(css, "echo-button-test");
		button.update({
			"label": "SecondLabel",
			"disabled": true,
			"icon": "ui-test-icon"
		});
		QUnit.ok(!$(target).html().match(/FirstLabel/) && $(target).html().match(/SecondLabel/),
			"Checking that label is changed after update() method");
		QUnit.ok(element.attr('disabled'),
			"Checking that button is disabled after update() method");
		QUnit.ok($(target).html().match(/icon/) && $(target).html().match(/ui-test-icon/),
			"Checking that icon CSS class is added to element after update() method");
		
		button.label = "ThirdLabel";
		button.render();
		QUnit.ok(!$(target).html().match(/SecondLabel/) && $(target).html().match(/ThirdLabel/),
			"Checking that label is changed after field updating and rerendering");
		button.disabled = false;
		button.render();
		QUnit.ok(!element.attr('disabled'),
			"Checking that button is enabled after field updating and rerendering");
		button.icon = false;
		button.render();
		QUnit.ok(!$(target).html().match(/icon/) && !$(target).html().match(/ui-test-icon/),
			"Checking that icon CSS class is not added to element after field updating and rerendering");
		
		$(target).empty();
		var element = $('<button disabled="disabled">ClickMe</button>').appendTo(target);
		button = new Echo.Button(element);
		QUnit.ok($(target).html().match(/ClickMe/),
			 "Checking that label value is taken from the element");
		QUnit.ok(element.attr('disabled'),
			"Checking that disabled value is taken from the element");
	}
};

})(Echo.jQuery);
<commit_msg>Fixed tests for Button<commit_after>(function($) {

var suite = Echo.Tests.Unit.Button = function() {};

suite.prototype.info = {
	"className": "Echo.Button",
	"functions": []
};

suite.prototype.tests = {};

suite.prototype.tests.commonWorkflow = {
	"config": {
		"async": true
	},
	"check": function() {
		
		var check = function() {
			var target = document.getElementById("qunit-fixture");
			$(target).empty();

			var element = $("<button>").appendTo(target);
			element.echoButton({
				"label": "FirstLabel"
			});
			QUnit.ok($(target).html().match(/FirstLabel/),
				 "Checking that label is displayed");
			QUnit.ok(!element.attr('disabled'),
				"Checking that button is enabled by default");
			QUnit.ok(!$(target).html().match(/icon/),
				"Checking that icon CSS class is not added by default");

			element.echoButton("update", {
				"label": "SecondLabel",
				"disabled": true,
				"icon": Echo.Loader.getURL("sdk/images/loading.gif")
			});
			QUnit.ok(!$(target).html().match(/FirstLabel/) && $(target).html().match(/SecondLabel/),
				"Checking that label is changed after update() method");
			QUnit.ok(element.attr('disabled'),
				"Checking that button is disabled after update() method");
			QUnit.ok($(target).html().match(/icon/) && $(target).html().match(/.*background:.*sdk\/images\/loading.gif/),
				"Checking that background icon is added to element after update() method");

			element.echoButton("update", {"label": "ThirdLabel"});
			QUnit.ok(!$(target).html().match(/SecondLabel/) && $(target).html().match(/ThirdLabel/),
				"Checking that label is changed after updating 'label' field");
			element.echoButton("update", {"disabled": false});
			QUnit.ok(!element.attr('disabled'),
				"Checking that button is enabled after updating 'disabled' field");
			element.echoButton("update", {"icon": false});
			QUnit.ok(!$(target).html().match(/icon/) && !$(target).html().match(/.*background:.*sdk\/images\/loading.gif/),
				"Checking that background icon is not added to element after updating 'icon' field");
			$(target).empty();

			element = $('<button disabled="disabled">ClickMe</button>').appendTo(target);
			element.echoButton();
			QUnit.ok($(target).html().match(/ClickMe/),
				 "Checking that label value is taken from the element");
			QUnit.ok(element.attr('disabled'),
				"Checking that disabled value is taken from the element");

			$(target).empty();
			QUnit.start();
		};
		
		Echo.Loader.download({
			"scripts": [{
				"url": Echo.Loader.getURL("sdk/third-party/bootstrap/plugins/echo-button.js")
			}],
			"callback": check
		});
	}
};

})(Echo.jQuery);

{'fraction_non_alphanumeric': 0.19553183076314748, 'fraction_numerical': 0.0007908264136022143, 'mean_word_length': 4.237060041407868, 'pattern_counts': {'":': 22, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2445514', 'n_tokens_mistral': 1756, 'n_tokens_neox': 1535, 'n_words': 358}