department-of-veterans-affairs/vets-website

View on GitHub
src/applications/check-in/actions/universal/universal.actions.unit.spec.js

Summary

Maintainability
A
3 hrs
Test Coverage
import { expect } from 'chai';

import {
  setApp,
  SET_APP,
  recordAnswer,
  RECORD_ANSWER,
  setError,
  SET_ERROR,
} from './index';

describe('check-in', () => {
  describe('universal actions', () => {
    describe('setApp', () => {
      it('should return correct action', () => {
        const action = setApp();
        expect(action.type).to.equal(SET_APP);
      });
      it('should return correct structure', () => {
        const action = setApp('preCheckIn');
        expect(action.payload.app).equal('preCheckIn');
      });
    });
    describe('recordAnswer', () => {
      it('should return correct action', () => {
        const action = recordAnswer({});
        expect(action.type).to.equal(RECORD_ANSWER);
      });
      it('should return correct structure', () => {
        const action = recordAnswer({
          demographicsUpToDate: 'yes',
        });
        expect(action.payload.demographicsUpToDate).equal('yes');
      });
    });
    describe('setError', () => {
      it('should return correct action', () => {
        const action = setError({});
        expect(action.type).to.equal(SET_ERROR);
      });
      it('should return correct structure', () => {
        const action = setError('max-validation');
        expect(action.payload.error).equal('max-validation');
      });
    });
  });
});