<commit_before>buster.spec.expose();

describe('jquery.ajaxHandler', function () {
	'use strict';

	var expect = buster.expect;

	afterEach(function () {
		$.ajaxHandler.remove();
	});


	describe('.install()', function () {
		it('sets the options', function () {
			$.ajaxHandler.install();
			expect($.ajaxHandler.options).toBeObject();
		});


		it('replaces $.ajax and keeps a reference to the old version', function () {
			$.ajaxHandler.install();

//			expect($.ajax).toBeDefined();
			expect($.ajaxHandler.origAjax).toBeDefined();
		});
	});


	describe('.config()', function () {
		it('sets the `options` object using the defaults', function () {
			$.ajaxHandler.config();
			expect($.ajaxHandler.options).toBeObject();
			expect($.ajaxHandler.options.isAjaxHandlerEnabled).toBeFalse();
		});


		it('can override the defaults with new options', function () {
			$.ajaxHandler.config({isAjaxHandlerEnabled: true});
			expect($.ajaxHandler.options.isAjaxHandlerEnabled).toBeTrue();
		});


		it('sets properties on the `options` object and returns it', function () {
			var result = $.ajaxHandler.install({blah: true});

			expect($.ajaxHandler.options).toMatch(result);
			expect($.ajaxHandler.options).toMatch({
				blah: true
			});
		});
	});


	describe('remove', function () {
		it('resets the Backbone object back to its pre jquery.ajaxHandler state', function () {
			$.ajaxHandler.install({why: 'peaches'});
			$.ajaxHandler.remove();

			expect($.ajaxHandler.ajax).toBeDefined();
			expect($.ajaxHandler.origAjax).not.toBeDefined();
			expect($.ajaxHandler.options).not.toBeDefined();
		});
	});

});<commit_msg>+ more tests<commit_after>buster.spec.expose();

describe('jquery.ajaxHandler', function () {
	'use strict';

	var expect = buster.expect;

	after(function () {
		$.ajaxHandler.remove();
	});


	describe('.install()', function () {
		it('sets the options', function () {
			$.ajaxHandler.install();
			expect($.ajaxHandler.options).toBeObject();
		});


		it('replaces $.ajax and keeps a reference to the old version', function () {
			$.ajaxHandler.install();

			expect($.ajax).toBeDefined();
			expect($.ajaxHandler.origAjax).toBeDefined();
		});
	});


	describe('.config()', function () {
		it('sets the `options` object using the defaults', function () {
			$.ajaxHandler.config();
			expect($.ajaxHandler.options).toBeObject();
			expect($.ajaxHandler.options.isAjaxHandlerEnabled).toBeFalse();
		});


		it('can override the defaults with new options', function () {
			$.ajaxHandler.config({isAjaxHandlerEnabled: true});
			expect($.ajaxHandler.options.isAjaxHandlerEnabled).toBeTrue();
		});


		it('sets properties on the `options` object and returns it', function () {
			var result = $.ajaxHandler.install({blah: true});

			expect($.ajaxHandler.options).toMatch(result);
			expect($.ajaxHandler.options).toMatch({
				blah: true
			});
		});
	});


	describe('.remove()', function () {
		it('resets the Backbone object back to its pre jquery.ajaxHandler state', function () {
			$.ajaxHandler.install({why: 'peaches'});
			$.ajaxHandler.remove();

			expect($.ajaxHandler.ajax).toBeDefined();
			expect($.ajaxHandler.origAjax).not.toBeDefined();
			expect($.ajaxHandler.options).not.toBeDefined();
		});
	});


	describe('.ajaxWrapper()', function () {
		it('replaces $.ajax and calls .handleAjaxRequest() if `ajaxHandlerOptions.isAjaxHandlerEnabled` == true', function () {
			$.ajaxHandler.install();
			this.stub($.ajaxHandler, 'handleAjaxRequest');

			$.ajaxHandler.ajaxWrapper({url: 'http://blah.org', ajaxHandlerOptions:{isAjaxHandlerEnabled: true}});
			expect($.ajaxHandler.handleAjaxRequest).toHaveBeenCalled();
		});


		it('it calls the original $.ajax() method if `ajaxHandlerOptions.isAjaxHandlerEnabled` == false', function () {
			$.ajaxHandler.install();
			this.stub($.ajaxHandler, 'origAjax');

			$.ajaxHandler.ajaxWrapper({url: 'http://blah.org'});
			expect($.ajaxHandler.origAjax).toHaveBeenCalled();
		});
	});


	describe('.handleAjaxRequest()', function () {
		it('calls calls $.ajaxHandler.ajax()', function () {
			this.stub($.ajaxHandler, 'ajax');
			$.ajaxHandler.handleAjaxRequest();

			expect($.ajaxHandler.ajax).toHaveBeenCalled();
		});
	});

});
{'fraction_non_alphanumeric': 0.18764789398958825, 'fraction_numerical': 0.0, 'mean_word_length': 4.461240310077519, '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': '7297440', 'n_tokens_mistral': 1455, 'n_tokens_neox': 1275, 'n_words': 233}