-
Notifications
You must be signed in to change notification settings - Fork 66.8k
Expand file tree
/
Copy pathversions.js
More file actions
39 lines (33 loc) · 1.49 KB
/
versions.js
File metadata and controls
39 lines (33 loc) · 1.49 KB
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
import { jest } from '@jest/globals'
import revalidator from 'revalidator'
import { allVersions } from '../../lib/all-versions.js'
import { latest } from '../../lib/enterprise-server-releases.js'
import schema from '../helpers/schemas/versions-schema.js'
import nonEnterpriseDefaultVersion from '../../lib/non-enterprise-default-version.js'
jest.useFakeTimers({ legacyFakeTimers: true })
describe('versions module', () => {
test('is an object with versions as keys', () => {
expect(nonEnterpriseDefaultVersion in allVersions).toBe(true)
expect(`enterprise-server@${latest}` in allVersions).toBe(true)
})
test('every version is valid', () => {
Object.values(allVersions).forEach((versionObj) => {
const { valid, errors } = revalidator.validate(versionObj, schema)
const expectation = JSON.stringify({ versionObj, errors }, null, 2)
expect(valid, expectation).toBe(true)
})
})
test('check REST api calendar date versioned versions set to correct latestApiVersion', () => {
Object.values(allVersions).forEach((versionObj) => {
if (versionObj.apiVersions.length > 0) {
const latestApiVersion = versionObj.latestApiVersion
const apiVersions = versionObj.apiVersions
expect(apiVersions).toContain(latestApiVersion)
const latestApiDate = new Date(latestApiVersion).getTime()
for (const version of apiVersions) {
expect(latestApiDate).toBeGreaterThanOrEqual(new Date(version).getTime())
}
}
})
})
})