swagger-spec-validator command

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();
  }

swagger-spec-validator

validates JSON and YAML files
/home/kevin/src/node-projects/swagger-spec-validator/test/integration.js
async () => {
    const options = {
      stdin: new stream.PassThrough(),
      stdout: new stream.PassThrough({ encoding: 'utf8' }),
      stderr: new stream.PassThrough({ encoding: 'utf8' }),
    };
    const allArgs = [...RUNTIME_ARGS, swaggerJsonPath, swaggerYamlPath];
    const code = await swaggerSpecValidatorCmd(allArgs, options);
    assertMatch(
      {
        code,
        stdout: options.stdout.read(),
        stderr: options.stderr.read(),
      },
      match({
        code: 0,
        stdout: null,
        stderr: match(/\bvalid/i),
      }),
    );
  }
validates from stdin
/home/kevin/src/node-projects/swagger-spec-validator/test/integration.js
async () => {
    const options = {
      stdin: fs.createReadStream(swaggerYamlPath),
      stdout: new stream.PassThrough({ encoding: 'utf8' }),
      stderr: new stream.PassThrough({ encoding: 'utf8' }),
    };
    const code = await swaggerSpecValidatorCmd(RUNTIME_ARGS, options);
    assertMatch(
      {
        code,
        stdout: options.stdout.read(),
        stderr: options.stderr.read(),
      },
      match({
        code: 0,
        stdout: null,
        stderr: match(/\bvalid/i),
      }),
    );
  }
handles validation failures
/home/kevin/src/node-projects/swagger-spec-validator/test/integration.js
async () => {
    const options = {
      stdin: new stream.PassThrough(),
      stdout: new stream.PassThrough({ encoding: 'utf8' }),
      stderr: new stream.PassThrough({ encoding: 'utf8' }),
    };
    const allArgs = [...RUNTIME_ARGS, invalidYamlPath];
    const code = await swaggerSpecValidatorCmd(allArgs, options);
    assertMatch(
      {
        code,
        stdout: options.stdout.read(),
        stderr: options.stderr.read(),
      },
      match({
        code: 1,
        stdout: match(new RegExp(`^${regexpEscape(invalidYamlPath)}:`)),
        stderr: null,
      }),
    );
  }
handles unreadable file errors
/home/kevin/src/node-projects/swagger-spec-validator/test/integration.js
async () => {
    const options = {
      stdin: new stream.PassThrough(),
      stdout: new stream.PassThrough({ encoding: 'utf8' }),
      stderr: new stream.PassThrough({ encoding: 'utf8' }),
    };
    const nonexistentPath = 'nonexistent.yaml';
    const allArgs = [...RUNTIME_ARGS, nonexistentPath];
    const code = await swaggerSpecValidatorCmd(allArgs, options);
    assertMatch(
      {
        code,
        stdout: options.stdout.read(),
        stderr: options.stderr.read(),
      },
      match({
        code: 2,
        stdout: null,
        stderr: match(new RegExp(
          `^${regexpEscape(nonexistentPath)}:.*\\bENOENT\\b`,
        )),
      }),
    );
  }

swaggerSpecValidator

.validate

POSTs to DEFAULT_URL by default
/home/kevin/src/node-projects/swagger-spec-validator/test/swagger-spec-validator.js
const testBody = 'swagger';
const response = {};
const ne = nock(defaultProtoHost)
  .post(defaultUrlPath, testBody)
  .reply(200, response);
return swaggerSpecValidator.validate(testBody)
  .then((result) => {
    assert.deepStrictEqual(result, response);
    ne.done();
  });
POSTs to string in options.url
/home/kevin/src/node-projects/swagger-spec-validator/test/swagger-spec-validator.js
const testProtoHost = 'http://example.com';
const testPath = '/foo/bar?baz=quux';
const response = {};
const ne = nock(testProtoHost)
  .post(testPath)
  .reply(200, response);
const options = { url: testProtoHost + testPath };
return swaggerSpecValidator.validate('swagger', options)
  .then((result) => {
    assert.deepStrictEqual(result, response);
    ne.done();
  });
POSTs to URL in options.url
/home/kevin/src/node-projects/swagger-spec-validator/test/swagger-spec-validator.js
const testProtoHost = 'http://example.com';
const testPath = '/foo/bar?baz=quux';
const response = {};
const ne = nock(testProtoHost)
  .post(testPath)
  .reply(200, response);
