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

Add tests #3

Open
mercmobily opened this issue Feb 1, 2020 · 2 comments
Open

Add tests #3

mercmobily opened this issue Feb 1, 2020 · 2 comments
Assignees

Comments

@mercmobily
Copy link
Contributor

Documentation really rocks. However, we have zero tests.
I am not 100% sure how to approach tests here, especially since the output depends on templates.
But, it would be good to have some tests. Or, to at least have the infrastructure in place for them.

@mercmobily mercmobily changed the title Add testing Add tests Feb 1, 2020
@Sebring
Copy link
Contributor

Sebring commented Feb 8, 2021

I'm about to docco.marko markojs-files. They're similar to a .vue-file in that they contain not only js but also html(concise) and css. Hence I need split the file into three parts before running docco.documentOne on each part (also applying specific language for each). The real no-go for me was that .documentOne reads from file. First thing I did was to read the file in it's own function and then feed documentOne with an array of lines instead.

This small refactor (and here's my point) would also make it easier to test the exported functions. For given config and input (array of lines) you can expect a given output. Same is true of course for a given file, but it makes testing more cumbersome.

especially since the output depends on templates.

This is only interesting if you are testing the actual templates, otherwise you should test up to generation of the data for the templates and stop there. I haven't quite gotten that far yet in the docco-code but again it is probably a matter of splitting up a function (makeHtmlBlob?) to at least three steps like pseudo: generateTemplateInput -> runTemplate(input) -> templateOutput. And it's probably reasonably for any non-template tests to stop at validating the return of generateTemplateInput.

Sorry for writing so chatty, I should sleep now =p

TL/DR
Test only given input + given config === given output on each exported function. And some refactoring might be required for this to make sense.

@mercmobily
Copy link
Contributor Author

All good and thanks for the feedback. We are VERY open to suggestions, requests, PRs, etc. I am having a bit of grief trying to figure out what we should do here though :D

Can you please open a new ticket with specifics? The more pragmatic, the better!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants