- verifies stdin when no arguments given
- /home/kevin/src/node-projects/swagger-spec-validator/test/cli.js
swaggerSpecValidatorMock.expects('validateFile').never();
swaggerSpecValidatorMock.expects('validate').once()
.withArgs(
options.stdin,
match.object,
match.func,
);
swaggerSpecValidatorCmd(RUNTIME_ARGS, options);
swaggerSpecValidatorMock.verify();
- verifies stdin with "-" argument
- /home/kevin/src/node-projects/swagger-spec-validator/test/cli.js
swaggerSpecValidatorMock.expects('validateFile').never();
swaggerSpecValidatorMock.expects('validate').once()
.withArgs(
options.stdin,
match.object,
match.func,
);
const allArgs = [...RUNTIME_ARGS, '-'];
swaggerSpecValidatorCmd(allArgs, options);
swaggerSpecValidatorMock.verify();
- verifies file named "-" with "./-" argument
- /home/kevin/src/node-projects/swagger-spec-validator/test/cli.js
swaggerSpecValidatorMock.expects('validate').never();
swaggerSpecValidatorMock.expects('validateFile').once()
.withArgs(
'./-',
match.object,
match.func,
);
const allArgs = [...RUNTIME_ARGS, './-'];
swaggerSpecValidatorCmd(allArgs, options);
swaggerSpecValidatorMock.verify();
- verifies multiple named files
- /home/kevin/src/node-projects/swagger-spec-validator/test/cli.js
swaggerSpecValidatorMock.expects('validate').never();
swaggerSpecValidatorMock.expects('validateFile').once()
.withArgs(
'file1',
match.object,
match.func,
);
swaggerSpecValidatorMock.expects('validateFile').once()
.withArgs(
'file2',
match.object,
match.func,
);
const allArgs = [...RUNTIME_ARGS, 'file1', 'file2'];
swaggerSpecValidatorCmd(allArgs, options);
swaggerSpecValidatorMock.verify();
- verifies multiply named files once
- /home/kevin/src/node-projects/swagger-spec-validator/test/cli.js
swaggerSpecValidatorMock.expects('validate').never();
swaggerSpecValidatorMock.expects('validateFile').once()
.withArgs(
'file1',
match.object,
match.func,
);
const allArgs = [...RUNTIME_ARGS, 'file1', 'file1'];
swaggerSpecValidatorCmd(allArgs, options);
swaggerSpecValidatorMock.verify();
- does not normalize paths when merging duplicates
- /home/kevin/src/node-projects/swagger-spec-validator/test/cli.js
swaggerSpecValidatorMock.expects('validate').never();
swaggerSpecValidatorMock.expects('validateFile').once()
.withArgs(
'file1',
match.object,
match.func,
);
swaggerSpecValidatorMock.expects('validateFile').once()
.withArgs(
'./file1',
match.object,
match.func,
);
const allArgs = [...RUNTIME_ARGS, 'file1', './file1'];
swaggerSpecValidatorCmd(allArgs, options);
swaggerSpecValidatorMock.verify();
- verifies mix of files and stdin
- /home/kevin/src/node-projects/swagger-spec-validator/test/cli.js
swaggerSpecValidatorMock.expects('validateFile').once()
.withArgs(
'file1',
match.object,
match.func,
);
swaggerSpecValidatorMock.expects('validateFile').once()
.withArgs(
'file2',
match.object,
match.func,
);
swaggerSpecValidatorMock.expects('validate').once()
.withArgs(
options.stdin,
match.object,
match.func,
);
const allArgs = [...RUNTIME_ARGS, 'file1', '-', 'file2'];
swaggerSpecValidatorCmd(allArgs, options);
swaggerSpecValidatorMock.verify();
- interprets --header Content-Type:text/plain as match(request: match(headers: [object Object]))
- /home/kevin/src/node-projects/swagger-spec-validator/test/cli.js
swaggerSpecValidatorMock.expects('validateFile').never();
swaggerSpecValidatorMock.expects('validate').once()
.withArgs(
options.stdin,
expectObj,
match.func,
);
const allArgs = [...RUNTIME_ARGS, ...args];
swaggerSpecValidatorCmd(allArgs, options);
swaggerSpecValidatorMock.verify();
- interprets --header content-type: text/plain as match(request: match(headers: [object Object]))
- /home/kevin/src/node-projects/swagger-spec-validator/test/cli.js
swaggerSpecValidatorMock.expects('validateFile').never();
swaggerSpecValidatorMock.expects('validate').once()
.withArgs(
options.stdin,
expectObj,
match.func,
);
const allArgs = [...RUNTIME_ARGS, ...args];
swaggerSpecValidatorCmd(allArgs, options);
swaggerSpecValidatorMock.verify();
- interprets --quiet as match(verbosity: -1)
- /home/kevin/src/node-projects/swagger-spec-validator/test/cli.js
swaggerSpecValidatorMock.expects('validateFile').never();
swaggerSpecValidatorMock.expects('validate').once()
.withArgs(
options.stdin,
expectObj,
match.func,
);
const allArgs = [...RUNTIME_ARGS, ...args];
swaggerSpecValidatorCmd(allArgs, options);
swaggerSpecValidatorMock.verify();
- interprets --url http://example.com as match(url: http://example.com)
- /home/kevin/src/node-projects/swagger-spec-validator/test/cli.js
swaggerSpecValidatorMock.expects('validateFile').never();
swaggerSpecValidatorMock.expects('validate').once()
.withArgs(
options.stdin,
expectObj,
match.func,
);
const allArgs = [...RUNTIME_ARGS, ...args];
swaggerSpecValidatorCmd(allArgs, options);
swaggerSpecValidatorMock.verify();
- interprets --verbose as match(verbosity: 1)
- /home/kevin/src/node-projects/swagger-spec-validator/test/cli.js
swaggerSpecValidatorMock.expects('validateFile').never();
swaggerSpecValidatorMock.expects('validate').once()
.withArgs(
options.stdin,
expectObj,
match.func,
);
const allArgs = [...RUNTIME_ARGS, ...args];
swaggerSpecValidatorCmd(allArgs, options);
swaggerSpecValidatorMock.verify();
- interprets -H Content-Type:text/plain as match(request: match(headers: [object Object]))
- /home/kevin/src/node-projects/swagger-spec-validator/test/cli.js
swaggerSpecValidatorMock.expects('validateFile').never();
swaggerSpecValidatorMock.expects('validate').once()
.withArgs(
options.stdin,
expectObj,
match.func,
);
const allArgs = [...RUNTIME_ARGS, ...args];
swaggerSpecValidatorCmd(allArgs, options);
swaggerSpecValidatorMock.verify();
- interprets -u https://example.com/path?query as match(url: https://example.com/path?query)
- /home/kevin/src/node-projects/swagger-spec-validator/test/cli.js
swaggerSpecValidatorMock.expects('validateFile').never();
swaggerSpecValidatorMock.expects('validate').once()
.withArgs(
options.stdin,
expectObj,
match.func,
);
const allArgs = [...RUNTIME_ARGS, ...args];
swaggerSpecValidatorCmd(allArgs, options);
swaggerSpecValidatorMock.verify();
- interprets -q as match(verbosity: -1)
- /home/kevin/src/node-projects/swagger-spec-validator/test/cli.js
swaggerSpecValidatorMock.expects('validateFile').never();
swaggerSpecValidatorMock.expects('validate').once()
.withArgs(
options.stdin,
expectObj,
match.func,
);
const allArgs = [...RUNTIME_ARGS, ...args];
swaggerSpecValidatorCmd(allArgs, options);
swaggerSpecValidatorMock.verify();
- interprets -v as match(verbosity: 1)
- /home/kevin/src/node-projects/swagger-spec-validator/test/cli.js
swaggerSpecValidatorMock.expects('validateFile').never();
swaggerSpecValidatorMock.expects('validate').once()
.withArgs(
options.stdin,
expectObj,
match.func,
);
const allArgs = [...RUNTIME_ARGS, ...args];
swaggerSpecValidatorCmd(allArgs, options);
swaggerSpecValidatorMock.verify();
- interprets -H Content-Type: as match(request: match(headers: [object Object]))
- /home/kevin/src/node-projects/swagger-spec-validator/test/cli.js
swaggerSpecValidatorMock.expects('validateFile').never();
swaggerSpecValidatorMock.expects('validate').once()
.withArgs(
options.stdin,
expectObj,
match.func,
);
const allArgs = [...RUNTIME_ARGS, ...args];
swaggerSpecValidatorCmd(allArgs, options);
swaggerSpecValidatorMock.verify();
- interprets -H Content-Type: text/plain as match(request: match(headers: [object Object]))
- /home/kevin/src/node-projects/swagger-spec-validator/test/cli.js
swaggerSpecValidatorMock.expects('validateFile').never();
swaggerSpecValidatorMock.expects('validate').once()
.withArgs(
options.stdin,
expectObj,
match.func,
);
const allArgs = [...RUNTIME_ARGS, ...args];
swaggerSpecValidatorCmd(allArgs, options);
swaggerSpecValidatorMock.verify();
- interprets -H Content-Type : text/plain as match(request: match(headers: [object Object]))
- /home/kevin/src/node-projects/swagger-spec-validator/test/cli.js
swaggerSpecValidatorMock.expects('validateFile').never();
swaggerSpecValidatorMock.expects('validate').once()
.withArgs(
options.stdin,
expectObj,
match.func,
);
const allArgs = [...RUNTIME_ARGS, ...args];
swaggerSpecValidatorCmd(allArgs, options);
swaggerSpecValidatorMock.verify();
- interprets -H Content-Type:text/plain -H X-Foo : bar as match(request: match(headers: [object Object]))
- /home/kevin/src/node-projects/swagger-spec-validator/test/cli.js
swaggerSpecValidatorMock.expects('validateFile').never();
swaggerSpecValidatorMock.expects('validate').once()
.withArgs(
options.stdin,
expectObj,
match.func,
);
const allArgs = [...RUNTIME_ARGS, ...args];
swaggerSpecValidatorCmd(allArgs, options);
swaggerSpecValidatorMock.verify();
- -H only consumes one argument
- /home/kevin/src/node-projects/swagger-spec-validator/test/cli.js
swaggerSpecValidatorMock.expects('validate').never();
swaggerSpecValidatorMock.expects('validateFile').once()
.withArgs(
'file',
match({
request: match({ headers: { 'Content-Type': 'text/plain' } }),
}),
match.func,
);
const allArgs =
[...RUNTIME_ARGS, '-H', 'Content-Type: text/plain', 'file'];
swaggerSpecValidatorCmd(allArgs, options);
swaggerSpecValidatorMock.verify();
- interprets -qqq as match(verbosity: -3)
- /home/kevin/src/node-projects/swagger-spec-validator/test/cli.js
swaggerSpecValidatorMock.expects('validateFile').never();
swaggerSpecValidatorMock.expects('validate').once()
.withArgs(
options.stdin,
expectObj,
match.func,
);
const allArgs = [...RUNTIME_ARGS, ...args];
swaggerSpecValidatorCmd(allArgs, options);
swaggerSpecValidatorMock.verify();
- interprets -vvv as match(verbosity: 3)
- /home/kevin/src/node-projects/swagger-spec-validator/test/cli.js
swaggerSpecValidatorMock.expects('validateFile').never();
swaggerSpecValidatorMock.expects('validate').once()
.withArgs(
options.stdin,
expectObj,
match.func,
);
const allArgs = [...RUNTIME_ARGS, ...args];
swaggerSpecValidatorCmd(allArgs, options);
swaggerSpecValidatorMock.verify();
- interprets -qvv as match(verbosity: 1)
- /home/kevin/src/node-projects/swagger-spec-validator/test/cli.js
swaggerSpecValidatorMock.expects('validateFile').never();
swaggerSpecValidatorMock.expects('validate').once()
.withArgs(
options.stdin,
expectObj,
match.func,
);
const allArgs = [...RUNTIME_ARGS, ...args];
swaggerSpecValidatorCmd(allArgs, options);
swaggerSpecValidatorMock.verify();
- interprets -u notaurl as match(url: notaurl)
- /home/kevin/src/node-projects/swagger-spec-validator/test/cli.js
swaggerSpecValidatorMock.expects('validateFile').never();
swaggerSpecValidatorMock.expects('validate').once()
.withArgs(
options.stdin,
expectObj,
match.func,
);
const allArgs = [...RUNTIME_ARGS, ...args];
swaggerSpecValidatorCmd(allArgs, options);
swaggerSpecValidatorMock.verify();
- prints error and exits for -H
- /home/kevin/src/node-projects/swagger-spec-validator/test/cli.js
async () => {
swaggerSpecValidatorMock.expects('validate').never();
swaggerSpecValidatorMock.expects('validateFile').never();
const allArgs = [...RUNTIME_ARGS, ...args];
const code = await swaggerSpecValidatorCmd(allArgs, options);
assert.strictEqual(code, expectCode);
if (expectOutMsg instanceof RegExp) {
assertMatch(options.stdout.read(), expectOutMsg);
} else {
assert.strictEqual(options.stdout.read(), expectOutMsg);
}
if (expectErrMsg instanceof RegExp) {
assertMatch(options.stderr.read(), expectErrMsg);
} else {
assert.strictEqual(options.stderr.read(), expectErrMsg);
}
swaggerSpecValidatorMock.verify();
}
- prints error and exits for --header
- /home/kevin/src/node-projects/swagger-spec-validator/test/cli.js
async () => {
swaggerSpecValidatorMock.expects('validate').never();
swaggerSpecValidatorMock.expects('validateFile').never();
const allArgs = [...RUNTIME_ARGS, ...args];
const code = await swaggerSpecValidatorCmd(allArgs, options);
assert.strictEqual(code, expectCode);
if (expectOutMsg instanceof RegExp) {
assertMatch(options.stdout.read(), expectOutMsg);
} else {
assert.strictEqual(options.stdout.read(), expectOutMsg);
}
if (expectErrMsg instanceof RegExp) {
assertMatch(options.stderr.read(), expectErrMsg);
} else {
assert.strictEqual(options.stderr.read(), expectErrMsg);
}
swaggerSpecValidatorMock.verify();
}
- prints error and exits for -H :badarg
- /home/kevin/src/node-projects/swagger-spec-validator/test/cli.js
async () => {
swaggerSpecValidatorMock.expects('validate').never();
swaggerSpecValidatorMock.expects('validateFile').never();
const allArgs = [...RUNTIME_ARGS, ...args];
const code = await swaggerSpecValidatorCmd(allArgs, options);
assert.strictEqual(code, expectCode);
if (expectOutMsg instanceof RegExp) {
assertMatch(options.stdout.read(), expectOutMsg);
} else {
assert.strictEqual(options.stdout.read(), expectOutMsg);
}
if (expectErrMsg instanceof RegExp) {
assertMatch(options.stderr.read(), expectErrMsg);
} else {
assert.strictEqual(options.stderr.read(), expectErrMsg);
}
swaggerSpecValidatorMock.verify();
}
- prints error and exits for -H badarg
- /home/kevin/src/node-projects/swagger-spec-validator/test/cli.js
async () => {
swaggerSpecValidatorMock.expects('validate').never();
swaggerSpecValidatorMock.expects('validateFile').never();
const allArgs = [...RUNTIME_ARGS, ...args];
const code = await swaggerSpecValidatorCmd(allArgs, options);
assert.strictEqual(code, expectCode);
if (expectOutMsg instanceof RegExp) {
assertMatch(options.stdout.read(), expectOutMsg);
} else {
assert.strictEqual(options.stdout.read(), expectOutMsg);
}
if (expectErrMsg instanceof RegExp) {
assertMatch(options.stderr.read(), expectErrMsg);
} else {
assert.strictEqual(options.stderr.read(), expectErrMsg);
}
swaggerSpecValidatorMock.verify();
}
- prints error and exits for -u
- /home/kevin/src/node-projects/swagger-spec-validator/test/cli.js
async () => {
swaggerSpecValidatorMock.expects('validate').never();
swaggerSpecValidatorMock.expects('validateFile').never();
const allArgs = [...RUNTIME_ARGS, ...args];
const code = await swaggerSpecValidatorCmd(allArgs, options);
assert.strictEqual(code, expectCode);
if (expectOutMsg instanceof RegExp) {
assertMatch(options.stdout.read(), expectOutMsg);
} else {
assert.strictEqual(options.stdout.read(), expectOutMsg);
}
if (expectErrMsg instanceof RegExp) {
assertMatch(options.stderr.read(), expectErrMsg);
} else {
assert.strictEqual(options.stderr.read(), expectErrMsg);
}
swaggerSpecValidatorMock.verify();
}
- prints error and exits for --url
- /home/kevin/src/node-projects/swagger-spec-validator/test/cli.js
async () => {
swaggerSpecValidatorMock.expects('validate').never();
swaggerSpecValidatorMock.expects('validateFile').never();
const allArgs = [...RUNTIME_ARGS, ...args];
const code = await swaggerSpecValidatorCmd(allArgs, options);
assert.strictEqual(code, expectCode);
if (expectOutMsg instanceof RegExp) {
assertMatch(options.stdout.read(), expectOutMsg);
} else {
assert.strictEqual(options.stdout.read(), expectOutMsg);
}
if (expectErrMsg instanceof RegExp) {
assertMatch(options.stderr.read(), expectErrMsg);
} else {
assert.strictEqual(options.stderr.read(), expectErrMsg);
}
swaggerSpecValidatorMock.verify();
}
- prints error and exits for --badtestopt
- /home/kevin/src/node-projects/swagger-spec-validator/test/cli.js
async () => {
swaggerSpecValidatorMock.expects('validate').never();
swaggerSpecValidatorMock.expects('validateFile').never();
const allArgs = [...RUNTIME_ARGS, ...args];
const code = await swaggerSpecValidatorCmd(allArgs, options);
assert.strictEqual(code, expectCode);
if (expectOutMsg instanceof RegExp) {
assertMatch(options.stdout.read(), expectOutMsg);
} else {
assert.strictEqual(options.stdout.read(), expectOutMsg);
}
if (expectErrMsg instanceof RegExp) {
assertMatch(options.stderr.read(), expectErrMsg);
} else {
assert.strictEqual(options.stderr.read(), expectErrMsg);
}
swaggerSpecValidatorMock.verify();
}
- prints error and exits for --help
- /home/kevin/src/node-projects/swagger-spec-validator/test/cli.js
async () => {
swaggerSpecValidatorMock.expects('validate').never();
swaggerSpecValidatorMock.expects('validateFile').never();
const allArgs = [...RUNTIME_ARGS, ...args];
const code = await swaggerSpecValidatorCmd(allArgs, options);
assert.strictEqual(code, expectCode);
if (expectOutMsg instanceof RegExp) {
assertMatch(options.stdout.read(), expectOutMsg);
} else {
assert.strictEqual(options.stdout.read(), expectOutMsg);
}
if (expectErrMsg instanceof RegExp) {
assertMatch(options.stderr.read(), expectErrMsg);
} else {
assert.strictEqual(options.stderr.read(), expectErrMsg);
}
swaggerSpecValidatorMock.verify();
}
- prints error and exits for -h
- /home/kevin/src/node-projects/swagger-spec-validator/test/cli.js
async () => {
swaggerSpecValidatorMock.expects('validate').never();
swaggerSpecValidatorMock.expects('validateFile').never();
const allArgs = [...RUNTIME_ARGS, ...args];
const code = await swaggerSpecValidatorCmd(allArgs, options);
assert.strictEqual(code, expectCode);
if (expectOutMsg instanceof RegExp) {
assertMatch(options.stdout.read(), expectOutMsg);
} else {
assert.strictEqual(options.stdout.read(), expectOutMsg);
}
if (expectErrMsg instanceof RegExp) {
assertMatch(options.stderr.read(), expectErrMsg);
} else {
assert.strictEqual(options.stderr.read(), expectErrMsg);
}
swaggerSpecValidatorMock.verify();
}
- prints error and exits for --version
- /home/kevin/src/node-projects/swagger-spec-validator/test/cli.js
async () => {
swaggerSpecValidatorMock.expects('validate').never();
swaggerSpecValidatorMock.expects('validateFile').never();
const allArgs = [...RUNTIME_ARGS, ...args];
const code = await swaggerSpecValidatorCmd(allArgs, options);
assert.strictEqual(code, expectCode);
if (expectOutMsg instanceof RegExp) {
assertMatch(options.stdout.read(), expectOutMsg);
} else {
assert.strictEqual(options.stdout.read(), expectOutMsg);
}
if (expectErrMsg instanceof RegExp) {
assertMatch(options.stderr.read(), expectErrMsg);
} else {
assert.strictEqual(options.stderr.read(), expectErrMsg);
}
swaggerSpecValidatorMock.verify();
}
- prints error and exits for -V
- /home/kevin/src/node-projects/swagger-spec-validator/test/cli.js
async () => {
swaggerSpecValidatorMock.expects('validate').never();
swaggerSpecValidatorMock.expects('validateFile').never();
const allArgs = [...RUNTIME_ARGS, ...args];
const code = await swaggerSpecValidatorCmd(allArgs, options);
assert.strictEqual(code, expectCode);
if (expectOutMsg instanceof RegExp) {
assertMatch(options.stdout.read(), expectOutMsg);
} else {
assert.strictEqual(options.stdout.read(), expectOutMsg);
}
if (expectErrMsg instanceof RegExp) {
assertMatch(options.stderr.read(), expectErrMsg);
} else {
assert.strictEqual(options.stderr.read(), expectErrMsg);
}
swaggerSpecValidatorMock.verify();
}
- normally prints valid message to stderr
- /home/kevin/src/node-projects/swagger-spec-validator/test/cli.js
async () => {
swaggerSpecValidatorMock.expects('validateFile').never();
const validate = swaggerSpecValidatorMock.expects('validate').once()
.withArgs(
options.stdin,
match.object,
match.func,
);
const codeP = swaggerSpecValidatorCmd(RUNTIME_ARGS, options);
validate.yield(null, {});
const code = await codeP;
assert.strictEqual(code, 0);
assert.strictEqual(options.stdout.read(), null);
assertMatch(options.stderr.read(), /valid/i);
}
- -q exits without printing valid
- /home/kevin/src/node-projects/swagger-spec-validator/test/cli.js
async () => {
swaggerSpecValidatorMock.expects('validateFile').never();
const validate = swaggerSpecValidatorMock.expects('validate').once()
.withArgs(
options.stdin,
match.object,
match.func,
);
const allArgs = [...RUNTIME_ARGS, arg];
const codeP = swaggerSpecValidatorCmd(allArgs, options);
validate.yield(null, {});
const code = await codeP;
assert.strictEqual(code, 0);
assert.strictEqual(options.stdout.read(), null);
assert.strictEqual(options.stderr.read(), null);
}
- --quiet exits without printing valid
- /home/kevin/src/node-projects/swagger-spec-validator/test/cli.js
async () => {
swaggerSpecValidatorMock.expects('validateFile').never();
const validate = swaggerSpecValidatorMock.expects('validate').once()
.withArgs(
options.stdin,
match.object,
match.func,
);
const allArgs = [...RUNTIME_ARGS, arg];
const codeP = swaggerSpecValidatorCmd(allArgs, options);
validate.yield(null, {});
const code = await codeP;
assert.strictEqual(code, 0);
assert.strictEqual(options.stdout.read(), null);
assert.strictEqual(options.stderr.read(), null);
}
- normally prints error messages to stderr
- /home/kevin/src/node-projects/swagger-spec-validator/test/cli.js
async () => {
swaggerSpecValidatorMock.expects('validateFile').never();
const validate = swaggerSpecValidatorMock.expects('validate').once()
.withArgs(
options.stdin,
match.object,
match.func,
);
const codeP = swaggerSpecValidatorCmd(RUNTIME_ARGS, options);
validate.yield(new Error('testerr'), {});
const code = await codeP;
assert.strictEqual(code, 2);
assert.strictEqual(options.stdout.read(), null);
assertMatch(options.stderr.read(), /testerr/i);
}
- -v prints error messages with stack to stderr
- /home/kevin/src/node-projects/swagger-spec-validator/test/cli.js
async () => {
swaggerSpecValidatorMock.expects('validateFile').never();
const validate = swaggerSpecValidatorMock.expects('validate').once()
.withArgs(
options.stdin,
match.object,
match.func,
);
const allArgs = [...RUNTIME_ARGS, '-v'];
const codeP = swaggerSpecValidatorCmd(allArgs, options);
validate.yield(new Error('testerr'), {});
const code = await codeP;
assert.strictEqual(code, 2);
assert.strictEqual(options.stdout.read(), null);
const errStr = String(options.stderr.read());
assertMatch(errStr, /testerr/i);
assertMatch(errStr, new RegExp(regexpEscape(__filename)));
}
- normally prints validation messages to stdout
- /home/kevin/src/node-projects/swagger-spec-validator/test/cli.js
async () => {
swaggerSpecValidatorMock.expects('validateFile').never();
const validate = swaggerSpecValidatorMock.expects('validate').once()
.withArgs(
options.stdin,
match.object,
match.func,
);
const codeP = swaggerSpecValidatorCmd(RUNTIME_ARGS, options);
validate.yield(null, {
messages: ['testmsg'],
});
const code = await codeP;
assert.strictEqual(code, 1);
assertMatch(options.stdout.read(), /testmsg/i);
assert.strictEqual(options.stderr.read(), null);
}
- normally prints validation schema messages to stdout
- /home/kevin/src/node-projects/swagger-spec-validator/test/cli.js
async () => {
swaggerSpecValidatorMock.expects('validateFile').never();
const validate = swaggerSpecValidatorMock.expects('validate').once()
.withArgs(
options.stdin,
match.object,
match.func,
);
const codeP = swaggerSpecValidatorCmd(RUNTIME_ARGS, options);
validate.yield(null, {
schemaValidationMessages: [
{ level: 'level', message: 'testmsg' },
],
});
const code = await codeP;
assert.strictEqual(code, 1);
assertMatch(options.stdout.read(), /level.*testmsg/i);
assert.strictEqual(options.stderr.read(), null);
}
- -qq exits without printing error
- /home/kevin/src/node-projects/swagger-spec-validator/test/cli.js
async () => {
swaggerSpecValidatorMock.expects('validateFile').never();
const validate = swaggerSpecValidatorMock.expects('validate').once()
.withArgs(
options.stdin,
match.object,
match.func,
);
const allArgs = [...RUNTIME_ARGS, ...arg];
const codeP = swaggerSpecValidatorCmd(allArgs, options);
validate.yield(new Error('testerr'), {});
const code = await codeP;
assert.strictEqual(code, 2);
assert.strictEqual(options.stdout.read(), null);
assert.strictEqual(options.stderr.read(), null);
}
- -qq exits without printing validation message
- /home/kevin/src/node-projects/swagger-spec-validator/test/cli.js
async () => {
swaggerSpecValidatorMock.expects('validateFile').never();
const validate = swaggerSpecValidatorMock.expects('validate').once()
.withArgs(
options.stdin,
match.object,
match.func,
);
const allArgs = [...RUNTIME_ARGS, ...arg];
const codeP = swaggerSpecValidatorCmd(allArgs, options);
validate.yield(null, {
messages: ['testmsg'],
schemaValidationMessages: [
{ level: 'level', message: 'testmsg' },
],
});
const code = await codeP;
assert.strictEqual(code, 1);
assert.strictEqual(options.stdout.read(), null);
assert.strictEqual(options.stderr.read(), null);
}
- --quiet,--quiet exits without printing error
- /home/kevin/src/node-projects/swagger-spec-validator/test/cli.js
async () => {
swaggerSpecValidatorMock.expects('validateFile').never();
const validate = swaggerSpecValidatorMock.expects('validate').once()
.withArgs(
options.stdin,
match.object,
match.func,
);
const allArgs = [...RUNTIME_ARGS, ...arg];
const codeP = swaggerSpecValidatorCmd(allArgs, options);
validate.yield(new Error('testerr'), {});
const code = await codeP;
assert.strictEqual(code, 2);
assert.strictEqual(options.stdout.read(), null);
assert.strictEqual(options.stderr.read(), null);
}
- --quiet,--quiet exits without printing validation message
- /home/kevin/src/node-projects/swagger-spec-validator/test/cli.js
async () => {
swaggerSpecValidatorMock.expects('validateFile').never();
const validate = swaggerSpecValidatorMock.expects('validate').once()
.withArgs(
options.stdin,
match.object,
match.func,
);
const allArgs = [...RUNTIME_ARGS, ...arg];
const codeP = swaggerSpecValidatorCmd(allArgs, options);
validate.yield(null, {
messages: ['testmsg'],
schemaValidationMessages: [
{ level: 'level', message: 'testmsg' },
],
});
const code = await codeP;
assert.strictEqual(code, 1);
assert.strictEqual(options.stdout.read(), null);
assert.strictEqual(options.stderr.read(), null);
}
- rejects null args with TypeError
- /home/kevin/src/node-projects/swagger-spec-validator/test/cli.js
async () => {
swaggerSpecValidatorMock.expects('validate').never();
swaggerSpecValidatorMock.expects('validateFile').never();
await assert.rejects(
swaggerSpecValidatorCmd(null, options),
TypeError,
);
swaggerSpecValidatorMock.verify();
}
- rejects empty args with TypeError
- /home/kevin/src/node-projects/swagger-spec-validator/test/cli.js
async () => {
swaggerSpecValidatorMock.expects('validate').never();
swaggerSpecValidatorMock.expects('validateFile').never();
await assert.rejects(
swaggerSpecValidatorCmd([], options),
TypeError,
);
swaggerSpecValidatorMock.verify();
}
- rejects non-Array args with TypeError
- /home/kevin/src/node-projects/swagger-spec-validator/test/cli.js
async () => {
swaggerSpecValidatorMock.expects('validate').never();
swaggerSpecValidatorMock.expects('validateFile').never();
await assert.rejects(
swaggerSpecValidatorCmd(true, options),
TypeError,
);
swaggerSpecValidatorMock.verify();
}
- rejects with TypeError for args.length < 2
- /home/kevin/src/node-projects/swagger-spec-validator/test/cli.js
async () => {
swaggerSpecValidatorMock.expects('validate').never();
swaggerSpecValidatorMock.expects('validateFile').never();
await assert.rejects(
swaggerSpecValidatorCmd(['ha'], options),
TypeError,
);
swaggerSpecValidatorMock.verify();
}
- rejects with TypeError without options
- /home/kevin/src/node-projects/swagger-spec-validator/test/cli.js
async () => {
swaggerSpecValidatorMock.expects('validate').never();
swaggerSpecValidatorMock.expects('validateFile').never();
await assert.rejects(
swaggerSpecValidatorCmd(RUNTIME_ARGS),
TypeError,
);
swaggerSpecValidatorMock.verify();
}
- rejects with TypeError for non-object options
- /home/kevin/src/node-projects/swagger-spec-validator/test/cli.js
async () => {
swaggerSpecValidatorMock.expects('validate').never();
swaggerSpecValidatorMock.expects('validateFile').never();
await assert.rejects(
swaggerSpecValidatorCmd(RUNTIME_ARGS, true),
TypeError,
);
swaggerSpecValidatorMock.verify();
}
- returns Error for non-Readable stdin
- /home/kevin/src/node-projects/swagger-spec-validator/test/cli.js
async () => {
swaggerSpecValidatorMock.expects('validate').never();
swaggerSpecValidatorMock.expects('validateFile').never();
await assert.rejects(
swaggerSpecValidatorCmd(RUNTIME_ARGS, { ...options, stdin: {} }),
TypeError,
);
swaggerSpecValidatorMock.verify();
}
- returns Error for non-Writable stdout
- /home/kevin/src/node-projects/swagger-spec-validator/test/cli.js
async () => {
swaggerSpecValidatorMock.expects('validate').never();
swaggerSpecValidatorMock.expects('validateFile').never();
await assert.rejects(
swaggerSpecValidatorCmd(RUNTIME_ARGS, { ...options, stdout: {} }),
TypeError,
);
swaggerSpecValidatorMock.verify();
}
- returns Error for non-Writable stderr
- /home/kevin/src/node-projects/swagger-spec-validator/test/cli.js
async () => {
swaggerSpecValidatorMock.expects('validate').never();
swaggerSpecValidatorMock.expects('validateFile').never();
await assert.rejects(
swaggerSpecValidatorCmd(RUNTIME_ARGS, { ...options, stderr: {} }),
TypeError,
);
swaggerSpecValidatorMock.verify();
}