<commit_before>describe('AB Testing', function() {

	afterEach(function() {
		document.cookie = "codemumblerAB_index=;";
	});

	describe('AB plugin', function() {
		it('jquery plugin', function() {
			expect(typeof $.fn.ab).toBe('function');
		});

		it('ensure chaining possible', function(){
			var expected = $(document.body);
			expect(expected.ab({}).is('body')).toEqual(true);
		});
	});

	describe('AB set experiments', function() {
		var testElement, randomValue;
		beforeEach(function(){
			$(document.body).append("<div class='test-ab-element'/>");
			testElement = $('.test-ab-element');
			Math.random = function() {
				return 0;
			};
		});

		afterEach(function(){
			$('.test-ab-element').remove();
		});

		it('define text alternatives', function() {
			testElement.ab({
				'experiments':[{
					'value': 'experiment A'
				}]
			});
			expect(testElement.text()).toBe('experiment A');
		});

		it('define 2 text alternatives - pick A', function() {
			testElement.ab({
				'experiments':[{
					'value': 'experiment A'
				},{
					'value': 'experiment B'
				}]
			});
			expect(testElement.text()).toBe('experiment A');
		});

		it('define 2 text alternatives - pick B', function() {
			Math.random = function() {
				return 0.9;
			};
			testElement.ab({
				'experiments':[{
					'value': 'experiment A'
				},{
					'value': 'experiment B'
				}]
			});
			expect(testElement.text()).toBe('experiment B');
		});
	});

	describe('Cookie tests - ', function() {
		var testElement;
		function readCookie(cname) {
			var name = cname + "=";
			var ca = document.cookie.split(';');
			for(var i=0; i<ca.length; i++) {
				var c = ca[i];
				while (c.charAt(0)==' ') c = c.substring(1);
					if (c.indexOf(name) == 0) return c.substring(name.length,c.length);
			}
			return null;
		};

		function setCookie(cname, cvalue, exdays) {
			var d = new Date();
			d.setTime(d.getTime() + (exdays*24*60*60*1000));
			var expires = "expires="+d.toUTCString();
			document.cookie = cname + "=" + cvalue + "; " + expires;
		};

		beforeEach(function(){
			$(document.body).append("<div class='test-ab-element'/>");
			testElement = $('.test-ab-element');
		});

		afterEach(function(){
			$('.test-ab-element').remove();
		});

		describe('Experiment survives refresh via cookie', function() {
			beforeEach(function(){
				setCookie('codemumblerAB_index', '0', 1);
			});

			it('Uses cookie value', function() {
				testElement.ab({
					'experiments':[{
						'value': 'experiment A'
					},{
						'value': 'experiment B'
					}]
				});
				expect(testElement.text()).toBe('experiment A');
			});
		});

		describe('Saves experiment index', function() {
			it('Creates cookie', function() {
				Math.random = function() {
					return 0.9;
				};
				testElement.ab({
					'experiments':[{
						'value': 'experiment A'
					},{
						'value': 'experiment B'
					}]
				});
				expect(readCookie('codemumblerAB_index')).toBe('1');
			});
		});
	});
});<commit_msg>cleaned up the tests<commit_after>describe('AB Testing', function() {
	var testElement;
	beforeEach(function(){
		$(document.body).append('<div class="test-ab-element"/>');
		testElement = $('.test-ab-element');
		Math.random = function() {
			return 0;
		};
	});

	afterEach(function() {
		$('.test-ab-element').remove();
		document.cookie = 'codemumblerAB_index=;';
	});

	describe('AB plugin', function() {
		it('jquery plugin', function() {
			expect(typeof $.fn.ab).toBe('function');
		});

		it('ensure chaining possible', function(){
			var expected = $(document.body);
			expect(expected.ab({}).is('body')).toEqual(true);
		});
	});

	describe('AB set experiments', function() {
		it('define text alternatives', function() {
			testElement.ab({
				'experiments':[{
					'value': 'experiment A'
				}]
			});
			expect(testElement.text()).toBe('experiment A');
		});

		it('define 2 text alternatives - pick A', function() {
			testElement.ab({
				'experiments':[{
					'value': 'experiment A'
				},{
					'value': 'experiment B'
				}]
			});
			expect(testElement.text()).toBe('experiment A');
		});

		it('define 2 text alternatives - pick B', function() {
			Math.random = function() {
				return 0.9;
			};
			testElement.ab({
				'experiments':[{
					'value': 'experiment A'
				},{
					'value': 'experiment B'
				}]
			});
			expect(testElement.text()).toBe('experiment B');
		});
	});

	describe('Cookie tests - ', function() {
		function readCookie(cname) {
			var name = cname + "=";
			var ca = document.cookie.split(';');
			for(var i=0; i<ca.length; i++) {
				var c = ca[i];
				while (c.charAt(0)==' ') c = c.substring(1);
					if (c.indexOf(name) == 0) return c.substring(name.length,c.length);
			}
			return null;
		};

		function setCookie(cname, cvalue, exdays) {
			var d = new Date();
			d.setTime(d.getTime() + (exdays*24*60*60*1000));
			var expires = "expires="+d.toUTCString();
			document.cookie = cname + "=" + cvalue + "; " + expires;
		};

		describe('Experiment survives refresh via cookie', function() {
			it('Uses cookie value', function() {
				testElement.ab({
					'experiments':[{
						'value': 'experiment A'
					},{
						'value': 'experiment B'
					}]
				});
				expect(testElement.text()).toBe('experiment A');
			});

			it('Creates cookie', function() {
				Math.random = function() {
					return 0.9;
				};
				testElement.ab({
					'experiments':[{
						'value': 'experiment A'
					},{
						'value': 'experiment B'
					}]
				});
				expect(readCookie('codemumblerAB_index')).toBe('1');
			});
		});
	});
});
{'fraction_non_alphanumeric': 0.2090385307886208, 'fraction_numerical': 0.008282319049333813, 'mean_word_length': 3.179834462001505, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 6, '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': '2682030', 'n_tokens_mistral': 2365, 'n_tokens_neox': 1843, 'n_words': 360}