Skip to content
Snippets Groups Projects
Select Git revision
  • a7603d54d2e6349f433395d0d7fb3b6637a4a00c
  • demo_ci_gitlab_pages default
  • demo_gitlab_ci
  • 5-images-in-annotations
  • 5-final-images
  • 5-chpk-images-in-annot
  • tetras-main protected
  • 5-rebase-images-in-annot
  • 5-wip-images-in-annot
  • tmp
  • 1-edit-annotations-on-videos
  • 5-old-images-in-annotations
  • old_demo_ci_gitlab_pages
  • images_annotations
  • wip
  • devsetup
  • wip-annot-video-ui
  • wip-annotations-on-videos
  • master
  • v0.4.0_react16
  • wip-debugging-annotations
21 results

AnnotationCreation.test.js

Blame
  • Forked from IIIF / Mirador / Mirador annotations
    Source project has a limited visibility.
    setupJest.js 1.13 KiB
    /* eslint-disable import/no-extraneous-dependencies */
    import fetchMock from 'jest-fetch-mock';
    import sizeMe from 'react-sizeme';
    import i18next from 'i18next';
    import { setupIntersectionMocking } from 'react-intersection-observer/test-utils';
    import en from './src/locales/en/translation.json';
    
    jest.setTimeout(10000);
    
    sizeMe.noPlaceholders = true;
    
    const { TextEncoder } = require('util');
    
    global.TextEncoder = TextEncoder;
    
    // Setup Jest to mock fetch
    fetchMock.enableMocks();
    
    if (typeof Element !== 'undefined') Element.prototype.scrollTo = () => {};
    
    setupIntersectionMocking(jest.fn);
    
    /** */
    function Path2D() {
    }
    
    global.Path2D = Path2D;
    
    i18next.init({
      lng: 'en',
      resources: {
        en,
      },
    });
    
    jest.mock('react-i18next', () => ({
      I18nextProvider: ({ children }) => children,
      initReactI18next: {
        init: jest.fn(),
        type: '3rdParty',
      },
      // this mock makes sure any components using the translate HoC receive the t function as a prop
      withTranslation: () => (Component) => {
        Component.defaultProps = { // eslint-disable-line no-param-reassign
          ...Component.defaultProps, t: k => k,
        };
        return Component;
      },
    }));