Welcome to mirror list, hosted at ThFree Co, Russian Federation.

tabs_spec.js « users « admin « frontend « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 39ba86184868c3084abfa9ba6cfcd4a86ab23802 (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
import initTabs from '~/admin/users/tabs';
import Api from '~/api';

jest.mock('~/api.js');
jest.mock('~/lib/utils/common_utils');

describe('tabs', () => {
  beforeEach(() => {
    setFixtures(`
    <div>
      <div class="js-users-tab-item">
        <a href="#users" data-testid='users-tab'>Users</a>
      </div>
      <div class="js-users-tab-item">
        <a href="#cohorts" data-testid='cohorts-tab'>Cohorts</a>
      </div>
    </div`);

    initTabs();
  });

  afterEach(() => {});

  describe('tracking', () => {
    it('tracks event when cohorts tab is clicked', () => {
      document.querySelector('[data-testid="cohorts-tab"]').click();

      expect(Api.trackRedisHllUserEvent).toHaveBeenCalledWith('i_analytics_cohorts');
    });

    it('does not track an event when users tab is clicked', () => {
      document.querySelector('[data-testid="users-tab"]').click();

      expect(Api.trackRedisHllUserEvent).not.toHaveBeenCalled();
    });
  });
});