Repository: date-fns/date-fns
File: src/differenceInMonths/test.js (JavaScript)

Code before:
    const start = new Date('Feb 29 2012 09:00:00')
    const end = new Date('Feb 28 2012 10:00:00')
    var result = differenceInMonths(start, end)
    assert(result === 0)
  })

  it('returns the number of full months between the given dates - end of Feb', function () {
    const start = new Date('Feb 28 2012 09:00:00')
    const end = new Date('Feb 29 2012 10:00:00')
    var result = differenceInMonths(start, end)
    assert(result === 0)
  })

  it('returns the number of full months between the given dates - end of Feb', function () {
    const start = new Date('Feb 27 2012 09:00:00')
    const end = new Date('Feb 27 2012 10:00:00')
    var result = differenceInMonths(start, end)
    assert(result === 0)
  })

  it('returns the number of full months between the given dates - end of Feb', function () {
    const start = new Date('Feb 29 2012 09:00:00')
    const end = new Date('Feb 29 2012 10:00:00')
    var result = differenceInMonths(start, end)
    assert(result === 0)
  })

  it('returns the number of full months between the given dates', function () {
    const start = new Date('Feb 28 2012 09:00:00')
    const end = new Date('Feb 28 2012 10:00:00')
    var result = differenceInMonths(start, end)
    assert(result === 0)
  })

  it('returns the number of full months between the given dates', function () {
    var result = differenceInMonths(
      new Date(2012, 6 /* Jul */, 2, 18, 0),
      new Date(2011, 6 /* Jul */, 2, 6, 0)
    )
    assert(result === 12)
  })

  it('returns a negative number if the time value of the first date is smaller', function () {
    var result = differenceInMonths(
      new Date(2011, 6 /* Jul */, 2, 6, 0),
      new Date(2012, 6 /* Jul */, 2, 18, 0)
    )
    assert(result === -12)
  })

  it('accepts timestamps', function () {

Review comment (bug):
Please do the following:

1. Join these tests into a single one, as all of them have the same description
2. Move edge case tests to the end of the file, you might even wrap them into `describe('edge cases', ...` or `describe('regression tests', ...`

Code after:
    var result = differenceInMonths(
      new Date(2012, 6 /* Jul */, 2, 18, 0),
      new Date(2011, 6 /* Jul */, 2, 6, 0)
    )
    assert(result === 12)
  })

  it('returns a negative number if the time value of the first date is smaller', function () {
    var result = differenceInMonths(
      new Date(2011, 6 /* Jul */, 2, 6, 0),
      new Date(2012, 6 /* Jul */, 2, 18, 0)
    )
    assert(result === -12)
  })

  it('accepts timestamps', function () {
    var result = differenceInMonths(
      new Date(2014, 7 /* Aug */, 2).getTime(),
      new Date(2010, 6 /* Jul */, 2).getTime()
    )
    assert(result === 49)
  })

  describe('edge cases', function () {
    it('it returns diff of 1 month between Feb 28 2021 and Jan 30 2021', function () {
      var result = differenceInMonths(
        new Date(2021, 1 /* Feb */, 28),
        new Date(2021, 0 /* Jan */, 30)
      )
      assert(result === 1)
    })

    it('it returns diff of 1 month between Feb 28 2021 and Jan 31 2021', function () {
      var result = differenceInMonths(
        new Date(2021, 1 /* Feb */, 28),
        new Date(2021, 0 /* Jan */, 31)
      )
      assert(result === 1)
    })

    it('it returns diff of 1 month between Nov, 30 2021 and Oct, 31 2021', function () {
      var result = differenceInMonths(
        new Date(2021, 10 /* Nov */, 30),
        new Date(2021, 9 /* Oct */, 31)
      )
      assert(result === 1)
    })

    it('it returns diff of 1 month between Oct, 31 2021 and Sep, 30 2021', function () {
      var result = differenceInMonths(
        new Date(2021, 9 /* Oct */, 31),