<commit_before>/*global createContainer:false, removeContainer:false, rnd:false, getIframeDoc: false, $:false */

describe('EpicEditor([options])', function () {
  var editor
    , id
    , el
    , opts;

  beforeEach(function (done) {
    id = rnd();
    el = createContainer(id);
    opts =
      { basePath: '/epiceditor'
      , container: el
      , file: { autoSave: false }
      }
    // blow away the stack trace. Hack for Mocha:
    // https://github.com/visionmedia/mocha/issues/502
    setTimeout(done, 0);
  });

  afterEach(function (done) {
    if (editor.is('loaded')) {
      editor.unload();
    }
    if (!el.id) {
      (el.id = id); // to reset in the case where the id is removed
    }
    removeContainer(id);
    done();
  });

  describe('options.button', function () {
    it('should have all buttons enabled by default', function () {
      editor = new EpicEditor(opts).load();
      var wrapper = editor.getElement('wrapper');
      expect(wrapper.getElementsByClassName('epiceditor-fullscreen-btn').length)
        .to.equal(1);
      expect(wrapper.getElementsByClassName('epiceditor-toggle-preview-btn').length)
        .to.equal(1);
      expect(wrapper.getElementsByClassName('epiceditor-toggle-edit-btn').length)
        .to.equal(1);
    });
    it('should disable all buttons if the buttons config is set to false', function () {
      opts['button'] = false;
      editor = new EpicEditor(opts).load();
      var wrapper = editor.getElement('wrapper');
      expect(wrapper.getElementsByClassName('epiceditor-fullscreen-btn').length)
        .to.equal(0);
      expect(wrapper.getElementsByClassName('epiceditor-toggle-preview-btn').length)
        .to.equal(0);
      expect(wrapper.getElementsByClassName('epiceditor-toggle-edit-btn').length)
        .to.equal(0);
    });
    it('should enable all buttons if the buttons config is set to true', function () {
      opts.button = true;
      editor = new EpicEditor(opts).load();
      var wrapper = editor.getElement('wrapper');
      expect(wrapper.getElementsByClassName('epiceditor-fullscreen-btn').length)
        .to.equal(1);
      expect(wrapper.getElementsByClassName('epiceditor-toggle-preview-btn').length)
        .to.equal(1);
      expect(wrapper.getElementsByClassName('epiceditor-toggle-edit-btn').length)
        .to.equal(1);
    });
    it('should properly merge configs if none are specified', function () {
      // if no specific value for a button is specified, assume that it is true.
      opts.button = { fullscreen: false };
      editor = new EpicEditor(opts).load();
      var wrapper = editor.getElement('wrapper');
      expect(wrapper.getElementsByClassName('epiceditor-fullscreen-btn').length)
        .to.equal(0);
      expect(wrapper.getElementsByClassName('epiceditor-toggle-preview-btn').length)
        .to.equal(1);
      expect(wrapper.getElementsByClassName('epiceditor-toggle-edit-btn').length)
        .to.equal(1);
    });
    it('should always hide buttons if bar is hide', function () {
      opts.button = {bar: 'hide'};
      editor = new EpicEditor(opts).load();
      var wrapper = editor.getElement('wrapper');
      expect($(wrapper).find('[class*="btn"]').is(":visible")).to.be(false);
    });
    it('should always show buttons if bar is show', function () {
      opts.button = {bar: 'show'};
      editor = new EpicEditor(opts).load();
      var wrapper = editor.getElement('wrapper');
      expect($(wrapper).find('[class*="btn"]').is(":hidden")).to.be(false);
    });
  });

  it('should allow the container option to be passed as an element ID string', function () {
    opts.container = id;

    editor = new EpicEditor(opts).load();
    expect(editor.getElement('container').id).to.be(id);
  });
<commit_msg>Ticket #27 - fixing jerk-ass unit test for jerks<commit_after>/*global createContainer:false, removeContainer:false, rnd:false, getIframeDoc: false, $:false */

describe('EpicEditor([options])', function () {
  var editor
    , id
    , el
    , opts;

  beforeEach(function (done) {
    id = rnd();
    el = createContainer(id);
    opts =
      { basePath: '/epiceditor'
      , container: el
      , file: { autoSave: false }
      }
    // blow away the stack trace. Hack for Mocha:
    // https://github.com/visionmedia/mocha/issues/502
    setTimeout(done, 0);
  });

  afterEach(function (done) {
    if (editor.is('loaded')) {
      editor.unload();
    }
    if (!el.id) {
      (el.id = id); // to reset in the case where the id is removed
    }
    removeContainer(id);
    done();
  });

  describe('options.button', function () {
    it('should have all buttons enabled by default', function () {
      editor = new EpicEditor(opts).load();
      var wrapper = editor.getElement('wrapper');
      expect(wrapper.getElementsByClassName('epiceditor-fullscreen-btn').length)
        .to.equal(1);
      expect(wrapper.getElementsByClassName('epiceditor-toggle-preview-btn').length)
        .to.equal(1);
      expect(wrapper.getElementsByClassName('epiceditor-toggle-edit-btn').length)
        .to.equal(1);
    });
    it('should disable all buttons if the buttons config is set to false', function () {
      opts['button'] = false;
      editor = new EpicEditor(opts).load();
      var wrapper = editor.getElement('wrapper');
      expect(wrapper.getElementsByClassName('epiceditor-fullscreen-btn').length)
        .to.equal(0);
      expect(wrapper.getElementsByClassName('epiceditor-toggle-preview-btn').length)
        .to.equal(0);
      expect(wrapper.getElementsByClassName('epiceditor-toggle-edit-btn').length)
        .to.equal(0);
    });
    it('should enable all buttons if the buttons config is set to true', function () {
      opts.button = true;
      editor = new EpicEditor(opts).load();
      var wrapper = editor.getElement('wrapper');
      expect(wrapper.getElementsByClassName('epiceditor-fullscreen-btn').length)
        .to.equal(1);
      expect(wrapper.getElementsByClassName('epiceditor-toggle-preview-btn').length)
        .to.equal(1);
      expect(wrapper.getElementsByClassName('epiceditor-toggle-edit-btn').length)
        .to.equal(1);
    });
    it('should properly merge configs if none are specified', function () {
      // if no specific value for a button is specified, assume that it is true.
      opts.button = { fullscreen: false };
      editor = new EpicEditor(opts).load();
      var wrapper = editor.getElement('wrapper');
      expect(wrapper.getElementsByClassName('epiceditor-fullscreen-btn').length)
        .to.equal(0);
      expect(wrapper.getElementsByClassName('epiceditor-toggle-preview-btn').length)
        .to.equal(1);
      expect(wrapper.getElementsByClassName('epiceditor-toggle-edit-btn').length)
        .to.equal(1);
    });
    it('should always hide buttons if bar is hide', function () {
      opts.button = {bar: 'hide'};
      editor = new EpicEditor(opts).load();
      var wrapper = editor.getElement('wrapper');
      expect($(wrapper).find('#epiceditor-utilbar').is(":visible")).to.be(false);
    });
    it('should always show buttons if bar is show', function () {
      opts.button = {bar: 'show'};
      editor = new EpicEditor(opts).load();
      var wrapper = editor.getElement('wrapper');
      expect($(wrapper).find('#epiceditor-utilbar').is(":hidden")).to.be(false);
    });
  });

  it('should allow the container option to be passed as an element ID string', function () {
    opts.container = id;

    editor = new EpicEditor(opts).load();
    expect(editor.getElement('container').id).to.be(id);
  });

{'fraction_non_alphanumeric': 0.15342936434518303, 'fraction_numerical': 0.0044931941324170745, 'mean_word_length': 3.1377802077638055, 'pattern_counts': {'":': 4, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, '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': '5750339', 'n_tokens_mistral': 2243, 'n_tokens_neox': 2205, 'n_words': 471}