2017-01-10 23:02:20 +00:00
|
|
|
/* eslint-disable space-before-function-paren, no-var */
|
2017-01-06 18:46:56 +00:00
|
|
|
|
2017-05-16 21:01:51 +00:00
|
|
|
import '~/header';
|
|
|
|
import '~/lib/utils/text_utility';
|
2016-08-08 21:19:46 +00:00
|
|
|
|
|
|
|
(function() {
|
|
|
|
describe('Header', function() {
|
2017-03-29 21:16:57 +00:00
|
|
|
var todosPendingCount = '.todos-count';
|
2017-02-13 00:06:54 +00:00
|
|
|
var fixtureTemplate = 'issues/open-issue.html.raw';
|
2016-08-08 21:19:46 +00:00
|
|
|
|
|
|
|
function isTodosCountHidden() {
|
|
|
|
return $(todosPendingCount).hasClass('hidden');
|
|
|
|
}
|
|
|
|
|
|
|
|
function triggerToggle(newCount) {
|
|
|
|
$(document).trigger('todo:toggle', newCount);
|
|
|
|
}
|
|
|
|
|
2016-12-31 00:14:33 +00:00
|
|
|
preloadFixtures(fixtureTemplate);
|
2016-08-08 21:19:46 +00:00
|
|
|
beforeEach(function() {
|
2016-12-31 00:14:33 +00:00
|
|
|
loadFixtures(fixtureTemplate);
|
2016-08-08 21:19:46 +00:00
|
|
|
});
|
|
|
|
|
2017-03-29 21:16:57 +00:00
|
|
|
it('should update todos-count after receiving the todo:toggle event', function() {
|
2016-08-08 21:19:46 +00:00
|
|
|
triggerToggle(5);
|
|
|
|
expect($(todosPendingCount).text()).toEqual('5');
|
|
|
|
});
|
|
|
|
|
2017-03-29 21:16:57 +00:00
|
|
|
it('should hide todos-count when it is 0', function() {
|
2016-08-08 21:19:46 +00:00
|
|
|
triggerToggle(0);
|
|
|
|
expect(isTodosCountHidden()).toEqual(true);
|
|
|
|
});
|
|
|
|
|
2017-03-29 21:16:57 +00:00
|
|
|
it('should show todos-count when it is more than 0', function() {
|
2016-08-08 21:19:46 +00:00
|
|
|
triggerToggle(10);
|
|
|
|
expect(isTodosCountHidden()).toEqual(false);
|
|
|
|
});
|
|
|
|
|
2017-03-29 21:16:57 +00:00
|
|
|
describe('when todos-count is 1000', function() {
|
2016-08-08 21:19:46 +00:00
|
|
|
beforeEach(function() {
|
|
|
|
triggerToggle(1000);
|
|
|
|
});
|
|
|
|
|
2017-03-29 21:16:57 +00:00
|
|
|
it('should show todos-count', function() {
|
2016-08-08 21:19:46 +00:00
|
|
|
expect(isTodosCountHidden()).toEqual(false);
|
|
|
|
});
|
|
|
|
|
2017-03-29 21:16:57 +00:00
|
|
|
it('should show 99+ for todos-count', function() {
|
2017-02-21 19:21:49 +00:00
|
|
|
expect($(todosPendingCount).text()).toEqual('99+');
|
2016-08-08 21:19:46 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
2017-02-10 07:29:41 +00:00
|
|
|
}).call(window);
|