department-of-veterans-affairs/vets-website

View on GitHub
src/applications/vaos/new-appointment/components/ReviewPage/ReviewRequestInfo/ContactDetailSection.unit.spec.js

Summary

Maintainability
A
0 mins
Test Coverage
import React from 'react';
import { expect } from 'chai';
import {
  createTestStore,
  renderWithStoreAndRouter,
} from '../../../../tests/mocks/setup';

import ContactDetailSection from './ContactDetailSection';

describe('VAOS Component: ContactDetailSection', () => {
  describe('best time to call', () => {
    it('should display best time to call when community care appointment', async () => {
      const store = createTestStore({
        newAppointment: {
          flowType: 'request',
          data: {
            facilityType: 'communityCare',
          },
        },
      });

      const screen = renderWithStoreAndRouter(
        <ContactDetailSection
          data={{
            bestTimeToCall: { morning: true },
          }}
        />,
        { store },
      );

      expect(await screen.queryByText(/Call morning/i)).to.exist;
    });

    it('should not display best time to call when request schedule', async () => {
      const store = createTestStore({
        newAppointment: {
          flowType: 'request',
          data: {
            facilityType: 'vamc',
          },
        },
      });

      const screen = renderWithStoreAndRouter(
        <ContactDetailSection
          data={{
            bestTimeToCall: { morning: true },
          }}
        />,
        { store },
      );

      expect(await screen.queryByText(/Call morning/i)).not.to.exist;
    });

    it('should not display best time to call when direct schedule', async () => {
      const store = createTestStore({
        newAppointment: {
          flowType: 'direct',
          data: {
            facilityType: 'vamc',
          },
        },
      });

      const screen = renderWithStoreAndRouter(
        <ContactDetailSection
          data={{
            bestTimeToCall: { morning: true },
          }}
        />,
        { store },
      );

      expect(await screen.queryByText('Call morning')).not.to.exist;
    });
  });
});