diff options
Diffstat (limited to 'spec/javascripts/dashboard_spec.js.es6')
-rw-r--r-- | spec/javascripts/dashboard_spec.js.es6 | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/spec/javascripts/dashboard_spec.js.es6 b/spec/javascripts/dashboard_spec.js.es6 new file mode 100644 index 00000000000..c0bdb89ed63 --- /dev/null +++ b/spec/javascripts/dashboard_spec.js.es6 @@ -0,0 +1,37 @@ +/* eslint-disable no-new */ + +require('~/sidebar'); +require('~/lib/utils/text_utility'); + +((global) => { + describe('Dashboard', () => { + const fixtureTemplate = 'static/dashboard.html.raw'; + + function todosCountText() { + return $('.js-todos-count').text(); + } + + function triggerToggle(newCount) { + $(document).trigger('todo:toggle', newCount); + } + + preloadFixtures(fixtureTemplate); + beforeEach(() => { + loadFixtures(fixtureTemplate); + 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); |