summaryrefslogtreecommitdiff
path: root/spec/javascripts/dashboard_spec.js.es6
blob: aadf6f518a86a5a2d80dbe6d035d0df225b9a286 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/* eslint-disable no-new, padded-blocks */

/*= require sidebar */
/*= require jquery */
/*= require js.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);