Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

transformer tests could use a helper #46

Open
boneskull opened this issue Aug 7, 2019 · 0 comments
Open

transformer tests could use a helper #46

boneskull opened this issue Aug 7, 2019 · 0 comments
Labels
chore Related to tests, packaging, build, releases, etc. package-transformers Involving transformers package

Comments

@boneskull
Copy link
Contributor

boneskull commented Aug 7, 2019

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.
@boneskull boneskull added chore Related to tests, packaging, build, releases, etc. package-transformers Involving transformers package labels Aug 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
chore Related to tests, packaging, build, releases, etc. package-transformers Involving transformers package
Projects
None yet
Development

No branches or pull requests

1 participant