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

mocks_spec.js « jest_self_check « frontend « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: f1e9e12e6330b7ef92ee2dadf305547d5d77984c (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
41
42
43
import * as textUtils from '~/lib/utils/text_utility';

jest.mock('~/lib/utils/text_utility');

describe('does restore mocks config work?', () => {
  describe('shared spy', () => {
    const spy = jest.fn();

    beforeEach(() => {
      spy();
    });

    it('is only called once', () => {
      expect(spy).toHaveBeenCalledTimes(1);
    });

    it('is only called once B', () => {
      expect(spy).toHaveBeenCalledTimes(1);
    });

    it('is only called once C', () => {
      expect(spy).toHaveBeenCalledTimes(1);
    });
  });

  describe('module mock', () => {
    beforeEach(() => {
      textUtils.humanize('');
    });

    it('is only called once', () => {
      expect(textUtils.humanize).toHaveBeenCalledTimes(1);
    });

    it('is only called once B', () => {
      expect(textUtils.humanize).toHaveBeenCalledTimes(1);
    });

    it('is only called once C', () => {
      expect(textUtils.humanize).toHaveBeenCalledTimes(1);
    });
  });
});