{"size": 1741, "ext": "js", "max_stars_repo_path": "static/js/components/dashboard/FinalExamCard_test.js", "max_stars_repo_name": "Wassaf-Shahzad/micromasters", "max_stars_repo_stars_event_min_datetime": "2016-03-25T01:03:13.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-15T19:35:42.000Z", "max_issues_repo_path": "static/js/components/dashboard/FinalExamCard_test.js", "max_issues_repo_name": "Wassaf-Shahzad/micromasters", "max_issues_repo_issues_event_min_datetime": "2016-03-03T13:48:30.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-29T22:09:51.000Z", "max_forks_repo_path": "static/js/components/dashboard/FinalExamCard_test.js", "max_forks_repo_name": "umarmughal824/micromasters", "max_forks_repo_forks_event_min_datetime": "2016-08-18T22:07:44.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-15T13:35:35.000Z"}
{"max_stars_count": 32, "max_issues_count": 4858, "max_forks_count": 20, "avg_line_length": 31.6545454545, "max_line_length": 105, "alphanum_fraction": 0.6714531878}
// @flow
/* global SETTINGS: false */
import _ from "lodash"
import React from "react"
import { mount } from "enzyme"
import { assert } from "chai"
import { MuiThemeProvider, createMuiTheme } from "@material-ui/core/styles"

import FinalExamCard from "./FinalExamCard"
import { DASHBOARD_RESPONSE, USER_PROFILE_RESPONSE } from "../../test_constants"
import { PEARSON_PROFILE_ABSENT } from "../../constants"
import { INITIAL_UI_STATE } from "../../reducers/ui"
import { stringStrip } from "../../util/test_utils"
import type { Program } from "../../flow/programTypes"

describe("FinalExamCard", () => {
  let props

  const profile = { ...USER_PROFILE_RESPONSE, preferred_name: "Preferred Name" }

  beforeEach(() => {
    const program: Program = (_.cloneDeep(
      DASHBOARD_RESPONSE.programs.find(
        program => program.exam_card_status !== undefined
      )
    ): any)
    props = {
      profile: profile,
      program: program,
      ui:      { ...INITIAL_UI_STATE }
    }
  })

  const commonText = `To earn a certificate, you must take an online proctored exam for each 
  course. Before you can take a proctored exam, you have to pay for the course and pass the online work.`

  const renderCard = props =>
    mount(
      <MuiThemeProvider theme={createMuiTheme()}>
        <FinalExamCard {...props} />
      </MuiThemeProvider>
    )

  it("should not render when exam_card_status is empty", () => {
    const card = renderCard(props)
    assert.equal(card.html(), "")
  })

  it("should just show a basic message if the profile is absent", () => {
    props.program.exam_card_status = PEARSON_PROFILE_ABSENT
    const card = renderCard(props)
    assert.include(stringStrip(card.text()), stringStrip(commonText))
  })
})