const options = { url: new URL(testProtoHost + testPath) };
return swaggerSpecValidator.validate('swagger', options)
  .then((result) => {
    assert.deepStrictEqual(result, response);
    ne.done();
  });
POSTs to url.parse in options.url
/home/kevin/src/node-projects/swagger-spec-validator/test/swagger-spec-validator.js
const testProtoHost = 'http://example.com';
const testPath = '/foo/bar?baz=quux';
const response = {};
const ne = nock(testProtoHost)
  .post(testPath)
  .reply(200, response);
// eslint-disable-next-line n/no-deprecated-api
const options = { url: url.parse(testProtoHost + testPath) };
return swaggerSpecValidator.validate('swagger', options)
  .then((result) => {
    assert.deepStrictEqual(result, response);
    ne.done();
  });
POSTs to url.parse in request options
/home/kevin/src/node-projects/swagger-spec-validator/test/swagger-spec-validator.js
const testProtoHost = 'http://example.com';
const testPath = '/foo/bar?baz=quux';
const response = {};
const ne = nock(testProtoHost)
  .post(testPath)
  .reply(200, response);
// eslint-disable-next-line n/no-deprecated-api
const options = { request: url.parse(testProtoHost + testPath) };
return swaggerSpecValidator.validate('swagger', options)
  .then((result) => {
    assert.deepStrictEqual(result, response);
    ne.done();
  });
path in request options overrides path in options.url
/home/kevin/src/node-projects/swagger-spec-validator/test/swagger-spec-validator.js
const testProtoHost = 'http://example.com';
const testPath1 = '/foo/bar?baz=quux';
const testPath2 = '/foo2/bar2?baz2=quux2';
const response = {};
const ne = nock(testProtoHost)
  .post(testPath2)
  .reply(200, response);
const options = {
  request: { path: testPath2 },
  url: testProtoHost + testPath1,
};
return swaggerSpecValidator.validate('swagger', options)
  .then((result) => {
    assert.deepStrictEqual(result, response);
    ne.done();
  });
POSTs to URL path in request options with default host
/home/kevin/src/node-projects/swagger-spec-validator/test/swagger-spec-validator.js
const testPath = '/foo/bar?baz=quux';
const response = {};
const ne = nock(defaultProtoHost)
  .post(testPath)
  .reply(200, response);
const options = { request: { path: testPath } };
return swaggerSpecValidator.validate('swagger', options)
  .then((result) => {
    assert.deepStrictEqual(result, response);
    ne.done();
  });
sends Accept: application/json by default
/home/kevin/src/node-projects/swagger-spec-validator/test/swagger-spec-validator.js
const response = {};
const ne = nock(defaultProtoHost)
  .matchHeader('Accept', 'application/json')
  .post(defaultUrlPath)
  .reply(200, response);
return swaggerSpecValidator.validate('swagger')
  .then((result) => {
    assert.deepStrictEqual(result, response);
    ne.done();
  });
sends User-Agent with package version by default
/home/kevin/src/node-projects/swagger-spec-validator/test/swagger-spec-validator.js
const uaRE = new RegExp(
  `^${regexpEscape(`${packageJson.name}/${packageJson.version}`)}`,
);
const response = {};
const ne = nock(defaultProtoHost)
  .matchHeader('User-Agent', uaRE)
  .post(defaultUrlPath)
  .reply(200, response);
return swaggerSpecValidator.validate('swagger')
  .then((result) => {
    assert.deepStrictEqual(result, response);
    ne.done();
  });
can override default headers
/home/kevin/src/node-projects/swagger-spec-validator/test/swagger-spec-validator.js
const uaRE = new RegExp(
  `^${regexpEscape(`${packageJson.name}/${packageJson.version}`)}`,
);
const response = {};
const ne = nock(defaultProtoHost)
  .matchHeader('Accept', 'text/plain')
  .matchHeader('User-Agent', uaRE)
  .post(defaultUrlPath)
  .reply(200, response);
const options = { request: { headers: { Accept: 'text/plain' } } };
return swaggerSpecValidator.validate('swagger', options)
  .then((result) => {
    assert.deepStrictEqual(result, response);
    ne.done();
  });
