{"size": 3257, "ext": "js", "max_stars_repo_path": "src/utils/json-transform.test.js", "max_stars_repo_name": "18F/dspan-registration", "max_stars_repo_stars_event_min_datetime": "2019-04-03T20:24:28.000Z", "max_stars_repo_stars_event_max_datetime": "2020-06-29T05:56:41.000Z", "max_issues_repo_path": "src/utils/json-transform.test.js", "max_issues_repo_name": "18F/dspan-registration", "max_issues_repo_issues_event_min_datetime": "2018-12-12T19:32:36.000Z", "max_issues_repo_issues_event_max_datetime": "2020-01-10T18:57:44.000Z", "max_forks_repo_path": "src/utils/json-transform.test.js", "max_forks_repo_name": "18F/dspan-registration", "max_forks_repo_forks_event_min_datetime": "2021-02-14T09:41:43.000Z", "max_forks_repo_forks_event_max_datetime": "2021-02-14T09:41:43.000Z"}
{"max_stars_count": 3, "max_issues_count": 8, "max_forks_count": 1, "avg_line_length": 26.6967213115, "max_line_length": 83, "alphanum_fraction": 0.5882714154}
import {toRegistrationServiceFormat, toRulesServiceFormat} from './json-transform';
import testData from '../test-data';

test('Transform test data to registration service format', () => {
  expect(toRegistrationServiceFormat(testData)).toEqual({
    ebt_card_number: "1234567891234567",
    disaster_id: 11,
    preferred_language: "en",
    phone: "2165555555",
    email: "adam@email.biz",
    residential_address: {
      street1: "250 Oakland Way",
      street2: "",
      city: "Oakland",
      state: "FL",
      zipcode: "94612"
    },
    mailing_address: {
      street1: "365 Campus Rd",
      street2: "",
      city: "Cleveland",
      state: "OH",
      zipcode: "44121"
    },
    county: "Baker",
    state_id: "Y9456A7",
    money_on_hand: 1000,
    has_inaccessible_liquid_resources: false,
    has_lost_or_inaccessible_income: true,
    purchased_or_plans_to_purchase_food: true,
    disaster_expenses: {
      food_loss: 129,
      home_or_business_repairs: 0,
      temporary_shelter_expenses: 550,
      evacuation_expenses: 0,
      other: 1000
    },
    household: [
      {
        first_name: "Adam",
        middle_name: "",
        last_name: "B",
        dob: "1989-01-01",
        sex: "male",
        ssn: "111111111",
        race: "",
        ethnicity: "Not Hispanic or Latino",
        has_food_assistance: false,
        income: {
          self_employed: 0,
          unemployment: 200,
          cash_assistance: 0,
          disability: 0,
          social_security: 0,
          veterans_benefits: 0,
          alimony: 0,
          child_support: 0,
          other_sources: 0,
        },
        jobs: [{
          employer_name: "TTS",
          pay: 1000,
          is_dsnap_agency: false
        },
        {
          employer_name: "Apollo",
          pay: 500,
          is_dsnap_agency: false
        }],
      },
      {
        first_name: "Bob",
        middle_name: "",
        last_name: "Ross",
        dob: "1949-01-01",
        sex: "male",
        ssn: "111111112",
        race: "",
        ethnicity: "",
        has_food_assistance: false,
        income: {
          self_employed: 10000,
          unemployment: 0,
          cash_assistance: 0,
          disability: 0,
          social_security: 0,
          veterans_benefits: 0,
          alimony: 0,
          child_support: 0,
          other_sources: 0,
        },
        jobs: []
      },
    ]
  });
});

test('Transform registration to rules service format', () => {
  expect(toRulesServiceFormat(toRegistrationServiceFormat(testData))).toEqual({
    accessible_liquid_resources: 1000,
    disaster_expenses: {
      evacuation_expenses: 0,
      food_loss: 129,
      home_or_business_repairs: 0,
      other: 1000,
      temporary_shelter_expenses: 550,
    },
    disaster_id: 11,
    has_inaccessible_liquid_resources: false,
    has_lost_or_inaccessible_income: true,
    is_authorized_representative: false,
    is_head_of_household: true,
    purchased_or_plans_to_purchase_food: true,
    receives_SNAP_benefits: false,
    resided_in_disaster_area_at_disaster_time: true,
    residence_state: "FL",
    size_of_household: 2,
    total_take_home_income: 11700,
    worked_in_disaster_area_at_disaster_time: false,
  });
});
