aboutsummaryrefslogtreecommitdiffstats
path: root/test/unit/development/version–bump-test.js
blob: 1c445c8b454fbabaeba888d9e66db723abe9b1c6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
const assert = require('assert')
const versionBump = require('../../../development/version-bump')
const { promisify } = require('util')
const fs = require('fs')
const readFile = promisify(fs.readFile)
const path = require('path')
const changelogPath = path.join(__dirname, 'sample-changelog.md')
const manifest = require('./sample-manifest.json')
let changelog


describe('version bumper', function () {

  beforeEach(async () => {
    // load changelog. Mock version is 4.1.3
    const changeBuffer = await readFile(changelogPath)
    changelog = changeBuffer.toString()
  })

  it('returns a properly bumped major version', async function () {
    const result = await versionBump('major', changelog, manifest)
    const expected = '5.0.0'
    assert.equal(result.version, expected, 'major bumps correctly')
    assert.equal(result.manifest.version, expected, 'major bumps correctly')
    assert.ok(result.changelog.includes(expected))
  })

  it('returns a properly bumped minor version', async function () {
    const result = await versionBump('minor', changelog, manifest)
    const expected = '4.2.0'
    assert.equal(result.version, expected, 'minor bumps correctly')
    assert.equal(result.manifest.version, expected, 'minor bumps correctly')
    assert.ok(result.changelog.includes(expected))
  })

  it('returns a properly bumped patch version', async function () {
    const result = await versionBump('patch', changelog, manifest)
    const expected = '4.1.4'
    assert.equal(result.version, expected, 'patch bumps correctly')
    assert.equal(result.manifest.version, expected, 'patch bumps correctly')
    assert.ok(result.changelog.includes(expected))
  })
})