Skip to content

Commit 3d32efb

Browse files
authored
Merge pull request #218 from netlify/test/improve-normalization-test
Improve tests
2 parents fed7e16 + cbad8ae commit 3d32efb

File tree

5 files changed

+32
-12202
lines changed

5 files changed

+32
-12202
lines changed

package-lock.json

Lines changed: 9 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
"eslint-plugin-prettier": "^3.1.0",
2828
"execa": "^2.0.4",
2929
"gh-release": "^3.5.0",
30+
"is-plain-obj": "^2.1.0",
3031
"make-dir": "^3.0.0",
3132
"npm-run-all": "^4.1.5",
3233
"prettier": "^1.18.2",

src/convert.test.js

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,28 @@
11
const test = require('ava')
2+
const isPlainObj = require('is-plain-obj')
3+
4+
const { version } = require('../package.json')
25

36
// eslint-disable-next-line node/no-missing-require
47
const openApiDef = require('..')
58

6-
test('OpenAPI definition snapshot', async t => {
7-
t.snapshot(openApiDef)
9+
test('OpenAPI definition normalization', async t => {
10+
// Ensure the OpenAPI definition general shape looks normal
11+
t.true(isPlainObj(openApiDef))
12+
t.true(isPlainObj(openApiDef.definitions))
13+
t.true(isPlainObj(openApiDef.paths))
14+
15+
// Ensure the endpoints are present by checking for one of them
16+
t.true(isPlainObj(openApiDef.paths['/accounts']))
17+
t.true(isPlainObj(openApiDef.paths['/accounts'].get))
18+
t.is(openApiDef.paths['/accounts'].get.operationId, 'listAccountsForUser')
19+
20+
// Ensure the host URL is present
21+
t.is(typeof openApiDef.host, 'string')
22+
23+
// Ensure the API version is correct
24+
t.is(openApiDef.info.version, version)
25+
26+
// Ensure JSON references are normalized
27+
t.true(isPlainObj(openApiDef.paths['/accounts'].get.responses.default.schema))
828
})

0 commit comments

Comments
 (0)