-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathversions.test.js
57 lines (46 loc) · 1.67 KB
/
versions.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
'use strict'
const assert = require('node:assert/strict')
const { test } = require('node:test')
const compareOpenApiSchemas = require('../dist/index.js')
test('should throw source schema version is missing', () => {
const source = { paths: {} }
const target = { openapi: '1.0.0', paths: {} }
try {
compareOpenApiSchemas(source, target)
assert.fail('should throw')
} catch (err) {
assert.strictEqual(err.message, 'source schema version must be a string')
}
})
test('should throw target schema version is missing', () => {
const source = { openapi: '1.0.0', paths: {} }
const target = { paths: {} }
try {
compareOpenApiSchemas(source, target)
assert.fail('should throw')
} catch (err) {
assert.strictEqual(err.message, 'target schema version must be a string')
}
})
test('should throw if major version does not equal', () => {
const source = { openapi: '2.0.0', paths: {} }
const target = { openapi: '1.0.0', paths: {} }
try {
compareOpenApiSchemas(source, target)
assert.fail('should throw')
} catch (err) {
assert.strictEqual(err.message, 'source and target schemas must have the same major version')
}
})
test('should not throw if minor version does not equal', () => {
const source = { openapi: '1.1.0', paths: {} }
const target = { openapi: '1.0.0', paths: {} }
const { isEqual } = compareOpenApiSchemas(source, target)
assert.strictEqual(isEqual, true)
})
test('should not throw if path version does not equal', () => {
const source = { openapi: '1.1.1', paths: {} }
const target = { openapi: '1.1.0', paths: {} }
const { isEqual } = compareOpenApiSchemas(source, target)
assert.strictEqual(isEqual, true)
})