forked from electron/electron
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathversion-bump-spec.js
86 lines (73 loc) · 2.58 KB
/
version-bump-spec.js
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
const { expect } = require('chai')
const { nextVersion } = require('../script/bump-version')
describe('bump-version script', () => {
const nightlyPattern = /[0-9.]*(-nightly.(\d{4})(\d{2})(\d{2}))$/g
const betaPattern = /[0-9.]*(-beta[0-9.]*)/g
before(function () {
if (process.platform === 'linux' && process.arch === 'arm') {
this.skip()
}
})
it('bumps to nightly from stable', async () => {
const version = 'v2.0.0'
const next = await nextVersion('nightly', version)
const matches = next.match(nightlyPattern)
expect(matches).to.have.lengthOf(1)
})
it('bumps to nightly from beta', async () => {
const version = 'v2.0.0-beta.1'
const next = await nextVersion('nightly', version)
const matches = next.match(nightlyPattern)
expect(matches).to.have.lengthOf(1)
})
it('bumps to nightly from nightly', async () => {
const version = 'v2.0.0-nightly.19950901'
const next = await nextVersion('nightly', version)
const matches = next.match(nightlyPattern)
expect(matches).to.have.lengthOf(1)
})
it('throws error when bumping to beta from stable', () => {
const version = 'v2.0.0'
return expect(
nextVersion('beta', version)
).to.be.rejectedWith('Cannot bump to beta from stable.')
})
it('bumps to beta from nightly', async () => {
const version = 'v2.0.0-nightly.19950901'
const next = await nextVersion('beta', version)
const matches = next.match(betaPattern)
expect(matches).to.have.lengthOf(1)
})
it('bumps to beta from beta', async () => {
const version = 'v2.0.0-beta.8'
const next = await nextVersion('beta', version)
expect(next).to.equal('2.0.0-beta.9')
})
it('bumps to stable from beta', async () => {
const version = 'v2.0.0-beta.1'
const next = await nextVersion('stable', version)
expect(next).to.equal('2.0.0')
})
it('bumps to stable from stable', async () => {
const version = 'v2.0.0'
const next = await nextVersion('stable', version)
expect(next).to.equal('2.0.1')
})
it('bumps to stable from nightly', async () => {
const version = 'v2.0.0-nightly.19950901'
const next = await nextVersion('stable', version)
expect(next).to.equal('2.0.0')
})
it('throws on an invalid version', () => {
const version = 'vI.AM.INVALID'
return expect(
nextVersion('beta', version)
).to.be.rejectedWith(`Invalid current version: ${version}`)
})
it('throws on an invalid bump type', () => {
const version = 'v2.0.0'
return expect(
nextVersion('WRONG', version)
).to.be.rejectedWith('Invalid bump type.')
})
})