{"size": 857, "ext": "js", "max_stars_repo_path": "src/components/checkout/checkout-parts/payment-section/affirm/affirm.test.js", "max_stars_repo_name": "RichardBronosky/aws-api-tools", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/components/checkout/checkout-parts/payment-section/affirm/affirm.test.js", "max_issues_repo_name": "RichardBronosky/aws-api-tools", "max_issues_repo_issues_event_min_datetime": "2021-05-10T16:47:05.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-27T10:25:05.000Z", "max_forks_repo_path": "src/components/checkout/checkout-parts/payment-section/affirm/affirm.test.js", "max_forks_repo_name": "RichardBronosky/aws-api-tools", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": 8, "max_forks_count": null, "avg_line_length": 25.9696969697, "max_line_length": 97, "alphanum_fraction": 0.6149358226}
import React from 'react'
import renderer from 'react-test-renderer'
import Affirm from './affirm-button'

describe('Affirm', () => {
  const testProps = {
    affirmLoaded: false,
    affirmFunc: jest.fn(),
    affirm_config: {
      public_api_key: 'test-key',
      script: `test-url/js/v2/affirm.js`,
    },
  }

  beforeAll(() => {
    global.window = Object.create(window)
    Object.defineProperty(window, 'affirm', {
      checkout: jest.fn(),
      open: jest.fn(),
    })
  })

  it('renders correctly when affirm is not loaded', () => {
    const tree = renderer.create(<Affirm { ...testProps } />).toJSON()
    expect(tree).toMatchSnapshot()
  })

  it('renders correctly when affirm is loaded', () => {
    const tree = renderer.create(<Affirm { ...{ ...testProps, affirmLoaded: true } } />).toJSON()
    expect(tree).toMatchSnapshot()
  })
})
