{"size": 1514, "ext": "js", "max_stars_repo_path": "src/utils/integrity/checker-existing-target.spec.js", "max_stars_repo_name": "NicoLaval/Pogues", "max_stars_repo_stars_event_min_datetime": "2015-03-31T15:36:20.000Z", "max_stars_repo_stars_event_max_datetime": "2021-01-06T15:31:52.000Z", "max_issues_repo_path": "src/utils/integrity/checker-existing-target.spec.js", "max_issues_repo_name": "NicoLaval/Pogues", "max_issues_repo_issues_event_min_datetime": "2015-03-20T16:17:02.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-31T13:05:55.000Z", "max_forks_repo_path": "src/utils/integrity/checker-existing-target.spec.js", "max_forks_repo_name": "NicoLaval/Pogues", "max_forks_repo_forks_event_min_datetime": "2015-04-01T20:19:41.000Z", "max_forks_repo_forks_event_max_datetime": "2021-12-13T09:07:20.000Z"}
{"max_stars_count": 14, "max_issues_count": 488, "max_forks_count": 21, "avg_line_length": 26.1034482759, "max_line_length": 104, "alphanum_fraction": 0.4788639366}
import checkerExistingTarget from './checker-existing-target';
import { INTEGRITY_TYPES } from 'constants/pogues-constants';

describe('checkerExistingTarget', () => {
  it('should return an empty array', () => {
    const input = {
      appState: {
        activeComponentsById: {
          '1': { name: 'question1', redirections: {} },
          '2': { name: 'question', redirections: {} },
        },
        activeQuestionnaire: {
          id: '1',
        },
      },
    };
    const output = {
      '1': {
        [INTEGRITY_TYPES.NOT_EXISTING_TARGET]: [],
      },
    };
    expect(checkerExistingTarget(input)).toEqual(output);
  });
  it('should return an array with all errors', () => {
    const input = {
      appState: {
        activeComponentsById: {
          '1': {
            name: 'question1',
            redirections: {
              j6p6my1d: {
                cible: 'j3343clt',
                condition: "$READY != '1'",
                id: 'j6p6my1d',
                label: 'Cible1',
              },
            },
          },
          '2': { name: 'question', redirections: {} },
        },
        activeQuestionnaire: {
          id: '1',
        },
      },
    };
    const output = {
      '1': {
        [INTEGRITY_TYPES.NOT_EXISTING_TARGET]: [
          {
            message: `The following targets of redirections don't exist for the questionnaire : Cible1`,
          },
        ],
      },
    };
    expect(checkerExistingTarget(input)).toEqual(output);
  });
});
