MarkBind / markbind

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

Add tests for logger output when component attributes are overridden by slots #2525

Closed luminousleek closed 2 months ago

luminousleek commented 2 months ago

What is the purpose of this pull request?

Fixes #2476

Overview of changes:

Anything you'd like to highlight/discuss:

Inconsistent Test Inputs across Components

For some components, the test inputs test for all attributes at once to see if they are being checked properly, e.g.

export const PROCESS_PANEL_ATTRIBUTES = `
<panel header="# Lorem ipsum" alt="_emphasized alt_">
  Header and alt attributes should be processed and inserted under panel as slots and internal slots respectively and deleted.
</panel>
`;

export const PROCESS_PANEL_ATTRIBUTES_EXPECTED = `
<panel><template #header><h1>Lorem ipsum</h1>
</template><template #_alt><p><em>emphasized alt</em></p>
</template>
  Header and alt attributes should be processed and inserted under panel as slots and internal slots respectively and deleted.
</panel>
`;

where both the header and alt attributes are tested at the same time. However, for other components e.g. box, these are tested one at a time:

export const PROCESS_BOX_ICON = `
<box icon=":rocket:">
  Icon attribute should be inserted as icon slot and deleted.
</box>
`;

export const PROCESS_BOX_ICON_EXPECTED = `
<box><template #icon>🚀</template>
  Icon attribute should be inserted as icon slot and deleted.
</box>
`;

export const PROCESS_BOX_HEADER = `
<box header="#### Lorem ipsum dolor sit amet :rocket:">
  Header attribute should be inserted as header slot and deleted.
</box>
`;

export const PROCESS_BOX_HEADER_EXPECTED = `
<box><template #header><h4>Lorem ipsum dolor sit amet 🚀</h4>
</template>
  Header attribute should be inserted as header slot and deleted.
</box>
`;

Do let me know which one you prefer and I will refactor accordingly. Personally I don't see a real need to separate the attributes for the tests.

Other things

Documentation for which attributes are able to be overridden will be done in a separate PR.

Lastly, sorry for the long PR :(

Testing instructions:

Proposed commit message: (wrap lines at 72 characters)

Add tests for logger output when overriding attributes

Currently only certain components are tested for logger warnings when their attributes are overridden by slots.

Let's add tests for the remaining attributes and components, as well as add missing tests for the components which do not currently have tests.


Checklist: :ballot_box_with_check:


Reviewer checklist:

Indicate the SEMVER impact of the PR:

At the end of the review, please label the PR with the appropriate label: r.Major, r.Minor, r.Patch.

Breaking change release note preparation (if applicable):

Give a brief explanation note about:

  • what was the old feature that was made obsolete
  • any replacement feature (if any), and
  • how the author should modify his website to migrate from the old feature to the replacement feature (if possible).