const Validator = require('./validator');

describe('Validator', () => {
  const questions = [
    {
      type: 'group',
      key: 'projectSummary',
      label: 'Project Summary',
      questions: [
        {
          type: 'input',
          key: 'project_title',
          label: 'Project Title',
          inputType: 'text',
          required: true,
        },
      ],
    },
  ];

  it('should find form valid', () => {
    const answers = {
      projectSummary: {
        project_title: 'Test Project',
      },
    };
    expect(Validator.isFormValid(questions, answers)).toBeTruthy();
  });

  it('should find form invalid when answer is empty', () => {
    const answers = {
      projectSummary: {
        project_title: '',
      },
    };
    expect(Validator.isFormValid(questions, answers)).toBeFalsy();
  });

  it('should find form invalid when question is not answered', () => {
    const answers = {
      projectSummary: {},
    };
    expect(Validator.isFormValid(questions, answers)).toBeFalsy();
  });
});
