69e4072f89
* master: (389 commits)
Document "No gems fetched from git repositories" policy [ci skip]
Typos
Small gramatical tweaks
Typos
Added PHP & NPM doc
Use `:empty_project` where possible in request specs
Add caching of droplab ajax requests
Use `:empty_project` where possible in model specs
Revert 3f17f29a
Remove unused js response from refs controller
Add MR id to changelog entry
fixed small mini pipeline graph line glitch
Prevent form to be submitted twice
Fix Error 500 when repositories contain annotated tags pointing to blobs
Fix /explore sorting (trending)
Simplify wording in "adding an image" docs
Remove "official merge window" from CONTRIBUTING.md [ci skip]
Update repository check documentation
Fixed flexbox and wrap issues
Update two_factor_authentication.md
...
79 lines
2.3 KiB
JavaScript
79 lines
2.3 KiB
JavaScript
/* eslint-disable space-before-function-paren, no-var, one-var, one-var-declaration-per-line, object-shorthand, comma-dangle, no-return-assign, new-cap, 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';
|
|
preloadFixtures(fixtureName);
|
|
beforeEach(function() {
|
|
loadFixtures(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() {
|
|
return $('.notes-form .js-zen-leave').click();
|
|
};
|
|
|
|
escapeKeydown = function() {
|
|
return $('.notes-form textarea').trigger($.Event('keydown', {
|
|
keyCode: 27
|
|
}));
|
|
};
|
|
}).call(this);
|