Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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`);
// Validate every example
const exampleFiles = EXAMPLES.examples
.filter(
enum PackageEnum {
fail = 0;
cpp = 1;
}
message TestPackage {
PackageEnum foo = 1;
uint32 other = 2;
}
`;
const TEST_PROTO_ROOT = parse(TEST_PROTO_IDL).root;
const TEST_PROTO_TYPE = TEST_PROTO_ROOT.lookupType('Test');
const ENUM_TYPES = getProtoEnumTypes(TEST_PROTO_ROOT);
test('getProtoEnumTypes', t => {
const exp = {};
exp['.PackageEnum'] = {
fail: 0,
cpp: 1
};
exp['.Test.Enum'] = {
zip: 0,
zap: 1,
sog: 2
};
t.deepEquals(exp, ENUM_TYPES, 'Can lookup enum types');
t.end();