-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
validate_node_engine_version_spec.ts
71 lines (58 loc) · 2.25 KB
/
validate_node_engine_version_spec.ts
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
import { expect } from 'chai'
import * as sinon from 'sinon'
import { validateNodeEngineVersion } from './validate_node_engine_version'
describe(validateNodeEngineVersion.name, () => {
const readPackageJSON = () => ({
engines: {
node: '12 || 14 || >=16',
},
enginesTested: {
node: '12 || 14 || 16 || 17',
},
})
it('calls the onError callback when the version is lower than any of our supported versions', () => {
// Arrange
const errorSpy = sinon.spy()
const warningSpy = sinon.spy()
// Act
validateNodeEngineVersion('v11.1.2', errorSpy, warningSpy, readPackageJSON)
// Assert
expect(errorSpy).to.have.been.calledOnceWith(
'Cucumber can only run on Node.js versions 12 || 14 || >=16. This Node.js version is v11.1.2'
)
expect(warningSpy).not.to.have.been.called()
})
it('calls the onError callback when the version is between our supported versions', () => {
// Arrange
const errorSpy = sinon.spy()
const warningSpy = sinon.spy()
validateNodeEngineVersion('v13.1.2', errorSpy, warningSpy, readPackageJSON)
// Assert
expect(errorSpy).to.have.been.calledOnceWith(
'Cucumber can only run on Node.js versions 12 || 14 || >=16. This Node.js version is v13.1.2'
)
expect(warningSpy).not.to.have.been.called()
})
it('does not call onError or onWarning when the version is one of our supported versions', () => {
// Arrange
const errorSpy = sinon.spy()
const warningSpy = sinon.spy()
// Act
validateNodeEngineVersion('v17.1.2', errorSpy, warningSpy, readPackageJSON)
// Assert
expect(errorSpy).not.to.have.been.called()
expect(warningSpy).not.to.have.been.called()
})
it('does not call onError when the version is a version that isnt out yet at time of release', () => {
// Arrange
const errorSpy = sinon.spy()
const warningSpy = sinon.spy()
// Act
validateNodeEngineVersion('v18.0.0', errorSpy, warningSpy, readPackageJSON)
// Assert
expect(errorSpy).not.to.have.been.called()
expect(warningSpy).to.have.been.calledOnceWith(
`This Node.js version (v18.0.0) has not been tested with this version of Cucumber; it should work normally, but please raise an issue if you see anything unexpected.`
)
})
})