<commit_before>if(typeof require === 'function') var kff = require('../build/kff.js');

describe('kff.CheckBinder', function()
{
	it('should bind check binder', function()
	{
		var myModel = new kff.Cursor({
			checked: true
		});

		var dispatcher = new kff.Dispatcher({
			set: function(event)
			{
				event.cursor.set(event.value);
				return {
					type: 'refresh'
				};
			}
		});

		var $input = $('<input type="checkbox" data-kff-bind="myModel.checked:check"/>');
		var view = new kff.View(
		{
			element: $input[0],
			scope: {
				myModel: myModel
			},
			dispatcher: dispatcher
		});
		view.renderAll();
		view.runAll();

		expect($input.is(':checked')).to.equal(true);
		myModel.setIn('checked', false);
		view.refreshAll();

		expect($input.is(':checked')).to.equal(false);

		$input[0].dispatchEvent(new MouseEvent('click'));
		// emitEvent($input[0], 'click');

		expect(myModel.getIn('checked')).to.equal(true);
	});

});<commit_msg>test(CheckBinder): update tests, add test for non-boolean value<commit_after>if(typeof require === 'function') var kff = require('../build/kff.js');

describe('kff.CheckBinder', function()
{
	it('should bind check binder', function()
	{
		var state = new kff.Cursor(true);

		var dispatcher = new kff.Dispatcher({
			set: function(event)
			{
				event.cursor.set(event.value);
				return {
					type: 'refresh'
				};
			}
		});

		var input = document.createElement('input');
		input.setAttribute('type', 'checkbox');
		input.setAttribute('data-kff-bind', 'state:check');

		var view = new kff.View(
		{
			element: input,
			scope: {
				state: state
			},
			dispatcher: dispatcher
		});
		view.initAll();

		expect(input.checked).to.equal(true);
		state.set(false);
		view.refreshAll();

		expect(input.checked).to.equal(false);

		input.dispatchEvent(new MouseEvent('click'));
		// emitEvent(input, 'click');

		expect(state.get()).to.equal(true);
	});


	it('should bind check binder to non-boolean state', function()
	{
		var checkedValue = 'checkedValue';
		var state = new kff.Cursor(checkedValue);

		var dispatcher = new kff.Dispatcher({
			set: function(event)
			{
				event.cursor.set(event.value);
				return {
					type: 'refresh'
				};
			}
		});

		var input = document.createElement('input');
		input.setAttribute('type', 'checkbox');
		input.setAttribute('data-kff-bind', 'state:check(checkedValue)');

		var view = new kff.View(
		{
			element: input,
			scope: {
				state: state
			},
			dispatcher: dispatcher
		});
		view.initAll();

		expect(input.checked).to.equal(true);
		state.set('uncheckedValue');
		view.refreshAll();

		expect(input.checked).to.equal(false);

		input.dispatchEvent(new MouseEvent('click'));
		// emitEvent(input, 'click');

		expect(state.get()).to.equal(checkedValue);
	});

});
{'fraction_non_alphanumeric': 0.1839080459770115, 'fraction_numerical': 0.0010775862068965517, 'mean_word_length': 3.7283531409168083, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, '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': '6417068', 'n_tokens_mistral': 1103, 'n_tokens_neox': 935, 'n_words': 172}