-
Notifications
You must be signed in to change notification settings - Fork 94
/
Copy pathconvert.test.js
27 lines (21 loc) · 976 Bytes
/
convert.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
const test = require('ava')
const isPlainObj = require('is-plain-obj')
const { version } = require('../package.json')
// eslint-disable-next-line n/no-missing-require
const openApiDef = require('..')
test('OpenAPI definition normalization', async (t) => {
// Ensure the OpenAPI definition general shape looks normal
t.true(isPlainObj(openApiDef))
t.true(isPlainObj(openApiDef.definitions))
t.true(isPlainObj(openApiDef.paths))
// Ensure the endpoints are present by checking for one of them
t.true(isPlainObj(openApiDef.paths['/accounts']))
t.true(isPlainObj(openApiDef.paths['/accounts'].get))
t.is(openApiDef.paths['/accounts'].get.operationId, 'listAccountsForUser')
// Ensure the host URL is present
t.is(typeof openApiDef.host, 'string')
// Ensure the API version is correct
t.is(openApiDef.info.version, version)
// Ensure JSON references are normalized
t.true(isPlainObj(openApiDef.paths['/accounts'].get.responses.default.schema))
})