MarkBind / markbind

MarkBind is a tool for generating content-heavy websites from source files in Markdown format
https://markbind.org/
MIT License
135 stars 124 forks source link

Add more unit tests for core package #2106

Open raysonkoh opened 1 year ago

raysonkoh commented 1 year ago

Please confirm that you have searched existing issues in the repo

Yes, I have searched the existing issues

Any related issues?

No response

What is the area that this feature belongs to?

Testing

Is your feature request related to a problem? Please describe.

Currently, there are not a lot of unit tests for the various components / functions in the core package. This can definitely be improved. This issue may be blocked by #1913, but it may be possible to write some unit tests for those files that have migrated to typescript.

As some components are highly coupled (e.g. External depends on ExternalManager and ExternalManger depends on External), this may require some refactoring work. For certain components that depend on some other components, we could look into either writing a test stub or mocking it (https://jestjs.io/docs/mock-functions).

This can be done concurrently with #1755.

Also related: #1495 .

Describe the solution you'd like

Let's try to get some basic tests up. Once #1755 is complete, we can then add more tests as needed to increase the coverage. To keep the size of the PRs small and manageable to review, I think it would be good to write tests for components that are logically related to each other (such as those files that are in the same folder).

Describe alternatives you've considered

No response

Additional context

No response

raysonkoh commented 1 year ago

Also, it would be good to start enforcing immutable objects since there are quite a few places where a function is executed for its side-effects, such as mutating a DomElement node.

lhw-1 commented 1 year ago

This issue can be extended to the cli package as well - testing for the serve command is highlighted in #2266.