BigBlueHat commented on a change in pull request #43: Validation test tweaks
URL: https://github.com/apache/incubator-annotator/pull/43#discussion_r225939197
 
 

 ##########
 File path: test/data-model.mjs
 ##########
 @@ -46,12 +39,28 @@ process.argv.forEach((val, index) => {
   }
 });
 
-// load the annotationMusts test list
-const musts = JSON.parse(
-  fs.readFileSync(
-    'node_modules/web-annotation-tests/annotations/annotationMusts.test'
-  )
-);
+function readSchema(schemaPath, base = 'web-annotation-tests/') {
+  const resolverOptions = { extensions: ['.json', '.test'] };
+  const resolvedPath = resolve.sync(`${base}${schemaPath}`, resolverOptions);
+  const schemaUnparsed = fs.readFileSync(resolvedPath);
+  return JSON.parse(schemaUnparsed);
+}
+
+const DEFINITIONS = [
+  'annotations',
+  'bodyTarget',
+  'choiceSet',
+  'collections',
+  'id',
+  'otherProperties',
+  'specificResource',
+].map(name => readSchema(`definitions/${name}`));
 
 Review comment:
   Is persisting the names in the code here better than picking them up from 
the file names? Not opposed to this approach, just not sure what it's solving 
for exactly. 😃 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to