<commit_before>(function($) {

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

suite.prototype.info = {
	"className": "Echo.API",
	"suiteName": "API",
	"functions": [
		"Request.send",
		"Request.request",
		"Request.abort",
		"Transports.AJAX.available",
		"Transports.AJAX.send",
		"Transports.AJAX.abort",
		"Transports.XDomainRequest.available",
		"Transports.JSONP.available",
		"Transports.JSONP.send",
		"Transports.JSONP.abort",
		"Transport.send",
		"Transport.abort"
	]
};

suite.prototype.tests = {};

suite.prototype.tests.PrivateInterfaceTests = {
    "check": function() {
		var event1 = function() {},
			event2 = function() {};
		var req = new Echo.API.Request({
			"endpoint": "some_endpoint",
			"onSomeEvent": event1,
			"onSomeEvent2": event2,
			"onemotion": true
		});
		QUnit.equal("{%=baseURLs.api.streamserver%}/v1/some_endpoint", "//" + req._prepareURI(), "Checking URI assembler for trnsport url");
		var handlers = req._getHandlersByConfig();
		QUnit.ok("onSomeEvent" in handlers && "onSomeEvent2" in handlers, "Checking that component can retrieve event handlers from config");
	}
};

})(Echo.jQuery);<commit_msg>Add some tests for Echo.API + conversion to new format<commit_after>(function($) {

Echo.Tests.module("Echo.API", {
	"meta": {
		"className": "Echo.API",
		// TODO: cover all these methods with tests
		"functions": [
			"Request.send",
			"Request.request",
			"Request.abort",
			"Transports.AJAX.available",
			"Transports.AJAX.send",
			"Transports.AJAX.abort",
			"Transports.XDomainRequest.available",
			"Transports.JSONP.available",
			"Transports.JSONP.send",
			"Transports.JSONP.abort",
			"Transport.send",
			"Transport.abort"
		]
	}
});

Echo.Tests.test("private interface", function() {
	var req = new Echo.API.Request({
		"endpoint": "some_endpoint",
		"onSomeEvent": function() {},
		"onSomeEvent2": function() {},
		"onemotion": true
	});
	QUnit.equal("//" + req._prepareURI(), "{%=baseURLs.api.streamserver%}/v1/some_endpoint", "Checking URI assembler for transport url");
	var handlers = req._getHandlersByConfig();
	QUnit.ok("onSomeEvent" in handlers && "onSomeEvent2" in handlers, "Checking that component can retrieve event handlers from config");

	var request = function(url) {
		return new Echo.API.Request({
			"endpoint": "endpoint",
			"apiBaseURL": url
		});
	};
	QUnit.equal(request("https://example.com/v1/")._prepareURI(), "example.com/v1/endpoint", "[_prepareURI] https:// in URL");
	QUnit.equal(request("http://example.com/v1/")._prepareURI(), "example.com/v1/endpoint", "[_prepareURI] \"http://\" in URL");
	QUnit.equal(request("wss://example.com/v1/")._prepareURI(), "example.com/v1/endpoint", "[_prepareURI] \"wss://\" in URL");
	QUnit.equal(request("//example.com/v1/")._prepareURI(), "example.com/v1/endpoint", "[_prepareURI] \"//\" in URL");
	QUnit.equal(request("example.com/v1/")._prepareURI(), "example.com/v1/endpoint", "[_prepareURI] no protocol in URL");
});

})(Echo.jQuery);
{'fraction_non_alphanumeric': 0.19420094403236682, 'fraction_numerical': 0.006743088334457181, 'mean_word_length': 4.619318181818182, 'pattern_counts': {'":': 17, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, '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': '6493590', 'n_tokens_mistral': 1108, 'n_tokens_neox': 1025, 'n_words': 186}