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

describe('kff.ClickBinder', function()
{
	it('should bind click binder', function()
	{
		var myModel = new kff.Cursor({
			name: 'Karel'
		});

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

		var $div = $('<div data-kff-bind="myModel.name:click(Petr)"/>');
		var view = new kff.View(
		{
			element: $div,
			scope: {
				myModel: myModel
			},
			dispatcher: dispatcher
		});
		view.renderAll();
		view.runAll();

		expect(myModel.getIn('name')).to.equal('Karel');

		$div.trigger('click');

		expect(myModel.getIn('name')).to.equal('Petr');
	});
});<commit_msg>test(ClickBinder): test for using dynamic value from view scope in click binder<commit_after>if(typeof require === 'function') var kff = require('../build/kff.js');

describe('kff.ClickBinder', function()
{
	it('should bind click binder', function()
	{
		var myModel = new kff.Cursor({
			name: 'Karel'
		});

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

		var $div = $('<div data-kff-bind="myModel.name:click(Petr)"/>');
		var view = new kff.View(
		{
			element: $div,
			scope: {
				myModel: myModel
			},
			dispatcher: dispatcher
		});
		view.renderAll();
		view.runAll();

		expect(myModel.getIn('name')).to.equal('Karel');

		$div.trigger('click');

		expect(myModel.getIn('name')).to.equal('Petr');
	});

	it('should bind click binder using dynamic scope value lookup', function()
	{
		var myModel = new kff.Cursor({
			name: 'Karel',
			value: null
		});

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

		var $div = $('<div data-kff-bind="myModel.name:click(@myModel.value)"/>');
		var view = new kff.View(
		{
			element: $div,
			scope: {
				myModel: myModel
			},
			dispatcher: dispatcher
		});
		view.renderAll();
		view.runAll();

		expect(myModel.getIn('name')).to.equal('Karel');

		myModel.setIn('value', 'Petr');

		$div.trigger('click');

		expect(myModel.getIn('name')).to.equal('Petr');
	});
});
{'fraction_non_alphanumeric': 0.19496309161962658, 'fraction_numerical': 0.0, 'mean_word_length': 3.3389830508474576, 'pattern_counts': {'":': 0, '<': 6, '<?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': '5272820', 'n_tokens_mistral': 991, 'n_tokens_neox': 832, 'n_words': 159}