const FlexibleQuestionnaire = require('./flexible-questionnaire');
const data = require('../../helper/flexible-questionnaire/fq-helper-test-data');

describe('validateUA', () => {
  const groupQuestion = {
    key: 'project_overview',
    label: 'Project Overview',
    questions: [data.inputQuestion, data.textAreaQuestion],
    required: true,
    type: 'group',
  };

  const fq = new FlexibleQuestionnaire();
  const questions = [groupQuestion];

  it('should validate the form successful when required questions are answered', () => {
    const answers = { project_overview: { project_title: 'test', project_summary: 'something' } };

    expect(fq.isValid(questions, answers)).toBeTruthy();
  });

  it('should fail to validate form successful when required questions are not answered', () => {
    const answers = { project_overview: { project_title: 'test', project_summary: '' } };

    expect(fq.isValid(questions, answers)).toBeFalsy();
  });
});
