<commit_before>require({
	paths: { jquery: 'libs/jquery' }
}, [
	'jquery',
	'../dist/jquery.onoff'
], function($, OnOff) {
	// noConflict for tests
	$.noConflict(true);

	// Start testing
	start();

	/*
		======== A Handy Little QUnit Reference ========
		http://api.qunitjs.com/

		Test methods:
			module(name, {[setup][ ,teardown]})
			test(name, callback)
			expect(numberOfAssertions)
			stop(increment)
			start(decrement)
		Test assertions:
			ok(value, [message])
			equal(actual, expected, [message])
			notEqual(actual, expected, [message])
			deepEqual(actual, expected, [message])
			notDeepEqual(actual, expected, [message])
			strictEqual(actual, expected, [message])
			notStrictEqual(actual, expected, [message])
			throws(block, [expected], [message])
	*/

	// Initialize inputs for every test
	var setupInstance = {
		setup: function() {
			this.$inputs = $('#qunit-fixture input[type=checkbox]').onoff();
		}
	};

	/* Environment
	---------------------------------------------------------------------- */
	module('environment');

	test('vars', function() {
		expect(3);
		equal(window.jQuery, undefined, 'No jQuery globals');
		equal(window.$, undefined, 'No jQuery globals');
		equal($.isFunction(OnOff), true, 'OnOff is a function');
	});

	/* jQuery#onoff
	---------------------------------------------------------------------- */
	module('jQuery#onoff', {
		setup: function() {
			this.$inputs = $('#qunit-fixture input[type=checkbox]');
		}
	});

	test('is chainable', function() {
		expect(1);
		strictEqual(this.$inputs.onoff(), this.$inputs, 'should be chainable');
	});

	test('will not work on non-checkboxes', function() {
		expect(1);
		throws(function() {
			$('#not-checkbox').onoff();
		}, 'checkboxes');
	});

	test('does not replace existing IDs', function() {
		expect(1);
		this.$inputs.onoff();
		equal(this.$inputs.first().attr('id'), 'myonoffswitch', 'ID no overwritten');
	});

	/* Methods
	---------------------------------------------------------------------- */
	module('jQuery#onoff methods', setupInstance);

	test('disable()/isDisabled()/enable()', function() {
		expect(4);
		this.$inputs.each(function() {
			var $this = $(this);
			$this.onoff('disable');
			ok($this.onoff('isDisabled'), 'OnOff should be disabled');
			$this.onoff('enable');
			ok(!$this.onoff('isDisabled'), 'OnOff should be enabled');
		});
	});

	test('destroy()', function() {
		expect(4);
		this.$inputs.each(function() {
			var $this = $(this);
			var instance = $this.onoff('instance');
			$this.onoff('destroy');
			equal($.data(this, OnOff.datakey), undefined, 'Data removed');
			ok(instance.disabled, 'OnOff disabled');
		});
	});

	test('unwrap()', function() {
		expect(6);
		this.$inputs.each(function() {
			var $this = $(this).onoff('unwrap');
			var instance = $this.onoff('instance');
			equal($this.parent('.onoffswitch').length, 0, 'Container removed');
			equal($this.next('label[for="' + this.id + '"]').length, 0, 'Label removed');
			ok(instance.disabled, 'OnOff disabled');
		});
	});

	test('wrap()', function() {
		expect(2);
		this.$inputs.each(function() {
			var $this = $(this);
			var instance = $this.onoff('instance');
			equal(
				$('<div/>').html(instance.$con.clone()).html()
					.replace(/\s*checked="\w*"/, '')
					.replace(/\s*id="\w*"/, '')
					.replace(/\s*for="\w*"/, '')
					.replace(/\s*name="\w*"/, ''),
				['<div class="onoffswitch">',
					'<input type="checkbox" class="onoffswitch-checkbox">',
					'<label class="onoffswitch-label">',
						'<div class="onoffswitch-inner"></div>',
						'<div class="onoffswitch-switch"></div>',
					'</label>',
				'</div>'].join(''),
				'Validate generated HTML'
			);
		});
	});

	/* Options
	---------------------------------------------------------------------- */
	module('jQuery#onoff options', setupInstance);

	test('option()', function() {
		expect(8);
		this.$inputs.each(function() {
			var options = $(this).onoff('option');
			ok($.isPlainObject(options), 'Calling option() returns all options');
			ok(~options.namespace.indexOf(OnOff.defaults.namespace), 'Event namespace starts with the default');
			ok(/\d+$/.test(options.namespace), 'Namespace ends with uuid');
			equal(options.className, OnOff.defaults.className, 'Event namespace is the default');
		});
	});

	test('namespace', function() {
		expect(4);
		this.$inputs.each(function() {
			var $this = $(this);<commit_msg>Pass tests in IE9<commit_after>require({
	paths: { jquery: 'libs/jquery' }
}, [
	'jquery',
	'../dist/jquery.onoff'
], function($, OnOff) {
	// noConflict for tests
	$.noConflict(true);

	// Start testing
	start();

	/*
		======== A Handy Little QUnit Reference ========
		http://api.qunitjs.com/

		Test methods:
			module(name, {[setup][ ,teardown]})
			test(name, callback)
			expect(numberOfAssertions)
			stop(increment)
			start(decrement)
		Test assertions:
			ok(value, [message])
			equal(actual, expected, [message])
			notEqual(actual, expected, [message])
			deepEqual(actual, expected, [message])
			notDeepEqual(actual, expected, [message])
			strictEqual(actual, expected, [message])
			notStrictEqual(actual, expected, [message])
			throws(block, [expected], [message])
	*/

	// Initialize inputs for every test
	var setupInstance = {
		setup: function() {
			this.$inputs = $('#qunit-fixture input[type=checkbox]').onoff();
		}
	};

	/* Environment
	---------------------------------------------------------------------- */
	module('environment');

	test('vars', function() {
		expect(3);
		equal(window.jQuery, undefined, 'No jQuery globals');
		equal(window.$, undefined, 'No jQuery globals');
		equal($.isFunction(OnOff), true, 'OnOff is a function');
	});

	/* jQuery#onoff
	---------------------------------------------------------------------- */
	module('jQuery#onoff', {
		setup: function() {
			this.$inputs = $('#qunit-fixture input[type=checkbox]');
		}
	});

	test('is chainable', function() {
		expect(1);
		strictEqual(this.$inputs.onoff(), this.$inputs, 'should be chainable');
	});

	test('will not work on non-checkboxes', function() {
		expect(1);
		throws(function() {
			$('#not-checkbox').onoff();
		}, 'checkboxes');
	});

	test('does not replace existing IDs', function() {
		expect(1);
		this.$inputs.onoff();
		equal(this.$inputs.first().attr('id'), 'myonoffswitch', 'ID no overwritten');
	});

	/* Methods
	---------------------------------------------------------------------- */
	module('jQuery#onoff methods', setupInstance);

	test('disable()/isDisabled()/enable()', function() {
		expect(4);
		this.$inputs.each(function() {
			var $this = $(this);
			$this.onoff('disable');
			ok($this.onoff('isDisabled'), 'OnOff should be disabled');
			$this.onoff('enable');
			ok(!$this.onoff('isDisabled'), 'OnOff should be enabled');
		});
	});

	test('destroy()', function() {
		expect(4);
		this.$inputs.each(function() {
			var $this = $(this);
			var instance = $this.onoff('instance');
			$this.onoff('destroy');
			equal($.data(this, OnOff.datakey), undefined, 'Data removed');
			ok(instance.disabled, 'OnOff disabled');
		});
	});

	test('unwrap()', function() {
		expect(6);
		this.$inputs.each(function() {
			var $this = $(this).onoff('unwrap');
			var instance = $this.onoff('instance');
			equal($this.parent('.onoffswitch').length, 0, 'Container removed');
			equal($this.next('label[for="' + this.id + '"]').length, 0, 'Label removed');
			ok(instance.disabled, 'OnOff disabled');
		});
	});

	test('wrap()', function() {
		expect(2);
		this.$inputs.each(function() {
			var $this = $(this);
			var instance = $this.onoff('instance');
			equal(
				$('<div/>').html(instance.$con.clone()).html()
					.replace(/\s*checked="\w*"/i, '')
					.replace(/\s*id="\w*"/i, '')
					.replace(/\s*for="\w*"/i, '')
					.replace(/\s*value="\w*"/i, '')
					.replace(/\s*type="\w*"/i, '')
					.replace(/\s*name="\w*"/i, ''),

				['<div class="onoffswitch">',
					'<input class="onoffswitch-checkbox">',
					'<label class="onoffswitch-label">',
						'<div class="onoffswitch-inner"></div>',
						'<div class="onoffswitch-switch"></div>',
					'</label>',
				'</div>'].join(''),

				'Validate generated HTML'
			);
		});
	});

	/* Options
	---------------------------------------------------------------------- */
	module('jQuery#onoff options', setupInstance);

	test('option()', function() {
		expect(8);
		this.$inputs.each(function() {
			var options = $(this).onoff('option');
			ok($.isPlainObject(options), 'Calling option() returns all options');
			ok(~options.namespace.indexOf(OnOff.defaults.namespace), 'Event namespace starts with the default');
			ok(/\d+$/.test(options.namespace), 'Namespace ends with uuid');
			equal(options.className, OnOff.defaults.className, 'Event namespace is the default');
		});
	});

	test('namespace', function() {
		expect(4);
		this.$inputs.each(function() {
			var $this = $(this);
{'fraction_non_alphanumeric': 0.2706809229037704, 'fraction_numerical': 0.0028137310073157004, 'mean_word_length': 3.0556823368324966, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 23, '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': '3904425', 'n_tokens_mistral': 3187, 'n_tokens_neox': 2786, 'n_words': 539}