function test(filename, glossary) {
  return new Promise(function(resolve, reject) {
    const results = [];
    let validator = new JSONValidator();
    validator.addSchema(SCHEMA_GLOSSARY_ITEM, SCHEMA_GLOSSARY_ITEM.id);
    validator.addSchema(SCHEMA_GLOSSARY_LINK, SCHEMA_GLOSSARY_LINK.id);
    validator.validate(glossary, SCHEMA_GLOSSARY).errors.forEach((err) => {
      let msg = `${err.stack || err.message}`;
      msg = msg.replace('{}', '(' + err.instance + ')');
      const result = {
        level: 'ERROR',
        filename: filename,
        message: msg,
      };
      results.push(result);
    });
    let prevTermName = '';
    glossary.forEach((term) => {
      const termName = term.term.toLowerCase();
      if (prevTermName > termName) {
        const result = {
          level: 'ERROR',
          filename: filename,
          message: `'${prevTermName}' came before '${termName}'`,
        };
        results.push(result);
      }
      prevTermName = termName;
    });
    if (results.length > 0) {
      reject(results);
      return;
    }
    resolve(true);
  });
}
Tests and validates a glossary.yaml file.
  Note: The returned promise always resolves, it will never reject.

@param {string} filename The name of the file to be tested.
@param {Object} glossary The parsed contents of the glossary file.
@return {Promise} A promise with the result of the test.