department-of-veterans-affairs/vets-website

View on GitHub
src/applications/vaos/components/Breadcrumbs.unit.spec.js

Summary

Maintainability
C
1 day
Test Coverage
import React from 'react';
import { expect } from 'chai';
import { renderWithStoreAndRouter } from '../tests/mocks/setup';
import Breadcrumbs from './Breadcrumbs';

describe('VAOS Component: Breadcrumbs', () => {
  const initialState = {
    featureToggles: {
      vaOnlineSchedulingBreadcrumbUrlUpdate: true,
    },
  };
  it('should display Pending appointments as last crumb', () => {
    const url = 'my-health/appointments/pending';
    const screen = renderWithStoreAndRouter(<Breadcrumbs />, {
      initialState,
      path: url,
    });
    const navigation = screen.getByRole('navigation', { name: 'Breadcrumbs' });
    expect(navigation).to.exist;
    const crumb =
      navigation.breadcrumbList[navigation.breadcrumbList.length - 1].label;
    expect(crumb).to.equal('Pending appointments');
  });

  it('should display Past appointments as last crumb', () => {
    const url = 'my-health/appointments/past';
    const screen = renderWithStoreAndRouter(<Breadcrumbs />, {
      initialState,
      path: url,
    });
    const navigation = screen.getByRole('navigation', { name: 'Breadcrumbs' });
    expect(navigation).to.exist;
    const crumb =
      navigation.breadcrumbList[navigation.breadcrumbList.length - 1].label;
    expect(crumb).to.equal('Past appointments');
  });
});