How to use the @xviz/schema.getXVIZProtoTypes function in @xviz/schema

To help you get started, we’ve selected a few @xviz/schema examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github uber / xviz / test / modules / schema / proto-validation.spec.js View on Github external
test('protosCorrect', t => {
  const protoRoot = loadProtos();

  // Test a basic primitive out
  const examplesDir = path.join(getModuleDir(), 'examples');

  const validator = new XVIZValidator();

  // For each protobuf type
  const protoTypes = getXVIZProtoTypes(protoRoot);
  t.ok(protoTypes.length > 5, 'Have protos connected to schemas');

  const protoEnumTypes = getProtoEnumTypes(protoRoot);
  t.ok(Object.keys(protoEnumTypes).length > 5, 'Found enum types');

  const tests = [];

  for (let i = 0; i < protoTypes.length; i++) {
    const type = protoTypes[i];

    const schemaName = type.options[EXTENSION_PROPERTY];
    t.comment(schemaName);

    // Make sure we have a matching JSON schema
    t.ok(validator.hasSchema(schemaName), `"${schemaName}" is a real schema`);