2017-08-17 22:00:37 +05:30
|
|
|
/* eslint-disable no-unused-expressions, no-prototype-builtins, no-new, no-shadow, max-len */
|
|
|
|
|
2017-09-10 17:25:29 +05:30
|
|
|
import 'vendor/jquery.endless-scroll';
|
|
|
|
import '~/pager';
|
|
|
|
import '~/activities';
|
2016-11-03 12:29:30 +05:30
|
|
|
|
|
|
|
(() => {
|
|
|
|
window.gon || (window.gon = {});
|
2017-08-17 22:00:37 +05:30
|
|
|
const fixtureTemplate = 'static/event_filter.html.raw';
|
2016-11-03 12:29:30 +05:30
|
|
|
const filters = [
|
|
|
|
{
|
|
|
|
id: 'all',
|
|
|
|
}, {
|
|
|
|
id: 'push',
|
|
|
|
name: 'push events',
|
|
|
|
}, {
|
|
|
|
id: 'merged',
|
|
|
|
name: 'merge events',
|
|
|
|
}, {
|
|
|
|
id: 'comments',
|
2017-08-17 22:00:37 +05:30
|
|
|
}, {
|
2016-11-03 12:29:30 +05:30
|
|
|
id: 'team',
|
|
|
|
}];
|
|
|
|
|
|
|
|
function getEventName(index) {
|
2017-08-17 22:00:37 +05:30
|
|
|
const filter = filters[index];
|
2016-11-03 12:29:30 +05:30
|
|
|
return filter.hasOwnProperty('name') ? filter.name : filter.id;
|
|
|
|
}
|
|
|
|
|
|
|
|
function getSelector(index) {
|
2017-08-17 22:00:37 +05:30
|
|
|
const filter = filters[index];
|
|
|
|
return `#${filter.id}_event_filter`;
|
2016-11-03 12:29:30 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
describe('Activities', () => {
|
|
|
|
beforeEach(() => {
|
2017-08-17 22:00:37 +05:30
|
|
|
loadFixtures(fixtureTemplate);
|
|
|
|
new gl.Activities();
|
2016-11-03 12:29:30 +05:30
|
|
|
});
|
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
for (let i = 0; i < filters.length; i += 1) {
|
2016-11-03 12:29:30 +05:30
|
|
|
((i) => {
|
|
|
|
describe(`when selecting ${getEventName(i)}`, () => {
|
|
|
|
beforeEach(() => {
|
|
|
|
$(getSelector(i)).click();
|
|
|
|
});
|
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
for (let x = 0; x < filters.length; x += 1) {
|
2016-11-03 12:29:30 +05:30
|
|
|
((x) => {
|
2017-08-17 22:00:37 +05:30
|
|
|
const shouldHighlight = i === x;
|
|
|
|
const testName = shouldHighlight ? 'should highlight' : 'should not highlight';
|
2016-11-03 12:29:30 +05:30
|
|
|
|
|
|
|
it(`${testName} ${getEventName(x)}`, () => {
|
|
|
|
expect($(getSelector(x)).parent().hasClass('active')).toEqual(shouldHighlight);
|
|
|
|
});
|
|
|
|
})(x);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
})(i);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
})();
|