describe('Case State :  AwaitingConsideration', () => {
  before(() => {
    const getStub = sinon.stub(request, 'get');
    getStub
      .withArgs(sinon.match({
        uri: `${config.services.orchestrationService.getCaseUrl}`
      }))
      .resolves(merge({}, mockCaseResponse, {
        state: 'AwaitingConsideration',
        data: session
      }));

    sinon.stub(feesAndPaymentsService, 'getFee')
      .resolves({
        feeCode: 'FEE0002',
        version: 4,
        amount: 550.00,
        description: 'Filing an application for a divorce, nullity or civil partnership dissolution – fees order 1.2.' // eslint-disable-line max-len
      });
  });

  after(() => {
    request.get.restore();
    feesAndPaymentsService.getFee.restore();
  });

  journey.test([
    { step: Start },
    { step: IdamLogin, body: { success: 'yes' } },
    { step: Entry },
    { step: petitionProgressBar }
  ]);
});
 describe('View Co-Respondents response', () => {
   journey.test([
     { step: Start },
     { step: IdamLogin, body: { success: 'yes' } },
     { step: Entry },
     { step: petitionProgressBar },
     { step: reviewAosResponse, body: { reviewAosResponse: 'yes' } },
     { step: ReviewAosResponseFromCoRespondent, body: { reviewAosCRResponse: 'yes' } },
     { step: ApplyForDecreeNisi }
   ]);
 });
  describe('Intolerable: yes, livedApartSinceAdultery: yes', () => {
    journey.test([
      { step: Start },
      { step: IdamLogin, body: { success: 'yes' } },
      { step: Entry },
      { step: petitionProgressBar },
      { step: reviewAosResponse, body: { reviewAosResponse: 'yes' } },
      { step: ReviewAosResponseFromCoRespondent, body: { reviewAosCRResponse: 'yes' } },
      { step: respNotAdmitAdultery, body: { amendPetition: 'no' } },
      { step: ApplyForDecreeNisi, body: { applyForDecreeNisi: 'yes' } },
      {
        step: MiniPetition,
        body: {
          'changes.hasBeenChanges': 'no',
          'changes.statementOfTruthNoChanges': 'yes'
        }
      },
      { step: Intolerable, body: { intolerable: 'yes' } },
      { step: AdulteryFirstFoundOut, body: {
        'adulteryFirstFoundDate.day': '09',
        'adulteryFirstFoundDate.month': '08',
        'adulteryFirstFoundDate.year': '2011'
      } },
      { step: LivedApartSinceAdultery, body: { 'livedApart.livedApartSinceAdultery': 'yes' } },
      { step: ClaimCosts, body: { 'dnCosts.claimCosts': 'originalAmount' } },
      { step: ShareCourtDocuments, body: { upload: 'no' } },
      { step: CheckYourAnswers, body: { statementOfTruth: 'yes' } },
      { step: Done }
    ]);

    it('submits correct body to case orchestration service', () => {
      const body = {
        applyForDecreeNisi: 'yes',
        hasBeenChanges: 'no',
        changesDetails: null,
        statementOfTruthChanges: 'yes',
        claimCosts: 'originalAmount',
        costsDifferentDetails: null,
        uploadAnyOtherDocuments: 'no',
        statementOfTruth: 'yes',
        intolerable: 'yes',
        adulteryFirstFoundDate: moment('2011-08-09T00:00:00.000'),
        livedApartSinceAdultery: 'yes',
        datesLivedTogether: null
      };
      sinon.assert.calledWith(
        caseOrchestrationServiceSubmitStub,
        sinon.match(matchParam('body', body)
        )
      );
    });
  });
 describe('Intolerable: no', () => {
   journey.test([
     { step: Start },
     { step: IdamLogin, body: { success: 'yes' } },
     { step: Entry },
     { step: petitionProgressBar },
     { step: ApplyForDecreeNisi, body: { applyForDecreeNisi: 'yes' } },
     {
       step: MiniPetition,
       body: {
         'changes.hasBeenChanges': 'no',
         'changes.statementOfTruthNoChanges': 'yes'
       }
     },
     { step: Intolerable, body: { intolerable: 'no' } },
     { step: ExitIntolerable }
   ]);
 });
describe('Case State : AOSOverdue', () => {
  before(() => {
    const getStub = sinon.stub(request, 'get');
    const postStub = sinon.stub(request, 'post');

    getStub
      .withArgs(sinon.match({
        uri: `${config.services.orchestrationService.getCaseUrl}`
      }))
      .resolves(merge({}, mockCaseResponse, { state: 'DefendedDivorce', data: session }));

    caseOrchestrationServiceSubmitStub = postStub
      .withArgs(sinon.match({
        uri: `${config.services.orchestrationService.submitCaseUrl}/${mockCaseResponse.caseId}`
      }));
    caseOrchestrationServiceSubmitStub.resolves();

    sinon.stub(feesAndPaymentsService, 'getFee')
      .resolves({
        feeCode: 'FEE0002',
        version: 4,
        amount: 550.00,
        description: 'Filing an application for a divorce, nullity or civil partnership dissolution – fees order 1.2.' // eslint-disable-line max-len
      });
  });

  after(() => {
    request.get.restore();
    request.post.restore();
    feesAndPaymentsService.getFee.restore();
  });

  journey.test([
    { step: Start },
    { step: IdamLogin, body: { success: 'yes' } },
    { step: Entry },
    { step: petitionProgressBar },
    { step: ApplyForDecreeNisi, body: { applyForDecreeNisi: 'yes' } },
    {
      step: MiniPetition,
      body: {
        'changes.hasBeenChanges': 'no',
        'changes.statementOfTruthNoChanges': 'yes'
      }
    },
    { step: LivedApartSinceSeparation, body: { 'changes.livedApartSinceSeparation': 'yes' } },
    { step: ClaimCosts, body: { 'dnCosts.claimCosts': 'originalAmount' } },
    { step: ShareCourtDocuments, body: { upload: 'no' } },
    { step: CheckYourAnswers, body: { statementOfTruth: 'yes' } },
    { step: Done }
  ]);

  it('submits correct body to case orchestration service', () => {
    const body = {
      applyForDecreeNisi: 'yes',
      approximateDatesOfLivingTogetherField: null,
      changesDetails: null,
      claimCosts: 'originalAmount',
      costsDifferentDetails: null,
      hasBeenChanges: 'no',
      livedApartSinceSeparation: 'yes',
      statementOfTruth: 'yes',
      statementOfTruthChanges: 'yes',
      uploadAnyOtherDocuments: 'no'
    };
    sinon.assert.calledWith(caseOrchestrationServiceSubmitStub, sinon.match.has('body', body));
  });
});