{"size": 2081, "ext": "js", "max_stars_repo_path": "src/lib/support/shouldRunSetup.spec.js", "max_stars_repo_name": "gritwyplay/Storm", "max_stars_repo_stars_event_min_datetime": "2019-09-11T07:15:43.000Z", "max_stars_repo_stars_event_max_datetime": "2019-11-08T20:35:43.000Z", "max_issues_repo_path": "src/lib/support/shouldRunSetup.spec.js", "max_issues_repo_name": "gritwyplay/Storm", "max_issues_repo_issues_event_min_datetime": "2020-05-21T03:31:13.000Z", "max_issues_repo_issues_event_max_datetime": "2021-05-10T11:55:52.000Z", "max_forks_repo_path": "src/lib/support/shouldRunSetup.spec.js", "max_forks_repo_name": "gritwyplay/Storm", "max_forks_repo_forks_event_min_datetime": "2021-12-08T12:40:01.000Z", "max_forks_repo_forks_event_max_datetime": "2021-12-08T12:40:01.000Z"}
{"max_stars_count": 2, "max_issues_count": 4, "max_forks_count": 1, "avg_line_length": 21.4536082474, "max_line_length": 99, "alphanum_fraction": 0.6487265738}
import test from 'tape'
import shouldRunSetup from './shouldRunSetup'

test('shouldRunSetup - Type', assert => {
  const expected = 'function'
  const actual = typeof shouldRunSetup

  assert.equal(actual, expected, 'shouldRunSetup should be a function')

  assert.end()
})

test('shouldRunSetup - first execution - default', assert => {
  let expected = true
  let actual = shouldRunSetup(null, 0)

  assert.equal(
    actual,
    expected,
    'shouldRunSetup should return `true` on first execution (index = 0)'
  )

  assert.end()
})

test('shouldRunSetup - first execution - repeat object', assert => {
  let expected = true
  let actual = shouldRunSetup(
    {
      setup: true,
    },
    0
  )

  assert.equal(
    actual,
    expected,
    'shouldRunSetup should return `true` on first execution (index = 0)'
  )

  assert.end()
})

test('shouldRunSetup - next executions - default', assert => {
  let results = []

  for (let i = 1; i < 5; i++) {
    results.push(shouldRunSetup(null, i))
  }

  let actual = results.filter(item => item === false).length
  let expected = 4
  assert.equal(
    actual,
    expected,
    'shouldRunSetup should return false by default for next executions'
  )

  assert.end()
})

test('shouldRunSetup - next executions - repeat object false', assert => {
  let results = []

  for (let i = 1; i < 5; i++) {
    results.push(shouldRunSetup({ setup: false }, i))
  }

  let actual = results.filter(item => item === false).length
  let expected = 4
  assert.equal(
    actual,
    expected,
    'shouldRunSetup should return false by when setup is false in repeat object for next execution'
  )

  assert.end()
})

test('shouldRunSetup - next executions - repeat object true', assert => {
  let results = []

  for (let i = 1; i < 5; i++) {
    results.push(shouldRunSetup({ setup: true }, i))
  }

  let actual = results.filter(item => item === true).length
  let expected = 4
  assert.equal(
    actual,
    expected,
    'shouldRunSetup should return true by when setup is true in repeat object for next execution'
  )

  assert.end()
})
