summaryrefslogtreecommitdiff
path: root/spec/javascripts/dashboard_spec.js.es6
blob: c0bdb89ed63b2858966dfd1186c29cdda2ed7f5e (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
/* 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);