Giter Club home page Giter Club logo

odd-tests's Introduction

ODD Tests

Creates and runs a Mocha ODD test suite by extracting <egXML> elements from an ODD, transforming their contents into full XML documents (based on templates) and validating these documents (usually against the schemata generated from the ODD).

Requirements

node, npm

Installation

npm i odd-tests

ODD

Only <egXML> elements with a @valid attribute value of 'true' or 'false' get included in the tests. Each of the respective <egXML> elements needs to have a @rendition attribute pointing to a <rendition> element in the ODD header. Each <rendition> element needs to contain a descendant <ptr> element providing the path to the template file associated with the rendition in the @target attribute.

This is an excerpt of a TEI header providing the path to a single JSX template:

<encodingDesc>
  <tagsDecl>
    <rendition xml:id="afterStaff" scheme="free">
      <ptr target="../test/jsx/templates/AfterStaff.jsx"/>
    </rendition>
  </tagsDecl>
</encodingDesc>

An example of an <egXML> element referring to that <rendition>:

<egXML xmlns="http://www.tei-c.org/ns/Examples" valid="true" rendition="#afterStaff">
  <slur xml:id="d020" startid="#n01" endid="#n02"/>
</egXML>

A full example of an ODD which can get processed by the ODD Tests package can be found at https://github.com/tido/mei-customization/blob/master/src/tido.xml. See http://www.tei-c.org/release/doc/tei-p5-doc/en/html/ref-egXML.html for general information about the <egXML> element.

Running the tests

The ODD Tests package exposes a single function, run, which triggers the tests. It takes an options object with three mandatory properties:

  • oddPath: string - the path to the ODD file on which the tests are based
  • wrapFragment(templatePath: string, fragment: string): string - a function wrapping the provided fragment using the template at templatePath
  • validate(xmlString: string, schemaSpecName: string): ValidationReport - a function validating the given XML string against the schemata associated with the given <schemaSpec> (schemaSpecName is the value of the @ident attribute of the <schemaSpec> in concern). The returned ValidationReport must be an object with a boolean isValid property and a getErrors() method returning an array of validation errors. The returned validation errors are required to have a toString() method returning the error message to get displayed.

See https://github.com/tido/mei-customization/blob/master/test/run.js for a sample implementation using Preact to process JSX components as templates and the tido-mei-validation package for validation.

odd-tests's People

Watchers

James Cloos avatar Karim Sallam avatar Cyril Silverman avatar Pavan Kataria avatar Zoltan Komives avatar Daniel Wolff avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.