diff options
author | Clement Ho <ClemMakesApps@gmail.com> | 2016-08-09 00:19:46 +0300 |
---|---|---|
committer | Clement Ho <ClemMakesApps@gmail.com> | 2016-10-27 00:28:56 +0300 |
commit | f610f69ab92827c49e9cbb528cacc26af10be081 (patch) | |
tree | ca255d2f6aa66340a856b1fd8e013a74d46353a5 /spec/javascripts/dashboard_spec.js.es6 | |
parent | 5a4e6721786dd080cd40ca4ea23fc4202a85e73f (diff) |
Add todo toggle event
Diffstat (limited to 'spec/javascripts/dashboard_spec.js.es6')
-rw-r--r-- | spec/javascripts/dashboard_spec.js.es6 | 38 |
1 files changed, 38 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..8021145d8e8 --- /dev/null +++ b/spec/javascripts/dashboard_spec.js.es6 @@ -0,0 +1,38 @@ +/*= require sidebar */ +/*= require jquery */ +/*= require jquery.cookie */ +/*= require lib/utils/text_utility */ + +((global) => { + describe('Dashboard', () => { + const fixtureTemplate = 'dashboard.html'; + + function todosCountText() { + return $('.js-todos-count').text(); + } + + function triggerToggle(newCount) { + $(document).trigger('todo:toggle', newCount); + } + + fixture.preload(fixtureTemplate); + beforeEach(() => { + fixture.load(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); |