-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsame-routes.test.js
49 lines (45 loc) · 1.04 KB
/
same-routes.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
'use strict'
const assert = require('node:assert/strict')
const { test } = require('node:test')
const compareOpenApiSchemas = require('../dist/index.js')
test('compare two equal schemas', () => {
const source = {
openapi: '1.0.0',
paths: {
'/foo': {
get: {
requestBody: {
content: {
'application/json': {
schema: {
type: 'object',
properties: {
bar: {
type: 'integer'
}
}
}
}
}
}
}
}
}
}
const target = JSON.parse(JSON.stringify(source))
const diff = compareOpenApiSchemas(source, target)
assert.deepStrictEqual(diff, {
isEqual: true,
sameRoutes: [
{
method: 'get',
path: '/foo',
sourceSchema: source.paths['/foo'].get,
targetSchema: target.paths['/foo'].get
}
],
addedRoutes: [],
deletedRoutes: [],
changedRoutes: []
})
})