can override default headers case-insensitively
/home/kevin/src/node-projects/swagger-spec-validator/test/swagger-spec-validator.js
const uaRE = new RegExp(
  `^${regexpEscape(`${packageJson.name}/${packageJson.version}`)}`,
);
const response = {};
const ne = nock(defaultProtoHost)
  .matchHeader('Accept', 'text/plain')
  .matchHeader('User-Agent', uaRE)
  .post(defaultUrlPath)
  .reply(200, response);
const options = { request: { headers: { accept: 'text/plain' } } };
return swaggerSpecValidator.validate('swagger', options)
  .then((result) => {
    assert.deepStrictEqual(result, response);
    ne.done();
  });
returns Error for invalid JSON body
/home/kevin/src/node-projects/swagger-spec-validator/test/swagger-spec-validator.js
const testStatusCode = 200;
const testResponse = '{"bad": "json"';
const testType = 'application/json';
const ne = nock(defaultProtoHost)
  .post(defaultUrlPath)
  .reply(testStatusCode, testResponse, { 'Content-Type': testType });
return swaggerSpecValidator.validate('swagger')
  .then(
    neverCalled,
    (err) => {
      assert.strictEqual(err.statusCode, testStatusCode);
      assert.strictEqual(err.headers['content-type'], testType);
      assert.strictEqual(String(err.body), testResponse);
      ne.done();
    },
  );
returns Error with JSON body for 4XX/5XX response
/home/kevin/src/node-projects/swagger-spec-validator/test/swagger-spec-validator.js
const response = { message: 'test' };
const testStatusCode = 400;
const testType = 'application/json';
const ne = nock(defaultProtoHost)
  .post(defaultUrlPath)
  .reply(testStatusCode, response, { 'Content-Type': testType });
return swaggerSpecValidator.validate('swagger')
  .then(
    neverCalled,
    (err) => {
      assert.strictEqual(err.statusCode, testStatusCode);
      assert.strictEqual(err.headers['content-type'], testType);
      assert.deepStrictEqual(err.body, response);
      ne.done();
    },
  );
returns Error with non-JSON body for 4XX/5XX response
/home/kevin/src/node-projects/swagger-spec-validator/test/swagger-spec-validator.js
const response = 'test message';
const testStatusCode = 500;
const testType = 'text/plain';
const ne = nock(defaultProtoHost)
  .post(defaultUrlPath)
  .reply(testStatusCode, response, { 'Content-Type': testType });
return swaggerSpecValidator.validate('swagger')
  .then(
    neverCalled,
    (err) => {
      assert.strictEqual(err.statusCode, testStatusCode);
      assert.strictEqual(err.headers['content-type'], testType);
      assert.strictEqual(String(err.body), response);
      ne.done();
    },
  );
returns Error for unsupported protocol in request options
/home/kevin/src/node-projects/swagger-spec-validator/test/swagger-spec-validator.js
// eslint-disable-next-line n/no-deprecated-api
const options = { request: url.parse('ftp://example.com') };
return swaggerSpecValidator.validateFile(swaggerJsonPath, options)
  .then(
    neverCalled,
    (err) => {
      assert.ok(/ftp/.test(err.message));
    },
  );
returns validator JSON with errors
/home/kevin/src/node-projects/swagger-spec-validator/test/swagger-spec-validator.js
const testBody = 'swagger';
const response = { messages: ['test1', 'test2'] };
const ne = nock(defaultProtoHost)
  .post(defaultUrlPath, testBody)
  .reply(200, response);
return swaggerSpecValidator.validate(testBody)
  .then((result) => {
    assert.deepStrictEqual(result, response);
    ne.done();
  });
can be called with callback without options
/home/kevin/src/node-projects/swagger-spec-validator/test/swagger-spec-validator.js
const testBody = 'swagger';
const testResponse = {};
const ne = nock(defaultProtoHost)
  .post(defaultUrlPath, testBody)
  .reply(200, testResponse);
