2016-12-13 22:01:05 -05:00
|
|
|
/* eslint-disable no-unused-expressions, comma-spacing, prefer-const, no-prototype-builtins, semi, no-new, keyword-spacing, no-plusplus, no-shadow, max-len */
|
|
|
|
|
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 = {});
|
|
|
|
const fixtureTemplate = 'event_filter.html';
|
|
|
|
const filters = [
|
|
|
|
{
|
|
|
|
id: 'all',
|
|
|
|
}, {
|
|
|
|
id: 'push',
|
|
|
|
name: 'push events',
|
|
|
|
}, {
|
|
|
|
id: 'merged',
|
|
|
|
name: 'merge events',
|
|
|
|
}, {
|
|
|
|
id: 'comments',
|
|
|
|
},{
|
|
|
|
id: 'team',
|
|
|
|
}];
|
|
|
|
|
|
|
|
function getEventName(index) {
|
|
|
|
let filter = filters[index];
|
|
|
|
return filter.hasOwnProperty('name') ? filter.name : filter.id;
|
|
|
|
}
|
|
|
|
|
|
|
|
function getSelector(index) {
|
|
|
|
let filter = filters[index];
|
|
|
|
return `#${filter.id}_event_filter`
|
|
|
|
}
|
|
|
|
|
|
|
|
describe('Activities', () => {
|
|
|
|
beforeEach(() => {
|
|
|
|
fixture.load(fixtureTemplate);
|
2016-11-20 00:52:53 -05:00
|
|
|
new gl.Activities();
|
2016-08-29 13:09:33 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
for(let i = 0; i < filters.length; i++) {
|
|
|
|
((i) => {
|
|
|
|
describe(`when selecting ${getEventName(i)}`, () => {
|
|
|
|
beforeEach(() => {
|
|
|
|
$(getSelector(i)).click();
|
|
|
|
});
|
|
|
|
|
|
|
|
for(let x = 0; x < filters.length; x++) {
|
|
|
|
((x) => {
|
|
|
|
let shouldHighlight = i === x;
|
|
|
|
let testName = shouldHighlight ? 'should highlight' : 'should not highlight';
|
|
|
|
|
|
|
|
it(`${testName} ${getEventName(x)}`, () => {
|
|
|
|
expect($(getSelector(x)).parent().hasClass('active')).toEqual(shouldHighlight);
|
|
|
|
});
|
|
|
|
})(x);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
})(i);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
})();
|