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
...
62 lines
1.5 KiB
JavaScript
62 lines
1.5 KiB
JavaScript
/* eslint-disable no-unused-expressions, no-prototype-builtins, no-new, no-shadow, max-len */
|
|
|
|
require('vendor/jquery.endless-scroll.js');
|
|
require('~/pager');
|
|
require('~/activities');
|
|
|
|
(() => {
|
|
window.gon || (window.gon = {});
|
|
const fixtureTemplate = 'static/event_filter.html.raw';
|
|
const filters = [
|
|
{
|
|
id: 'all',
|
|
}, {
|
|
id: 'push',
|
|
name: 'push events',
|
|
}, {
|
|
id: 'merged',
|
|
name: 'merge events',
|
|
}, {
|
|
id: 'comments',
|
|
}, {
|
|
id: 'team',
|
|
}];
|
|
|
|
function getEventName(index) {
|
|
const filter = filters[index];
|
|
return filter.hasOwnProperty('name') ? filter.name : filter.id;
|
|
}
|
|
|
|
function getSelector(index) {
|
|
const filter = filters[index];
|
|
return `#${filter.id}_event_filter`;
|
|
}
|
|
|
|
describe('Activities', () => {
|
|
beforeEach(() => {
|
|
loadFixtures(fixtureTemplate);
|
|
new gl.Activities();
|
|
});
|
|
|
|
for (let i = 0; i < filters.length; i += 1) {
|
|
((i) => {
|
|
describe(`when selecting ${getEventName(i)}`, () => {
|
|
beforeEach(() => {
|
|
$(getSelector(i)).click();
|
|
});
|
|
|
|
for (let x = 0; x < filters.length; x += 1) {
|
|
((x) => {
|
|
const shouldHighlight = i === x;
|
|
const testName = shouldHighlight ? 'should highlight' : 'should not highlight';
|
|
|
|
it(`${testName} ${getEventName(x)}`, () => {
|
|
expect($(getSelector(x)).parent().hasClass('active')).toEqual(shouldHighlight);
|
|
});
|
|
})(x);
|
|
}
|
|
});
|
|
})(i);
|
|
}
|
|
});
|
|
})();
|