<commit_before>/* eslint-disable space-before-function-paren, no-var, one-var, one-var-declaration-per-line, object-shorthand, comma-dangle, no-return-assign, new-cap, padded-blocks, max-len */
/* global Dropzone */
/* global Mousetrap */
/* global ZenMode */

/*= require zen_mode */

(function() {
  var enterZen, escapeKeydown, exitZen;

  describe('ZenMode', function() {
    var fixtureName = 'issues/open-issue.html.raw';
    fixture.preload(fixtureName);
    beforeEach(function() {
      fixture.load(fixtureName);
      spyOn(Dropzone, 'forElement').and.callFake(function() {
        return {
          enable: function() {
            return true;
          }
        };
      // Stub Dropzone.forElement(...).enable()
      });
      this.zen = new ZenMode();
      // Set this manually because we can't actually scroll the window
      return this.zen.scroll_position = 456;
    });
    describe('on enter', function() {
      it('pauses Mousetrap', function() {
        spyOn(Mousetrap, 'pause');
        enterZen();
        return expect(Mousetrap.pause).toHaveBeenCalled();
      });
      return it('removes textarea styling', function() {
        $('textarea').attr('style', 'height: 400px');
        enterZen();
        return expect('textarea').not.toHaveAttr('style');
      });
    });
    describe('in use', function() {
      beforeEach(function() {
        return enterZen();
      });
      return it('exits on Escape', function() {
        escapeKeydown();
        return expect($('.zen-backdrop')).not.toHaveClass('fullscreen');
      });
    });
    return describe('on exit', function() {
      beforeEach(function() {
        return enterZen();
      });
      it('unpauses Mousetrap', function() {
        spyOn(Mousetrap, 'unpause');
        exitZen();
        return expect(Mousetrap.unpause).toHaveBeenCalled();
      });
      return it('restores the scroll position', function() {
        spyOn(this.zen, 'scrollTo');
        exitZen();
        return expect(this.zen.scrollTo).toHaveBeenCalled();
      });
    });
  });

  enterZen = function() {
    return $('.js-zen-enter').click();
  };

  exitZen = function() { // Ohmmmmmmm
    return $('.js-zen-leave').click();
  };

  escapeKeydown = function() {
    return $('textarea').trigger($.Event('keydown', {
      keyCode: 27
    }));
  };

}).call(this);<commit_msg>Make sure elements share the same scope<commit_after>/* eslint-disable space-before-function-paren, no-var, one-var, one-var-declaration-per-line, object-shorthand, comma-dangle, no-return-assign, new-cap, padded-blocks, max-len */
/* global Dropzone */
/* global Mousetrap */
/* global ZenMode */

/*= require zen_mode */

(function() {
  var enterZen, escapeKeydown, exitZen;

  describe('ZenMode', function() {
    var fixtureName = 'issues/open-issue.html.raw';
    fixture.preload(fixtureName);
    beforeEach(function() {
      fixture.load(fixtureName);
      spyOn(Dropzone, 'forElement').and.callFake(function() {
        return {
          enable: function() {
            return true;
          }
        };
      // Stub Dropzone.forElement(...).enable()
      });
      this.zen = new ZenMode();
      // Set this manually because we can't actually scroll the window
      return this.zen.scroll_position = 456;
    });
    describe('on enter', function() {
      it('pauses Mousetrap', function() {
        spyOn(Mousetrap, 'pause');
        enterZen();
        return expect(Mousetrap.pause).toHaveBeenCalled();
      });
      return it('removes textarea styling', function() {
        $('.notes-form textarea').attr('style', 'height: 400px');
        enterZen();
        return expect($('.notes-form textarea')).not.toHaveAttr('style');
      });
    });
    describe('in use', function() {
      beforeEach(function() {
        return enterZen();
      });
      return it('exits on Escape', function() {
        escapeKeydown();
        return expect($('.notes-form .zen-backdrop')).not.toHaveClass('fullscreen');
      });
    });
    return describe('on exit', function() {
      beforeEach(function() {
        return enterZen();
      });
      it('unpauses Mousetrap', function() {
        spyOn(Mousetrap, 'unpause');
        exitZen();
        return expect(Mousetrap.unpause).toHaveBeenCalled();
      });
      return it('restores the scroll position', function() {
        spyOn(this.zen, 'scrollTo');
        exitZen();
        return expect(this.zen.scrollTo).toHaveBeenCalled();
      });
    });
  });

  enterZen = function() {
    return $('.notes-form .js-zen-enter').click();
  };

  exitZen = function() { // Ohmmmmmmm
    return $('.notes-form .js-zen-leave').click();
  };

  escapeKeydown = function() {
    return $('.notes-form textarea').trigger($.Event('keydown', {
      keyCode: 27
    }));
  };

}).call(this);
{'fraction_non_alphanumeric': 0.17050882658359293, 'fraction_numerical': 0.0033229491173416407, 'mean_word_length': 2.602094240837696, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, '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': '5811076', 'n_tokens_mistral': 1497, 'n_tokens_neox': 1482, 'n_words': 283}