Skip to content

Commit d4f2f1a

Browse files
committed
chore: Add JSDoc comments
1 parent b15f8a3 commit d4f2f1a

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

packages/test-case-component/src/generateHtml.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@ export async function generateHtml(data: DataFixture) {
1616

1717
const highlighter = createHighlighter();
1818

19+
/**
20+
* Closure-based HTML generator for test case data.
21+
*
22+
* @param {DataFixture} data - The state object containing the necessary data for HTML generation.
23+
* @returns {Object} An object with generate, generateAll, and getDecorations async functions.
24+
*/
1925
function createHtmlGenerator(data: DataFixture) {
2026
const lang = data.languageId as BundledLanguage;
2127
const command = data.command;
@@ -42,6 +48,12 @@ function createHtmlGenerator(data: DataFixture) {
4248
after: data.finalState
4349
};
4450

51+
/**
52+
* Generates HTML for a specific test case step (before, during, after).
53+
*
54+
* @param {StepNameType} stepName - The step to generate HTML for.
55+
* @returns {Promise<{ html: string; data: any[] } | string>} The generated HTML and decoration data, or an error string.
56+
*/
4557
async function generate(stepName: StepNameType) {
4658
const state = testCaseStates[stepName];
4759
if (!state) {
@@ -98,6 +110,11 @@ function createHtmlGenerator(data: DataFixture) {
98110
return { html: htmlArray.join(""), data: [decorations] };
99111
}
100112

113+
/**
114+
* Generates HTML for all test case steps (before, during, after).
115+
*
116+
* @returns {Promise<{ before: any; during: any; after: any }>} The generated HTML and decoration data for each step.
117+
*/
101118
async function generateAll() {
102119
return {
103120
before: await generate("before"),
@@ -106,6 +123,12 @@ function createHtmlGenerator(data: DataFixture) {
106123
};
107124
}
108125

126+
/**
127+
* Computes code decorations for a given test case state.
128+
*
129+
* @param {ExtendedTestCaseSnapshot} testCaseState - The test case state to decorate.
130+
* @returns {Promise<Decoration[]>} The computed decorations for the state.
131+
*/
109132
async function getDecorations(testCaseState: ExtendedTestCaseSnapshot) {
110133
const { messages, flashes, highlights, finalStateMarkHelpers } = testCaseState;
111134
const potentialMarks = testCaseState.marks || {};

0 commit comments

Comments
 (0)