Skip to content

Commit b67b140

Browse files
committed
test: cover Validator consumer typings
1 parent 390cf16 commit b67b140

2 files changed

Lines changed: 20 additions & 21 deletions

File tree

scripts/test-types.js

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const { spawnSync } = require("child_process");
66
const repoRoot = path.resolve(__dirname, "..");
77
const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), "ejvm-types-"));
88
const tarballDir = path.join(tempDir, "tarballs");
9-
const sourcePath = path.join(tempDir, "validation-error.ts");
9+
const sourcePath = path.join(tempDir, "consumer.ts");
1010

1111
function run(command, args, options = {}) {
1212
const result = spawnSync(command, args, {
@@ -28,7 +28,25 @@ try {
2828
fs.writeFileSync(
2929
sourcePath,
3030
[
31-
'import { ValidationError } from "express-json-validator-middleware";',
31+
'import { ValidationError, Validator } from "express-json-validator-middleware";',
32+
"",
33+
"const defaultValidator = new Validator();",
34+
"",
35+
"defaultValidator.validate({",
36+
"\tbody: {",
37+
'\t\ttype: "object"',
38+
"\t}",
39+
"});",
40+
"",
41+
"const configuredValidator = new Validator({",
42+
"\tallErrors: true",
43+
"});",
44+
"",
45+
"configuredValidator.validate({",
46+
"\tbody: {",
47+
'\t\ttype: "object"',
48+
"\t}",
49+
"});",
3250
"",
3351
"const validationError = new ValidationError({",
3452
"\tparams: [",

types/validator.ts

Lines changed: 0 additions & 19 deletions
This file was deleted.

0 commit comments

Comments
 (0)