<commit_before>import React from 'react';
import ReactDOM from 'react-dom';
import TestUtils from 'react-addons-test-utils';

import chai from 'chai';

import InlineEdit from '../../components/forms/input/inline';

const should = chai.should();

const { Simulate
			} = TestUtils;

describe('DataTable: ', function () {
	const sampleValue = 'Sample value';

	const renderInlineEdit = (instance) => function () {
		this.dom = document.createElement('div');
		document.body.appendChild(this.dom);
		this.component = ReactDOM.render(instance, this.dom);
	};

	function removeInlineEdit () {
		ReactDOM.unmountComponentAtNode(this.dom);
		document.body.removeChild(this.dom);
	}

	const getWrapper = (dom) => dom.querySelector('.slds-form-element');

	const getInput = (dom) => dom.querySelector('.slds-input');

	const getStatic = (dom) => dom.querySelector('.slds-form-element__static');

	const getTrigger = (dom) => getStatic(dom).querySelector('.slds-button');

	describe('Structure', function () {
		beforeEach(renderInlineEdit(
			<InlineEdit id="inline-edit-standard" value={sampleValue} />
		));

		afterEach(removeInlineEdit);

		it('renders static by default', function () {
			const wrapper = getWrapper(this.dom);
			const input = getInput(this.dom);
			const staticElement = getStatic(this.dom);
			const trigger = getTrigger(this.dom);

			should.exist(wrapper);
			should.not.exist(input);
			should.exist(staticElement);
			should.exist(trigger);
		});

		it.only('renders the correct value', function () {
			const staticElement = getStatic(this.dom);
			const value = staticElement.textContent;

			value.should.equal('Sample value'+'Edit');
		});
	});

	describe('Editable', function () {
		beforeEach(renderInlineEdit(
			<InlineEdit id="inline-edit-standard" value={sampleValue} />
		));

		afterEach(removeInlineEdit);

		it('becomes editable on click', function () {
			const trigger = getTrigger(this.dom);

			should.exist(trigger);

			Simulate.click(trigger, {});

			setTimeout(() => {
				const input = getInput(this.dom);
				const staticElement = getStatic(this.dom);

				should.exist(input);
				should.not.exist(staticElement);
			}, 100);
		});
	});

	describe('Custom Handler Function', function () {
		const enterEditModeHanlder = sinon.spy();
		const leaveEditModeHanlder = sinon.spy();

		beforeEach(renderInlineEdit(
			<InlineEdit 
				id="inline-edit-standard" 
				value={sampleValue} 
				onEnterEditMode={enterEditModeHanlder}
                onLeaveEditMode={leaveEditModeHanlder}/>
		));

		afterEach(removeInlineEdit);

		it('enterEditMode and leaveEditMode handler get called', function () {
			const trigger = getTrigger(this.dom);

			should.exist(trigger);

			Simulate.click(trigger, {});

			setTimeout(() => {
				const input = getInput(this.dom);
				
				should.exist(input);

				expect(enterEditModeHanlder.callCount).to.equal(1);
			}, 100);

			Simulate.click(trigger, {});

			setTimeout(() => {
				const input = getInput(this.dom);

				should.not.exist(input);

				expect(leaveEditModeHanlder.callCount).to.equal(1);
			}, 100);
			
		});
	});
});<commit_msg>forgot to remove .only in test<commit_after>import React from 'react';
import ReactDOM from 'react-dom';
import TestUtils from 'react-addons-test-utils';

import chai from 'chai';

import InlineEdit from '../../components/forms/input/inline';

const should = chai.should();

const { Simulate
			} = TestUtils;

describe('DataTable: ', function () {
	const sampleValue = 'Sample value';

	const renderInlineEdit = (instance) => function () {
		this.dom = document.createElement('div');
		document.body.appendChild(this.dom);
		this.component = ReactDOM.render(instance, this.dom);
	};

	function removeInlineEdit () {
		ReactDOM.unmountComponentAtNode(this.dom);
		document.body.removeChild(this.dom);
	}

	const getWrapper = (dom) => dom.querySelector('.slds-form-element');

	const getInput = (dom) => dom.querySelector('.slds-input');

	const getStatic = (dom) => dom.querySelector('.slds-form-element__static');

	const getTrigger = (dom) => getStatic(dom).querySelector('.slds-button');

	describe('Structure', function () {
		beforeEach(renderInlineEdit(
			<InlineEdit id="inline-edit-standard" value={sampleValue} />
		));

		afterEach(removeInlineEdit);

		it('renders static by default', function () {
			const wrapper = getWrapper(this.dom);
			const input = getInput(this.dom);
			const staticElement = getStatic(this.dom);
			const trigger = getTrigger(this.dom);

			should.exist(wrapper);
			should.not.exist(input);
			should.exist(staticElement);
			should.exist(trigger);
		});

		it('renders the correct value', function () {
			const staticElement = getStatic(this.dom);
			const value = staticElement.textContent;

			value.should.equal('Sample valueEdit');
		});
	});

	describe('Editable', function () {
		beforeEach(renderInlineEdit(
			<InlineEdit id="inline-edit-standard" value={sampleValue} />
		));

		afterEach(removeInlineEdit);

		it('becomes editable on click', function () {
			const trigger = getTrigger(this.dom);

			should.exist(trigger);

			Simulate.click(trigger, {});

			setTimeout(() => {
				const input = getInput(this.dom);
				const staticElement = getStatic(this.dom);

				should.exist(input);
				should.not.exist(staticElement);
			}, 100);
		});
	});

	describe('Custom Handler Function', function () {
		const enterEditModeHanlder = sinon.spy();
		const leaveEditModeHanlder = sinon.spy();

		beforeEach(renderInlineEdit(<InlineEdit id="inline-edit-standard" value={sampleValue} onEnterEditMode={enterEditModeHanlder} onLeaveEditMode={leaveEditModeHanlder} />
		));

		afterEach(removeInlineEdit);

		it('enterEditMode and leaveEditMode handler get called', function () {
			const trigger = getTrigger(this.dom);

			should.exist(trigger);

			Simulate.click(trigger, {});

			setTimeout(() => {
				const input = getInput(this.dom);
				
				should.exist(input);

				expect(enterEditModeHanlder.callCount).to.equal(1);
			}, 100);

			Simulate.click(trigger, {});

			setTimeout(() => {
				const input = getInput(this.dom);

				should.not.exist(input);

				expect(leaveEditModeHanlder.callCount).to.equal(1);
			}, 100);
		});
	});
});
{'fraction_non_alphanumeric': 0.15398230088495576, 'fraction_numerical': 0.0035398230088495575, 'mean_word_length': 4.285714285714286, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 25, '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': '787510', 'n_tokens_mistral': 2239, 'n_tokens_neox': 1918, 'n_words': 352}