|
3 | 3 | handleKeywords, |
4 | 4 | handleDynamicContent, |
5 | 5 | handleChoiceOptions, |
| 6 | + handleRegularContent, |
6 | 7 | } from "../../../../../../app/js/core/chatbot/parsers/helpers/processorsChatbotContent.mjs"; |
7 | 8 | import { config } from "../../../../../../app/js/config.mjs"; |
8 | 9 |
|
@@ -170,7 +171,7 @@ describe("handleKeywords", () => { |
170 | 171 | }); |
171 | 172 | }); |
172 | 173 |
|
173 | | -fdescribe("handleDynamicContent", () => { |
| 174 | +describe("handleDynamicContent", () => { |
174 | 175 | it("returns false if dynamicContent is not enabled in yaml", () => { |
175 | 176 | const line = "`if @userIsLoggedIn==true`"; |
176 | 177 | const currentData = {}; |
@@ -311,3 +312,48 @@ describe("handleChoiceOptions", () => { |
311 | 312 | expect(currentData.choiceOptions[0].link).toBe("section 1 link"); |
312 | 313 | }); |
313 | 314 | }); |
| 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