<commit_before>/* global it describe beforeEach, afterEach */

import { shallow } from 'enzyme';
import React from 'react';
import ReleaseToggleApp from './ReleaseToggleApp.jsx';
import { expect } from 'chai';
import Context from './core/context';
import sinon from 'sinon';

describe('<ReleaseToggleApp /> - No Context Tests', () => {
    let context = Context.empty();
    let spy = null;
    beforeEach(()=>{
        spy = sinon.spy(context, 'checkFeatures');
    });
    afterEach(()=>{
        context.checkFeatures.restore();
    });
    
    it('sets empty context when there is feature', () => {
        const wrapper = shallow(<ReleaseToggleApp><div className="my-feature">MyFeature</div></ReleaseToggleApp>);
        expect(wrapper.find('.my-feature')).to.be.length(1);
        expect(spy.calledWith({})).to.be.true;
    });
    it('renders nothing when checks exsiting of a feature', () => {
        const wrapper = shallow(<ReleaseToggleApp myFeature={true}><div className="my-feature">MyFeature</div></ReleaseToggleApp>);
        expect(wrapper.find('.my-feature')).to.be.length(0);
        expect(spy.calledWith({myFeature: true})).to.be.true;
    });
    it('renders children when checks not existing of a feature', () => {
        const wrapper = shallow(<ReleaseToggleApp myFeature={false}><div className="my-feature">MyFeature</div></ReleaseToggleApp>);
        expect(wrapper.find('.my-feature')).to.be.length(1);
        expect(spy.calledWith({myFeature: false})).to.be.true;
    });
});

describe('<ReleaseToggleApp /> UI Tests', () => {
    it('renders nothing when there is no child', () => {
        const wrapper = shallow(<ReleaseToggleApp></ReleaseToggleApp>);
        expect(wrapper.find('div')).to.be.length(0);
    });
    it('renders DIV tag as container', () => {
        const wrapper = shallow(<ReleaseToggleApp>MyFeature</ReleaseToggleApp>);
        expect(wrapper.find('div')).to.be.length(1);
    });
    it('renders container with class', () => {
        const wrapper = shallow(<ReleaseToggleApp className="myFeature">MyFeature</ReleaseToggleApp>);<commit_msg>working on tests<commit_after>/* global it describe beforeEach, afterEach */

import { shallow } from 'enzyme';
import React from 'react';
import ReleaseToggleApp from './ReleaseToggleApp.jsx';
import { expect } from 'chai';
import Context from './core/context';
import sinon from 'sinon';

describe('<ReleaseToggleApp /> - No Context Tests', () => {
    let spy = null;
    let app = <ReleaseToggleApp></ReleaseToggleApp>;
    beforeEach(()=>{
        spy = sinon.spy(ReleaseToggleApp.prototype.getChildContext, 'getChildContext');
    });
    afterEach(()=>{
        app.getChildContext.restore();
    });
    
    it('sets empty context when there is no feature', () => {
        shallow(app);
        expect(spy.returned()).to.deep.equal({});
    });
});

describe('<ReleaseToggleApp /> UI Tests', () => {
    it('renders nothing when there is no child', () => {
        const wrapper = shallow(<ReleaseToggleApp></ReleaseToggleApp>);
        expect(wrapper.find('div')).to.be.length(0);
    });
    it('renders DIV tag as container', () => {
        const wrapper = shallow(<ReleaseToggleApp>MyFeature</ReleaseToggleApp>);
        expect(wrapper.find('div')).to.be.length(1);
    });
    it('renders container with class', () => {
        const wrapper = shallow(<ReleaseToggleApp className="myFeature">MyFeature</ReleaseToggleApp>);
{'fraction_non_alphanumeric': 0.1716613325574629, 'fraction_numerical': 0.002036659877800407, 'mean_word_length': 3.7031463748290014, 'pattern_counts': {'":': 0, '<': 33, '<?xml version=': 0, '>': 51, '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': '2245859', 'n_tokens_mistral': 984, 'n_tokens_neox': 976, 'n_words': 211}