@@ -2,11 +2,20 @@ import path from 'path';
22import cheerio from 'cheerio' ;
33import htmlparser from 'htmlparser2' ;
44import * as testData from './NodeProcessor.data' ;
5+ import * as logger from '../../../src/utils/logger' ;
56import { Context } from '../../../src/html/Context' ;
67import { shiftSlotNodeDeeper , transformOldSlotSyntax } from '../../../src/html/vueSlotSyntaxProcessor' ;
78import { getNewDefaultNodeProcessor } from '../utils/utils' ;
89import { MbNode , parseHTML } from '../../../src/utils/node' ;
910
11+ jest . mock ( '../../../src/utils/logger' , ( ) => ( {
12+ warn : jest . fn ( ) ,
13+ } ) ) ;
14+
15+ beforeEach ( ( ) => {
16+ jest . clearAllMocks ( ) ;
17+ } ) ;
18+
1019/**
1120 * Runs the processNode or postProcessNode method of NodeProcessor on the provided
1221 * template, verifying it with the expected result.
@@ -42,12 +51,15 @@ const processAndVerifyTemplate = (template: string, expectedTemplate: string, po
4251} ;
4352
4453test ( 'processNode processes panel attributes and inserts into dom as slots correctly' , ( ) => {
54+ const warnSpy = jest . spyOn ( logger , 'warn' ) ;
4555 processAndVerifyTemplate ( testData . PROCESS_PANEL_ATTRIBUTES ,
4656 testData . PROCESS_PANEL_ATTRIBUTES_EXPECTED ) ;
4757 processAndVerifyTemplate ( testData . PROCESS_PANEL_HEADER_SLOT_TAKES_PRIORITY ,
4858 testData . PROCESS_PANEL_HEADER_SLOT_TAKES_PRIORITY_EXPECTED ) ;
59+ expect ( warnSpy ) . toHaveBeenCalledWith ( testData . PROCESS_PANEL_HEADER_SLOT_TAKES_PRIORITY_WARN_MSG ) ;
4960 processAndVerifyTemplate ( testData . PROCESS_PANEL_HEADER_NO_OVERRIDE ,
5061 testData . PROCESS_PANEL_HEADER_NO_OVERRIDE_EXPECTED ) ;
62+ expect ( warnSpy ) . toHaveBeenCalledWith ( testData . PROCESS_PANEL_HEADER_SLOT_TAKES_PRIORITY_WARN_MSG ) ;
5163} ) ;
5264
5365test ( 'processNode processes question attributes and inserts into dom as slots correctly' , ( ) => {
@@ -65,17 +77,20 @@ test('processNode processes q-option attributes and inserts into dom as slots co
6577} ) ;
6678
6779test ( 'processNode processes quiz attributes and inserts into dom as slots correctly' , ( ) => {
68- processAndVerifyTemplate ( testData . PROCESS_QUIZ_ATTRIBUTES_EXPECTED ,
80+ processAndVerifyTemplate ( testData . PROCESS_QUIZ_ATTRIBUTES ,
6981 testData . PROCESS_QUIZ_ATTRIBUTES_EXPECTED ) ;
7082 processAndVerifyTemplate ( testData . PROCESS_QUIZ_ATTRIBUTES_NO_OVERRIDE ,
7183 testData . PROCESS_QUIZ_ATTRIBUTES_NO_OVERRIDE_EXPECTED ) ;
7284} ) ;
7385
7486test ( 'processNode processes popover attributes and inserts into dom as slots correctly' , ( ) => {
87+ const warnSpy = jest . spyOn ( logger , 'warn' ) ;
7588 processAndVerifyTemplate ( testData . PROCESS_POPOVER_ATTRIBUTES ,
7689 testData . PROCESS_POPOVER_ATTRIBUTES_EXPECTED ) ;
7790 processAndVerifyTemplate ( testData . PROCESS_POPOVER_ATTRIBUTES_NO_OVERRIDE ,
7891 testData . PROCESS_POPOVER_ATTRIBUTES_NO_OVERRIDE_EXPECTED ) ;
92+ expect ( warnSpy ) . toHaveBeenCalledWith ( testData . PROCESS_POPOVER_ATTRIBUTES_NO_OVERRIDE_HEADER_WARN_MSG ) ;
93+ expect ( warnSpy ) . toHaveBeenCalledWith ( testData . PROCESS_POPOVER_ATTRIBUTES_NO_OVERRIDE_CONTENT_WARN_MSG ) ;
7994} ) ;
8095
8196test ( '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
118133} ) ;
119134
120135test ( 'processNode processes dropdown with header slot taking priority over header attribute' , ( ) => {
136+ const warnSpy = jest . spyOn ( logger , 'warn' ) ;
121137 processAndVerifyTemplate ( testData . PROCESS_DROPDOWN_HEADER_SLOT_TAKES_PRIORITY ,
122138 testData . PROCESS_DROPDOWN_HEADER_SLOT_TAKES_PRIORITY_EXPECTED ) ;
139+ expect ( warnSpy ) . toHaveBeenCalledWith ( testData . PROCESS_DROPDOWN_HEADER_SLOT_TAKES_PRIORITY_WARN_MSG ) ;
123140} ) ;
124141
125142test ( 'markdown coverts inline colour syntax correctly' , async ( ) => {
0 commit comments