Skip to content

Commit

Permalink
Fix script-config-jest + remove not necessary mock in packages
Browse files Browse the repository at this point in the history
  • Loading branch information
smouillour committed Oct 20, 2023
1 parent 27f728b commit 08fb9f9
Show file tree
Hide file tree
Showing 37 changed files with 82 additions and 161 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,6 @@ import { render, screen } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import Component from './TreeHeader.component';

jest.mock('react-i18next', () => {
// eslint-disable-next-line global-require
const mockTranslations = require('../../../../test/i18nMock').default;

return mockTranslations();
});

describe('TreeHeader', () => {
it('should render a simple tree header', () => {
const { container } = render(<Component title="myTitle" />);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
import { render, screen } from '@testing-library/react';
import Component, { getDefaultIcon } from './TreeBranchIcon.component';
jest.unmock('@talend/design-system');
jest.mock('react-i18next', () => {
// eslint-disable-next-line global-require
const mockTranslations = require('../../../../test/i18nMock').default;

return mockTranslations();
});
jest.unmock('@talend/design-system');

describe('getDefaultIcon', () => {
it('should return a custom object icon', () => {
Expand Down
57 changes: 0 additions & 57 deletions packages/components/test/i18nMock.js

This file was deleted.

1 change: 0 additions & 1 deletion packages/faceted-search/jest.setup.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
// DS is mocked by ui-scripts, preventing us to use testing-library getByLabelText & others selectors
jest.unmock('@talend/design-system');
jest.mock('ally.js');
1 change: 0 additions & 1 deletion packages/faceted-search/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@
"@talend/scripts-config-storybook-lib": "^5.0.0",
"@testing-library/react": "^12.1.5",
"@testing-library/user-event": "^13.5.0",
"ally.js": "^1.4.1",
"babel-plugin-angularjs-annotate": "^0.10.0",
"cross-env": "^7.0.3",
"i18next": "^20.6.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import { render, screen, waitFor } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import getDefaultT from '../../../translate';

jest.mock('ally.js');

const badgeFacetedContextValue = {
dispatch: jest.fn(),
};
Expand Down
2 changes: 0 additions & 2 deletions packages/forms/src/UIForm/UIForm.container.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import userEvent from '@testing-library/user-event';
import { actions, getMockData, getMockNestedData, initProps } from '../../__mocks__/data';
import UIForm from './UIForm.container';

jest.mock('ally.js');

describe('UIForm container', () => {
let props;
beforeEach(() => {
Expand Down
1 change: 0 additions & 1 deletion packages/forms/src/UIForm/Widget/Widget.component.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { WidgetContext } from '../context';
import Widget from './Widget.component';

jest.unmock('@talend/design-system');
jest.mock('ally.js');

describe('Widget component', () => {
const schema = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import userEvent from '@testing-library/user-event';

import SingleButton from './SingleButton.component';

jest.mock('ally.js');
jest.unmock('@talend/design-system');

describe('SingleButton field', () => {
Expand Down
3 changes: 0 additions & 3 deletions packages/forms/src/UIForm/fields/Code/Code.component.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ import 'ace-builds/src-noconflict/ext-language_tools';

import Code, { CodeProps } from './Code.component';

// fix cannot read appendChild of null;
jest.mock('ally.js');

declare global {
interface Window {
ReactAce: { default: typeof ReactAce };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import userEvent from '@testing-library/user-event';

import Datalist from './Datalist.component';

jest.mock('ally.js');
jest.unmock('@talend/design-system');

const schema = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { render, screen } from '@testing-library/react';
import DatalistTextMode from './TextMode.component';

jest.mock('ally.js');
jest.unmock('@talend/design-system');
const schema = {
title: 'My List',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { act, render, screen, fireEvent } from '@testing-library/react';
import DateWidget from './Date.component';
jest.mock('ally.js');

jest.unmock('@talend/design-system');

describe('Date widget', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { act, render, screen, fireEvent } from '@testing-library/react';
import DateTimeWidget from './DateTime.component';

jest.mock('ally.js');
jest.unmock('@talend/design-system');

describe('DateTime widget', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { act, render, screen, fireEvent } from '@testing-library/react';
import TimeWidget from './Time.component';

jest.unmock('@talend/design-system');
jest.mock('ally.js');

describe('Time component', () => {
beforeEach(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import userEvent from '@testing-library/user-event';
import EnumerationWidget from './EnumerationWidget';

jest.unmock('@talend/design-system');
jest.mock('ally.js');

describe('EnumerationWidget', () => {
it('should render items', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { screen, render } from '@testing-library/react';
import FieldTemplate from './FieldTemplate.component';

jest.unmock('@talend/design-system');
jest.mock('ally.js');

describe('FieldTemplate', () => {
const defaultProps = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { screen, render } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import File, { FileWidget, base64Decode } from './File.component';

jest.mock('ally.js');
jest.unmock('@talend/design-system');

describe('File field', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { screen, render } from '@testing-library/react';

jest.mock('ally.js');
jest.unmock('@talend/design-system');

import TextMode from './TextMode.component';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { screen, render } from '@testing-library/react';
import { WidgetContext } from '../../context';
import KeyValue from './KeyValue.component';

jest.mock('ally.js');
jest.unmock('@talend/design-system');

const widgets = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import userEvent from '@testing-library/user-event';
import ListView from './ListView.component';

const NO_RESULT_MESSAGE = 'No results found';
jest.mock('ally.js');

jest.unmock('@talend/design-system');

describe('ListView field', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import userEvent from '@testing-library/user-event';

import MultiSelectTag from './MultiSelectTag.component';

jest.mock('ally.js');
jest.unmock('@talend/design-system');

describe('MultiSelectTag field', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { screen, render } from '@testing-library/react';

import RadioOrSelect from './RadioOrSelect.component';

jest.mock('ally.js');
jest.unmock('@talend/design-system');

describe('RadioOrSelect field', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { screen, render, fireEvent } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import Radios from './Radios.component';

jest.mock('ally.js');
jest.unmock('@talend/design-system');

describe('Radios field', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ const ResourcePickerMock = ({ toolbar, onRowClick, isSelected, collection, ...pr
</div>
);

jest.mock('ally.js');
jest.unmock('@talend/design-system');
jest.mock('@talend/react-components/lib/ResourcePicker', () => ResourcePickerMock);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import omit from 'lodash/omit';

import Select from './Select.component';

jest.mock('ally.js');
jest.unmock('@talend/design-system');

describe('Select field', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import userEvent from '@testing-library/user-event';
import Toggle from './Toggle.component';

jest.unmock('@talend/design-system');
jest.mock('ally.js');

describe('Toggle field', () => {
const schema = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { screen, render } from '@testing-library/react';
import userEvent from '@testing-library/user-event';

jest.unmock('@talend/design-system');
jest.mock('ally.js');

function TestArray(props) {
return <div data-testid="array" data-props={JSON.stringify(props, null, 2)} />;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import userEvent from '@testing-library/user-event';
import ArrayItem from './ArrayItem.component';

jest.unmock('@talend/design-system');
jest.mock('ally.js');

describe('Array Item component', () => {
it('should render control panel with item content', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { screen, render } from '@testing-library/react';
import DefaultArrayTemplate from './DefaultArrayTemplate.component';

jest.unmock('@talend/design-system');
jest.mock('ally.js');

const schema = {
description: 'Tnstructions to fill it',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { WidgetContext } from '../../context';
import widgets from '../../utils/widgets';

jest.unmock('@talend/design-system');
jest.mock('ally.js');

function customTitle(value, schema) {
return `${schema.title}: ${value.firstname} ${value.lastname}`;
Expand Down
1 change: 0 additions & 1 deletion packages/forms/src/rhf/fields/Input/Input.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { useForm, FormProvider } from 'react-hook-form';
import Input from './RHFInput.component';

jest.unmock('@talend/design-system');
jest.mock('ally.js');

/* eslint-disable-next-line react/prop-types */
function FormWrapper({ children, onSubmit }) {
Expand Down
1 change: 0 additions & 1 deletion packages/forms/src/rhf/fields/Select/Select.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { useForm, FormProvider } from 'react-hook-form';
import Select from './RHFSelect.component';

jest.unmock('@talend/design-system');
jest.mock('ally.js');

/* eslint-disable-next-line react/prop-types */
function FormWrapper({ children, onSubmit }) {
Expand Down
1 change: 0 additions & 1 deletion packages/forms/src/rhf/fields/TextArea/RHFTextArea.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { useForm, FormProvider } from 'react-hook-form';
import TextArea from './RHFTextArea.component';

jest.unmock('@talend/design-system');
jest.mock('ally.js');

/* eslint-disable-next-line react/prop-types */
function FormWrapper({ children, onSubmit }) {
Expand Down
Loading

0 comments on commit 08fb9f9

Please sign in to comment.