forked from graphql/graphql-js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
version-test.js
40 lines (32 loc) · 1.02 KB
/
version-test.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
// @flow strict
import { expect } from 'chai';
import { describe, it } from 'mocha';
import { version, versionInfo } from '../version';
describe('Version', () => {
it('version', () => {
expect(version).to.be.a('string');
expect(version).to.match(/^\d+\.\d+\.\d(-(alpha|beta|rc)\.\d+)?$/);
});
it('versionInfo', () => {
expect(versionInfo).to.be.an('object');
expect(versionInfo).to.have.all.keys(
'major',
'minor',
'patch',
'preReleaseTag',
);
const { major, minor, patch, preReleaseTag } = versionInfo;
expect(major).to.be.a('number');
expect(minor).to.be.a('number');
expect(patch).to.be.a('number');
/* istanbul ignore next (Can't be verified on all versions) */
if (preReleaseTag !== null) {
expect(preReleaseTag).to.be.a('string');
}
expect(
`${major}.${minor}.${patch}` +
/* istanbul ignore next (Can't be verified on all versions) */
(preReleaseTag !== null ? '-' + preReleaseTag : ''),
).to.equal(version);
});
});