2017-01-10 18:02:20 -05:00
|
|
|
/* eslint-disable no-new */
|
2016-12-13 22:01:05 -05:00
|
|
|
|
2017-01-09 18:23:54 -05:00
|
|
|
require('~/sidebar');
|
|
|
|
require('~/lib/utils/text_utility');
|
2016-08-08 17:19:46 -04:00
|
|
|
|
|
|
|
((global) => {
|
|
|
|
describe('Dashboard', () => {
|
2016-12-30 16:27:40 -05:00
|
|
|
const fixtureTemplate = 'static/dashboard.html.raw';
|
2016-08-08 17:19:46 -04:00
|
|
|
|
|
|
|
function todosCountText() {
|
|
|
|
return $('.js-todos-count').text();
|
|
|
|
}
|
|
|
|
|
|
|
|
function triggerToggle(newCount) {
|
|
|
|
$(document).trigger('todo:toggle', newCount);
|
|
|
|
}
|
|
|
|
|
2016-12-30 19:14:33 -05:00
|
|
|
preloadFixtures(fixtureTemplate);
|
2016-08-08 17:19:46 -04:00
|
|
|
beforeEach(() => {
|
2016-12-30 19:14:33 -05:00
|
|
|
loadFixtures(fixtureTemplate);
|
2016-08-08 17:19:46 -04:00
|
|
|
new global.Sidebar();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should update todos-count after receiving the todo:toggle event', () => {
|
|
|
|
triggerToggle(5);
|
|
|
|
expect(todosCountText()).toEqual('5');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should display todos-count with delimiter', () => {
|
|
|
|
triggerToggle(1000);
|
|
|
|
expect(todosCountText()).toEqual('1,000');
|
|
|
|
|
|
|
|
triggerToggle(1000000);
|
|
|
|
expect(todosCountText()).toEqual('1,000,000');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
})(window.gl);
|