swaggerSpecValidator.validate(testBody, (err, result) => {
  assert.ifError(err);
  assert.deepStrictEqual(result, testResponse);
  ne.done();
  done();
});
throws for non-function callback
/home/kevin/src/node-projects/swagger-spec-validator/test/swagger-spec-validator.js
const testBody = 'swagger';
assert.throws(
  () => {
    swaggerSpecValidator.validate(testBody, {}, true);
  },
  TypeError,
  /\bcallback\b/,
);
accepts spec as Buffer
/home/kevin/src/node-projects/swagger-spec-validator/test/swagger-spec-validator.js
const testBody = 'swagger';
const response = {};
const ne = nock(defaultProtoHost)
  .post(defaultUrlPath, testBody)
  .reply(200, response);
return swaggerSpecValidator.validate(Buffer.from(testBody))
  .then((result) => {
    assert.deepStrictEqual(result, response);
    ne.done();
  });
accepts spec as Uint8Array
/home/kevin/src/node-projects/swagger-spec-validator/test/swagger-spec-validator.js
const testBody = 'swagger';
const response = {};
const ne = nock(defaultProtoHost)
  .post(defaultUrlPath, testBody)
  .reply(200, response);
return swaggerSpecValidator.validate(
  new Uint8Array(Buffer.from(testBody)),
)
  .then((result) => {
    assert.deepStrictEqual(result, response);
    ne.done();
  });
Error for non-string, non-Buffer, non-Readable spec
/home/kevin/src/node-projects/swagger-spec-validator/test/swagger-spec-validator.js
return swaggerSpecValidator.validate(true)
  .then(
    neverCalled,
    (err) => {
      assert.ok(err instanceof TypeError);
      assert.ok(/\bspec\b/.test(err.message));
    },
  );
Error for non-object options
/home/kevin/src/node-projects/swagger-spec-validator/test/swagger-spec-validator.js
const testBody = 'swagger';
return swaggerSpecValidator.validate(testBody, true)
  .then(
    neverCalled,
    (err) => {
      assert.ok(err instanceof TypeError);
      assert.ok(/\boptions\b/.test(err.message));
    },
  );
Error for non-Writable options.err
/home/kevin/src/node-projects/swagger-spec-validator/test/swagger-spec-validator.js
const testBody = 'swagger';
const options = { err: new stream.Readable() };
return swaggerSpecValidator.validate(testBody, options)
  .then(
    neverCalled,
    (err) => {
      assert.ok(err instanceof TypeError);
      assert.ok(/\boptions\.err\b/.test(err.message));
    },
  );

.validateFile

POSTs to DEFAULT_URL by default
/home/kevin/src/node-projects/swagger-spec-validator/test/swagger-spec-validator.js
const response = {};
const ne = nock(defaultProtoHost)
  .post(defaultUrlPath)
  .reply(200, response);
return swaggerSpecValidator.validateFile(swaggerJsonPath)
  .then((result) => {
    assert.deepStrictEqual(result, response);
    ne.done();
  });
adds Content-Type: application/json for .json files
/home/kevin/src/node-projects/swagger-spec-validator/test/swagger-spec-validator.js
const response = {};
const ne = nock(defaultProtoHost)
  .matchHeader('Content-Type', 'application/json')
  .post(defaultUrlPath)
  .reply(200, response);
return swaggerSpecValidator.validateFile(swaggerJsonPath)
  .then((result) => {
    assert.deepStrictEqual(result, response);
    ne.done();
  });
adds Content-Type: application/yaml .yaml files
/home/kevin/src/node-projects/swagger-spec-validator/test/swagger-spec-validator.js
const response = {};
const ne = nock(defaultProtoHost)
  .matchHeader('Content-Type', 'application/yaml')
  .post(defaultUrlPath)
  .reply(200, response);
return swaggerSpecValidator.validateFile(swaggerYamlPath)
  .then((result) => {
    assert.deepStrictEqual(result, response);
    ne.done();
  });
adds Content-Type: application/json for non-.json JSON files
/home/kevin/src/node-projects/swagger-spec-validator/test/swagger-spec-validator.js
const response = {};
const ne = nock(defaultProtoHost)
  .matchHeader('Content-Type', 'application/json')
  .post(defaultUrlPath)
  .reply(200, response);
return swaggerSpecValidator.validateFile(swaggerJsonPath.slice(0, -3))
  .then((result) => {
    assert.deepStrictEqual(result, response);
    ne.done();
  });
adds Content-Type: application/yaml for non-.yaml YAML files
/home/kevin/src/node-projects/swagger-spec-validator/test/swagger-spec-validator.js
const response = {};
const ne = nock(defaultProtoHost)
  .matchHeader('Content-Type', 'application/yaml')
  .post(defaultUrlPath)
  .reply(200, response);
