@@ -186,6 +188,9 @@ export const PROCESS_POPOVER_ATTRIBUTES_NO_OVERRIDE_EXPECTED = `
`;
+export const PROCESS_POPOVER_ATTRIBUTES_NO_OVERRIDE_HEADER_WARN_MSG = "popover has a header slot, 'header' attribute has no effect.";
+export const PROCESS_POPOVER_ATTRIBUTES_NO_OVERRIDE_CONTENT_WARN_MSG = "popover has a content slot, 'content' attribute has no effect.";
+
/*
* Tooltips
*/
@@ -317,4 +322,6 @@ export const PROCESS_DROPDOWN_HEADER_SLOT_TAKES_PRIORITY_EXPECTED = `
`;
+export const PROCESS_DROPDOWN_HEADER_SLOT_TAKES_PRIORITY_WARN_MSG = "dropdown has a header slot, 'header' attribute has no effect.";
+
/* eslint-enable max-len */
diff --git a/packages/core/test/unit/html/NodeProcessor.test.ts b/packages/core/test/unit/html/NodeProcessor.test.ts
index 371d1069f7..32f6d270fe 100644
--- a/packages/core/test/unit/html/NodeProcessor.test.ts
+++ b/packages/core/test/unit/html/NodeProcessor.test.ts
@@ -2,11 +2,20 @@ import path from 'path';
import cheerio from 'cheerio';
import htmlparser from 'htmlparser2';
import * as testData from './NodeProcessor.data';
+import * as logger from '../../../src/utils/logger';
import { Context } from '../../../src/html/Context';
import { shiftSlotNodeDeeper, transformOldSlotSyntax } from '../../../src/html/vueSlotSyntaxProcessor';
import { getNewDefaultNodeProcessor } from '../utils/utils';
import { MbNode, parseHTML } from '../../../src/utils/node';
+jest.mock('../../../src/utils/logger', () => ({
+ warn: jest.fn(),
+}));
+
+beforeEach(() => {
+ jest.clearAllMocks();
+});
+
/**
* Runs the processNode or postProcessNode method of NodeProcessor on the provided
* template, verifying it with the expected result.
@@ -42,12 +51,15 @@ const processAndVerifyTemplate = (template: string, expectedTemplate: string, po
};
test('processNode processes panel attributes and inserts into dom as slots correctly', () => {
+ const warnSpy = jest.spyOn(logger, 'warn');
processAndVerifyTemplate(testData.PROCESS_PANEL_ATTRIBUTES,
testData.PROCESS_PANEL_ATTRIBUTES_EXPECTED);
processAndVerifyTemplate(testData.PROCESS_PANEL_HEADER_SLOT_TAKES_PRIORITY,
testData.PROCESS_PANEL_HEADER_SLOT_TAKES_PRIORITY_EXPECTED);
+ expect(warnSpy).toHaveBeenCalledWith(testData.PROCESS_PANEL_HEADER_SLOT_TAKES_PRIORITY_WARN_MSG);
processAndVerifyTemplate(testData.PROCESS_PANEL_HEADER_NO_OVERRIDE,
testData.PROCESS_PANEL_HEADER_NO_OVERRIDE_EXPECTED);
+ expect(warnSpy).toHaveBeenCalledWith(testData.PROCESS_PANEL_HEADER_SLOT_TAKES_PRIORITY_WARN_MSG);
});
test('processNode processes question attributes and inserts into dom as slots correctly', () => {
@@ -72,10 +84,13 @@ test('processNode processes quiz attributes and inserts into dom as slots correc
});
test('processNode processes popover attributes and inserts into dom as slots correctly', () => {
+ const warnSpy = jest.spyOn(logger, 'warn');
processAndVerifyTemplate(testData.PROCESS_POPOVER_ATTRIBUTES,
testData.PROCESS_POPOVER_ATTRIBUTES_EXPECTED);
processAndVerifyTemplate(testData.PROCESS_POPOVER_ATTRIBUTES_NO_OVERRIDE,
testData.PROCESS_POPOVER_ATTRIBUTES_NO_OVERRIDE_EXPECTED);
+ expect(warnSpy).toHaveBeenCalledWith(testData.PROCESS_POPOVER_ATTRIBUTES_NO_OVERRIDE_HEADER_WARN_MSG);
+ expect(warnSpy).toHaveBeenCalledWith(testData.PROCESS_POPOVER_ATTRIBUTES_NO_OVERRIDE_CONTENT_WARN_MSG);
});
test('processNode processes tooltip attributes and inserts into dom as slots correctly', () => {
@@ -118,8 +133,10 @@ test('processNode processes dropdown header attribute and inserts into DOM as he
});
test('processNode processes dropdown with header slot taking priority over header attribute', () => {
+ const warnSpy = jest.spyOn(logger, 'warn');
processAndVerifyTemplate(testData.PROCESS_DROPDOWN_HEADER_SLOT_TAKES_PRIORITY,
testData.PROCESS_DROPDOWN_HEADER_SLOT_TAKES_PRIORITY_EXPECTED);
+ expect(warnSpy).toHaveBeenCalledWith(testData.PROCESS_DROPDOWN_HEADER_SLOT_TAKES_PRIORITY_WARN_MSG);
});
test('markdown coverts inline colour syntax correctly', async () => {