{"size": 1229, "ext": "js", "max_stars_repo_path": "src/analyze-commits-spec.js", "max_stars_repo_name": "bahmutov/simple-commit-message", "max_stars_repo_stars_event_min_datetime": "2015-12-09T07:32:18.000Z", "max_stars_repo_stars_event_max_datetime": "2021-11-20T21:11:07.000Z", "max_issues_repo_path": "src/analyze-commits-spec.js", "max_issues_repo_name": "bahmutov/simple-commit-message", "max_issues_repo_issues_event_min_datetime": "2015-12-09T17:31:33.000Z", "max_issues_repo_issues_event_max_datetime": "2021-07-04T07:59:07.000Z", "max_forks_repo_path": "src/analyze-commits-spec.js", "max_forks_repo_name": "bahmutov/simple-commit-message", "max_forks_repo_forks_event_min_datetime": "2016-03-20T20:00:04.000Z", "max_forks_repo_forks_event_max_datetime": "2021-01-29T08:31:32.000Z"}
{"max_stars_count": 23, "max_issues_count": 82, "max_forks_count": 13, "avg_line_length": 24.0980392157, "max_line_length": 60, "alphanum_fraction": 0.55817738}
'use strict'

const la = require('lazy-ass')

/* eslint-env mocha */
describe('analyze-commits', () => {
  const analyzeCommits = require('./analyze-commits')

  it('returns the type', () => {
    const commit = {
      message: 'feat: something new'
    }
    const type = analyzeCommits(null, { commits: [commit] })
    la(type === 'minor', type)
  })

  it('returns the type for break', () => {
    const commit = {
      message: 'break: something different'
    }
    const type = analyzeCommits(null, { commits: [commit] })
    la(type === 'major', type)
  })

  it('returns the largest release type', () => {
    const commits = [{
      message: 'fix: something'
    }, {
      message: 'feat: a feature'
    }, {
      message: 'feat(foo): finished foo'
    }]
    const type = analyzeCommits(null, { commits })
    la(type === 'minor', 'picked largest type', type)
  })

  it('skips unknown commits', () => {
    const commits = [{
      message: 'no semantic message'
    }, {
      message: 'feat: a feature'
    }, {
      message: 'feat(foo): finished foo'
    }, {
      message: 'another one'
    }]
    const type = analyzeCommits(null, { commits })
    la(type === 'minor', 'picked largest type', type)
  })
})
