Skip to content

Commit 7802181

Browse files
committed
test(core): ajout de tests pour handleRegularContent()
1 parent c003e92 commit 7802181

1 file changed

Lines changed: 47 additions & 1 deletion

File tree

tests/unit/core/chatbot/parsers/helpers/processorsChatbotContent.spec.mjs

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import {
33
handleKeywords,
44
handleDynamicContent,
55
handleChoiceOptions,
6+
handleRegularContent,
67
} from "../../../../../../app/js/core/chatbot/parsers/helpers/processorsChatbotContent.mjs";
78
import { config } from "../../../../../../app/js/config.mjs";
89

@@ -170,7 +171,7 @@ describe("handleKeywords", () => {
170171
});
171172
});
172173

173-
fdescribe("handleDynamicContent", () => {
174+
describe("handleDynamicContent", () => {
174175
it("returns false if dynamicContent is not enabled in yaml", () => {
175176
const line = "`if @userIsLoggedIn==true`";
176177
const currentData = {};
@@ -311,3 +312,48 @@ describe("handleChoiceOptions", () => {
311312
expect(currentData.choiceOptions[0].link).toBe("section 1 link");
312313
});
313314
});
315+
316+
describe("handleRegularContent", () => {
317+
it("adds regular content line to currentData.content", () => {
318+
const line = "This is a regular content line.";
319+
const yaml = { responsesTitles: ["## "] };
320+
const currentData = { content: [] };
321+
322+
handleRegularContent(line, yaml, currentData);
323+
324+
expect(currentData.content).toEqual([line]);
325+
expect(currentData.listParsed).toBe(true);
326+
});
327+
328+
it("converts internal links to anchor tags", () => {
329+
const line = "Click [here](#section-1) for more info.";
330+
const yaml = { responsesTitles: ["## "] };
331+
const currentData = { content: [] };
332+
333+
handleRegularContent(line, yaml, currentData);
334+
335+
expect(currentData.content).toEqual([
336+
'Click <a href="#section-1">here</a> for more info.',
337+
]);
338+
expect(currentData.listParsed).toBe(true);
339+
});
340+
341+
it("does not add structure titles to content", () => {
342+
const line = "# This is a structure title";
343+
const yaml = { responsesTitles: ["## "] };
344+
const currentData = { content: [] };
345+
346+
handleRegularContent(line, yaml, currentData);
347+
348+
expect(currentData.content).toEqual([]);
349+
});
350+
it("does not add custom structure titles to content", () => {
351+
const line = "## This is a structure title";
352+
const yaml = { responsesTitles: ["### "] };
353+
const currentData = { content: [] };
354+
355+
handleRegularContent(line, yaml, currentData);
356+
357+
expect(currentData.content).toEqual([]);
358+
});
359+
});

0 commit comments

Comments
 (0)