return swaggerSpecValidator.validateFile(swaggerYamlPath.slice(0, -3))
  .then((result) => {
    assert.deepStrictEqual(result, response);
    ne.done();
  });
adds Content-Type: application/yaml for non-JSON files
/home/kevin/src/node-projects/swagger-spec-validator/test/swagger-spec-validator.js
const response = {};
const ne = nock(defaultProtoHost)
  .matchHeader('Content-Type', 'application/yaml')
  .post(defaultUrlPath)
  .reply(200, response);
return swaggerSpecValidator.validateFile(emptyPath)
  .then((result) => {
    assert.deepStrictEqual(result, response);
    ne.done();
  });
adds Content-Type: application/json for JSON content
/home/kevin/src/node-projects/swagger-spec-validator/test/swagger-spec-validator.js
const response = {};
const ne = nock(defaultProtoHost)
  .matchHeader('Content-Type', 'application/json')
  .post(defaultUrlPath)
  .reply(200, response);
return swaggerSpecValidator.validate('{}')
  .then((result) => {
    assert.deepStrictEqual(result, response);
    ne.done();
  });
adds Content-Type: application/yaml for non-JSON content
/home/kevin/src/node-projects/swagger-spec-validator/test/swagger-spec-validator.js
const response = {};
const ne = nock(defaultProtoHost)
  .matchHeader('Content-Type', 'application/yaml')
  .post(defaultUrlPath)
  .reply(200, response);
return swaggerSpecValidator.validate('swagger: "2.0"')
  .then((result) => {
    assert.deepStrictEqual(result, response);
    ne.done();
  });
adds Content-Type: application/json for JSON stream
/home/kevin/src/node-projects/swagger-spec-validator/test/swagger-spec-validator.js
const spec = new stream.PassThrough();
spec.end('{}');
const response = {};
const ne = nock(defaultProtoHost)
  .matchHeader('Content-Type', 'application/json')
  .post(defaultUrlPath)
  .reply(200, response);
return swaggerSpecValidator.validate(spec)
  .then((result) => {
    assert.deepStrictEqual(result, response);
    ne.done();
  });
adds Content-Type: application/yaml for non-JSON stream
/home/kevin/src/node-projects/swagger-spec-validator/test/swagger-spec-validator.js
const spec = new stream.PassThrough();
spec.end('swagger: "2.0"');
const response = {};
const ne = nock(defaultProtoHost)
  .matchHeader('Content-Type', 'application/yaml')
  .post(defaultUrlPath)
  .reply(200, response);
return swaggerSpecValidator.validate(spec)
  .then((result) => {
    assert.deepStrictEqual(result, response);
    ne.done();
  });
does not change caller-provided Content-Type
/home/kevin/src/node-projects/swagger-spec-validator/test/swagger-spec-validator.js
const response = {};
const testType = 'text/plain';
const ne = nock(defaultProtoHost)
  .matchHeader('Content-Type', testType)
  .post(defaultUrlPath)
  .reply(200, response);
const options = { request: { headers: { 'content-type': testType } } };
return swaggerSpecValidator.validateFile(swaggerYamlPath, options)
  .then((result) => {
    assert.deepStrictEqual(result, response);
    ne.done();
  });
can be called with callback without options
/home/kevin/src/node-projects/swagger-spec-validator/test/swagger-spec-validator.js
const response = {};
const ne = nock(defaultProtoHost)
  .post(defaultUrlPath)
  .reply(200, response);
swaggerSpecValidator.validateFile(swaggerYamlPath, (err, result) => {
  assert.ifError(err);
  assert.deepStrictEqual(result, response);
  ne.done();
  done();
});
returns Error for unreadable file
/home/kevin/src/node-projects/swagger-spec-validator/test/swagger-spec-validator.js
const testStatusCode = 200;
const testResponse = {};
const ne = nock(defaultProtoHost)
  .post(defaultUrlPath)
  .optionally()
  .reply(testStatusCode, testResponse);
return swaggerSpecValidator.validateFile('nonexistent.yaml')
  .then(
    neverCalled,
    (err) => {
      assert.strictEqual(err.code, 'ENOENT');
      ne.done();
    },
  );