How to use the ts-mock-imports.ImportMock.mockFunction function in ts-mock-imports

To help you get started, we’ve selected a few ts-mock-imports examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github naver / egjs-flicking / test / unit / options.spec.ts View on Github external
it("should init with collectStatistics(true)", () => {
      // Given
      const mockGa = ImportMock.mockFunction(ga, "sendEvent");

      // When
      flickingInfo = createFlicking(horizontal.full, { collectStatistics: true });
      mockGa.restore();

      // Then
      expect(mockGa.callCount).to.be.equals(1);
    });
  });
github openfun / marsha / src / frontend / components / DashboardVideoPaneTranscriptOption / index.spec.tsx View on Github external
import { fireEvent, render } from '@testing-library/react';
import fetchMock from 'fetch-mock';
import React from 'react';
import { act } from 'react-dom/test-utils';
import { ImportMock } from 'ts-mock-imports';

import { DashboardVideoPaneTranscriptOption } from '.';
import * as useTimedTextTrackModule from '../../data/stores/useTimedTextTrack';
import { timedTextMode, uploadState } from '../../types/tracks';
import { Deferred } from '../../utils/tests/Deferred';
import { wrapInIntlProvider } from '../../utils/tests/intl';

const useTimedTextTrackStub = ImportMock.mockFunction(
  useTimedTextTrackModule,
  'useTimedTextTrack',
);

jest.mock('../../data/appData', () => ({
  appData: {},
}));

describe('', () => {
  afterEach(jest.resetAllMocks);

  afterAll(useTimedTextTrackStub.restore);
  const video = {
    description: 'Some description',
    has_transcript: false,
    id: '443',
github openfun / marsha / src / frontend / components / DashboardThumbnail / index.spec.tsx View on Github external
import { wrapInIntlProvider } from '../../utils/tests/intl';

jest.mock('react-router-dom', () => ({
  Redirect: ({ push, to }: { push: boolean; to: string }) =>
    `Redirect push to ${to}.`,
}));

jest.mock('../../data/appData', () => ({
  appData: {
    jwt: 'some token',
  },
}));

const mockAddThumbnail = jest.fn();

const useThumbnailStub = ImportMock.mockFunction(
  useThumbnailModule,
  'useThumbnail',
);

describe('', () => {
  afterEach(jest.resetAllMocks);

  afterAll(useThumbnailStub.restore);

  const video = {
    description: '',
    has_transcript: false,
    id: '43',
    is_ready_to_show: true,
    show_download: true,
    thumbnail: {
github openfun / marsha / src / frontend / components / VideoPlayer / index.spec.tsx View on Github external
jest.mock('jwt-decode', () => jest.fn());

jest.mock('../../utils/isAbrSupported', () => ({
  isHlsSupported: jest.fn(),
  isMSESupported: jest.fn(),
}));
const mockIsMSESupported = isMSESupported as jestMockOf;
const mockIsHlsSupported = isHlsSupported as jestMockOf;

jest.mock('../../Player/createPlayer', () => ({
  createPlayer: jest.fn(),
}));

const mockCreatePlayer = createPlayer as jestMockOf;

const useTimedTextTrackStub = ImportMock.mockFunction(
  useTimedTextTrackModule,
  'useTimedTextTrack',
);

jest.mock('../../data/appData', () => ({
  appData: {
    video: {
      description: 'Some description',
      id: 'video-id',
      is_ready_to_show: true,
      show_download: false,
      thumbnail: null,
      timed_text_tracks: [],
      title: 'Some title',
      upload_state: 'ready',
      urls: {

ts-mock-imports

Intuitive mocking for Typescript class imports

MIT
Latest version published 2 years ago

Package Health Score

50 / 100
Full package analysis