IBM / report-toolkit

A toolkit for consumers of Node.js diagnostic Reports
https://ibm.github.io/report-toolkit
Other
84 stars 10 forks source link

transformer tests could use a helper #46

Open boneskull opened 5 years ago

boneskull commented 5 years ago

These are unit tests, but the transform function that each exports is only ever called by the Transformer class, which applies any default options defined within a transformer. Calling these functions directly does not apply those defaults.

The reasoning behind defining defaults in the meta object is threefold:

  1. We can merge any custom options deeply within them, which would otherwise be boilerplate in each transform function
  2. Defaults can (in the future) and should be applied via schema validation (ajv). If the merging of options happened within the transform function itself, this would not be possible.
  3. When two transformers are chained together, the next transformer pulls in defaults from the previous one. This allows a chain of something like diff -> table to have its output defined by the diff transformer--the table transformer does not and cannot know how to display this data.