test: add specs to version bump utils (#16315)

This commit is contained in:
Shelley Vohr 2019-01-08 12:04:27 -08:00 committed by GitHub
parent 668049a593
commit 434f1368a0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 42 additions and 9 deletions

View file

@ -1,5 +1,43 @@
const { expect } = require('chai')
const { nextVersion } = require('../script/bump-version')
const utils = require('../script/lib/version-utils')
describe('bump-version utils', () => {
it('makes a version with a period delimeter', () => {
const components = {
major: 2,
minor: 0,
patch: 0
}
const version = utils.makeVersion(components, '.')
expect(version).to.equal('2.0.0')
})
it('makes a version with a period delimeter and a partial pre', () => {
const components = {
major: 2,
minor: 0,
patch: 0,
pre: [ 'nightly', 12345678 ]
}
const version = utils.makeVersion(components, '.', utils.preType.PARTIAL)
expect(version).to.equal('2.0.0.12345678')
})
it('makes a version with a period delimeter and a full pre', () => {
const components = {
major: 2,
minor: 0,
patch: 0,
pre: [ 'nightly', 12345678 ]
}
const version = utils.makeVersion(components, '.', utils.preType.FULL)
expect(version).to.equal('2.0.0-nightly.12345678')
})
})
describe('bump-version script', () => {
const nightlyPattern = /[0-9.]*(-nightly.(\d{4})(\d{2})(\d{2}))$/g