Skip to content

Commit ee23860

Browse files
committed
Add unit tests to get back to 100% coverage
1 parent 1916ac7 commit ee23860

File tree

4 files changed

+26
-3
lines changed

4 files changed

+26
-3
lines changed

code/get-hex/openapi.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ module.exports = {
2424
responses: {
2525
"200": {
2626
description: "JSON object with hex property",
27-
schema: bodySchema.openapi()
27+
schema: bodySchema.openAPI()
2828
}
2929
}
3030
}

code/post-up/openapi.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ module.exports = {
2121
responses: {
2222
"200": {
2323
description: "JSON object with uppercase property names",
24-
schema: bodySchema.openapi()
24+
schema: bodySchema.openAPI()
2525
}
2626
}
2727
}

code/schemas-tap.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
"use strict";
2+
const schemas = require("./schemas");
3+
const tap = require("tap");
4+
5+
tap.test("schemas.define supports example data", test => {
6+
const ssn = schemas.define({
7+
type: "string",
8+
pattern: /^\d{3}-\d{2}-\d{4}$/.source,
9+
example: "111-22-3333"
10+
});
11+
test.same(ssn.openAPI().example, "111-22-3333");
12+
test.end();
13+
});
14+
15+
tap.test("schemas.define supports example function", test => {
16+
const ssn = schemas.define({
17+
type: "string",
18+
pattern: /^\d{3}-\d{2}-\d{4}$/.source,
19+
example: () => "111-22-3333"
20+
});
21+
test.same(ssn.openAPI().example, "111-22-3333");
22+
test.end();
23+
});

code/schemas.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ function define(jsonSchema) {
2222
}
2323
return null;
2424
},
25-
openapi() {
25+
openAPI() {
2626
const api = Object.assign({}, jsonSchema);
2727
if (typeof jsonSchema.example === "function") {
2828
api.example = jsonSchema.example();

0 commit comments

Comments
 (0)