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
...
82 lines
2.7 KiB
JavaScript
82 lines
2.7 KiB
JavaScript
/* eslint-disable space-before-function-paren, no-var, one-var, one-var-declaration-per-line, new-parens, no-return-assign, new-cap, vars-on-top, max-len */
|
|
/* global Sidebar */
|
|
|
|
require('~/right_sidebar');
|
|
require('~/extensions/jquery.js');
|
|
|
|
(function() {
|
|
var $aside, $icon, $labelsIcon, $page, $toggle, assertSidebarState;
|
|
|
|
this.sidebar = null;
|
|
|
|
$aside = null;
|
|
|
|
$toggle = null;
|
|
|
|
$icon = null;
|
|
|
|
$page = null;
|
|
|
|
$labelsIcon = null;
|
|
|
|
assertSidebarState = function(state) {
|
|
var shouldBeCollapsed, shouldBeExpanded;
|
|
shouldBeExpanded = state === 'expanded';
|
|
shouldBeCollapsed = state === 'collapsed';
|
|
expect($aside.hasClass('right-sidebar-expanded')).toBe(shouldBeExpanded);
|
|
expect($page.hasClass('right-sidebar-expanded')).toBe(shouldBeExpanded);
|
|
expect($icon.hasClass('fa-angle-double-right')).toBe(shouldBeExpanded);
|
|
expect($aside.hasClass('right-sidebar-collapsed')).toBe(shouldBeCollapsed);
|
|
expect($page.hasClass('right-sidebar-collapsed')).toBe(shouldBeCollapsed);
|
|
return expect($icon.hasClass('fa-angle-double-left')).toBe(shouldBeCollapsed);
|
|
};
|
|
|
|
describe('RightSidebar', function() {
|
|
var fixtureName = 'issues/open-issue.html.raw';
|
|
preloadFixtures(fixtureName);
|
|
loadJSONFixtures('todos.json');
|
|
|
|
beforeEach(function() {
|
|
loadFixtures(fixtureName);
|
|
this.sidebar = new Sidebar;
|
|
$aside = $('.right-sidebar');
|
|
$page = $('.page-with-sidebar');
|
|
$icon = $aside.find('i');
|
|
$toggle = $aside.find('.js-sidebar-toggle');
|
|
return $labelsIcon = $aside.find('.sidebar-collapsed-icon');
|
|
});
|
|
it('should expand/collapse the sidebar when arrow is clicked', function() {
|
|
assertSidebarState('expanded');
|
|
$toggle.click();
|
|
assertSidebarState('collapsed');
|
|
$toggle.click();
|
|
assertSidebarState('expanded');
|
|
});
|
|
it('should float over the page and when sidebar icons clicked', function() {
|
|
$labelsIcon.click();
|
|
return assertSidebarState('expanded');
|
|
});
|
|
it('should collapse when the icon arrow clicked while it is floating on page', function() {
|
|
$labelsIcon.click();
|
|
assertSidebarState('expanded');
|
|
$toggle.click();
|
|
return assertSidebarState('collapsed');
|
|
});
|
|
|
|
it('should broadcast todo:toggle event when add todo clicked', function() {
|
|
var todos = getJSONFixture('todos.json');
|
|
spyOn(jQuery, 'ajax').and.callFake(function() {
|
|
var d = $.Deferred();
|
|
var response = todos;
|
|
d.resolve(response);
|
|
return d.promise();
|
|
});
|
|
|
|
var todoToggleSpy = spyOnEvent(document, 'todo:toggle');
|
|
|
|
$('.js-issuable-todo').click();
|
|
|
|
expect(todoToggleSpy.calls.count()).toEqual(1);
|
|
});
|
|
});
|
|
}).call(this);
|