2017-01-12 00:52:42 -05:00
|
|
|
/* eslint-disable no-unused-expressions, no-prototype-builtins, no-new, no-shadow, max-len */
|
2016-12-13 22:01:05 -05:00
|
|
|
|
2016-10-24 17:26:41 -04:00
|
|
|
/*= require js.cookie.js */
|
2016-08-29 13:09:33 -04:00
|
|
|
/*= require jquery.endless-scroll.js */
|
|
|
|
/*= require pager */
|
|
|
|
/*= require activities */
|
|
|
|
|
|
|
|
(() => {
|
|
|
|
window.gon || (window.gon = {});
|
2016-12-30 16:27:40 -05:00
|
|
|
const fixtureTemplate = 'static/event_filter.html.raw';
|
2016-08-29 13:09:33 -04:00
|
|
|
const filters = [
|
|
|
|
{
|
|
|
|
id: 'all',
|
|
|
|
}, {
|
|
|
|
id: 'push',
|
|
|
|
name: 'push events',
|
|
|
|
}, {
|
|
|
|
id: 'merged',
|
|
|
|
name: 'merge events',
|
|
|
|
}, {
|
|
|
|
id: 'comments',
|
2017-01-11 23:27:41 -05:00
|
|
|
}, {
|
2016-08-29 13:09:33 -04:00
|
|
|
id: 'team',
|
|
|
|
}];
|
|
|
|
|
|
|
|
function getEventName(index) {
|
2017-01-12 00:52:42 -05:00
|
|
|
const filter = filters[index];
|
2016-08-29 13:09:33 -04:00
|
|
|
return filter.hasOwnProperty('name') ? filter.name : filter.id;
|
|
|
|
}
|
|
|
|
|
|
|
|
function getSelector(index) {
|
2017-01-12 00:52:42 -05:00
|
|
|
const filter = filters[index];
|
2017-01-10 17:54:56 -05:00
|
|
|
return `#${filter.id}_event_filter`;
|
2016-08-29 13:09:33 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
describe('Activities', () => {
|
|
|
|
beforeEach(() => {
|
2016-12-30 19:14:33 -05:00
|
|
|
loadFixtures(fixtureTemplate);
|
2016-11-20 00:52:53 -05:00
|
|
|
new gl.Activities();
|
2016-08-29 13:09:33 -04:00
|
|
|
});
|
|
|
|
|
2017-01-11 23:27:41 -05:00
|
|
|
for (let i = 0; i < filters.length; i += 1) {
|
2016-08-29 13:09:33 -04:00
|
|
|
((i) => {
|
|
|
|
describe(`when selecting ${getEventName(i)}`, () => {
|
|
|
|
beforeEach(() => {
|
|
|
|
$(getSelector(i)).click();
|
|
|
|
});
|
|
|
|
|
2017-01-11 23:27:41 -05:00
|
|
|
for (let x = 0; x < filters.length; x += 1) {
|
2016-08-29 13:09:33 -04:00
|
|
|
((x) => {
|
2017-01-12 00:52:42 -05:00
|
|
|
const shouldHighlight = i === x;
|
|
|
|
const testName = shouldHighlight ? 'should highlight' : 'should not highlight';
|
2016-08-29 13:09:33 -04:00
|
|
|
|
|
|
|
it(`${testName} ${getEventName(x)}`, () => {
|
|
|
|
expect($(getSelector(x)).parent().hasClass('active')).toEqual(shouldHighlight);
|
|
|
|
});
|
|
|
|
})(x);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
})(i);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
})();
|