debian-mirror-gitlab/spec/frontend/jest_self_check/mocks_spec.js
2020-01-01 13:55:28 +05:30

43 lines
964 B
JavaScript

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);
});
});
});