bebraw
How to abstract tests to allow running different functions against the same test suite?
I've set up two suites of tests like this: https://github.com/gustwindjs/gustwind/tree/develop/htmlisp/html-tests, https://github.com/gustwindjs/gustwind/tree/develop/htmlisp/html-tests-sync . They are effectively the same but one is for async code and one for sync. Due to how the language works, technically it should be possible to use the async test suite for testing the sync code since
await
just wraps sync result within a Promise
. The question is, what would be a sane way to extract the shared tests and then inject the functions so I could end up with a single test suite against both async and sync functions?5 replies
Parsing HTML/XML
Lately I've been researching how to write a simple HTML/XML -> JSON converter. My syntax isn't completely standard HTML (i.e.,
<Button>
is possible) which makes this a notch harder than it probably should be. Here's an example of how things should work: https://github.com/gustwindjs/gustwind/blob/feat/html-prototype/html-to-breezewind/tests/element_test.ts .
The current implementation relies on https://deno.land/x/deno_dom but the problem is that it's losing information for tagName
. I cannot use it to tell a button
apart from a Button
as it's uppercasing the tag by default.
As an alternative, I looked into https://deno.land/x/xml but it's losing structural information due to its automatic grouping (i.e., it folds div
s within a single array and loses their relative positioning so I cannot map the structure later on to match the original).
Any insight on the issue would be valuable. Maybe I have to fork either to add the missing functionality but I hope to avoid that.4 replies