@@ -2,11 +2,20 @@ import path from 'path';
2
2
import cheerio from 'cheerio' ;
3
3
import htmlparser from 'htmlparser2' ;
4
4
import * as testData from './NodeProcessor.data' ;
5
+ import * as logger from '../../../src/utils/logger' ;
5
6
import { Context } from '../../../src/html/Context' ;
6
7
import { shiftSlotNodeDeeper , transformOldSlotSyntax } from '../../../src/html/vueSlotSyntaxProcessor' ;
7
8
import { getNewDefaultNodeProcessor } from '../utils/utils' ;
8
9
import { MbNode , parseHTML } from '../../../src/utils/node' ;
9
10
11
+ jest . mock ( '../../../src/utils/logger' , ( ) => ( {
12
+ warn : jest . fn ( ) ,
13
+ } ) ) ;
14
+
15
+ beforeEach ( ( ) => {
16
+ jest . clearAllMocks ( ) ;
17
+ } ) ;
18
+
10
19
/**
11
20
* Runs the processNode or postProcessNode method of NodeProcessor on the provided
12
21
* template, verifying it with the expected result.
@@ -42,12 +51,15 @@ const processAndVerifyTemplate = (template: string, expectedTemplate: string, po
42
51
} ;
43
52
44
53
test ( 'processNode processes panel attributes and inserts into dom as slots correctly' , ( ) => {
54
+ const warnSpy = jest . spyOn ( logger , 'warn' ) ;
45
55
processAndVerifyTemplate ( testData . PROCESS_PANEL_ATTRIBUTES ,
46
56
testData . PROCESS_PANEL_ATTRIBUTES_EXPECTED ) ;
47
57
processAndVerifyTemplate ( testData . PROCESS_PANEL_HEADER_SLOT_TAKES_PRIORITY ,
48
58
testData . PROCESS_PANEL_HEADER_SLOT_TAKES_PRIORITY_EXPECTED ) ;
59
+ expect ( warnSpy ) . toHaveBeenCalledWith ( testData . PROCESS_PANEL_HEADER_SLOT_TAKES_PRIORITY_WARN_MSG ) ;
49
60
processAndVerifyTemplate ( testData . PROCESS_PANEL_HEADER_NO_OVERRIDE ,
50
61
testData . PROCESS_PANEL_HEADER_NO_OVERRIDE_EXPECTED ) ;
62
+ expect ( warnSpy ) . toHaveBeenCalledWith ( testData . PROCESS_PANEL_HEADER_SLOT_TAKES_PRIORITY_WARN_MSG ) ;
51
63
} ) ;
52
64
53
65
test ( '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
65
77
} ) ;
66
78
67
79
test ( 'processNode processes quiz attributes and inserts into dom as slots correctly' , ( ) => {
68
- processAndVerifyTemplate ( testData . PROCESS_QUIZ_ATTRIBUTES_EXPECTED ,
80
+ processAndVerifyTemplate ( testData . PROCESS_QUIZ_ATTRIBUTES ,
69
81
testData . PROCESS_QUIZ_ATTRIBUTES_EXPECTED ) ;
70
82
processAndVerifyTemplate ( testData . PROCESS_QUIZ_ATTRIBUTES_NO_OVERRIDE ,
71
83
testData . PROCESS_QUIZ_ATTRIBUTES_NO_OVERRIDE_EXPECTED ) ;
72
84
} ) ;
73
85
74
86
test ( 'processNode processes popover attributes and inserts into dom as slots correctly' , ( ) => {
87
+ const warnSpy = jest . spyOn ( logger , 'warn' ) ;
75
88
processAndVerifyTemplate ( testData . PROCESS_POPOVER_ATTRIBUTES ,
76
89
testData . PROCESS_POPOVER_ATTRIBUTES_EXPECTED ) ;
77
90
processAndVerifyTemplate ( testData . PROCESS_POPOVER_ATTRIBUTES_NO_OVERRIDE ,
78
91
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 ) ;
79
94
} ) ;
80
95
81
96
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
118
133
} ) ;
119
134
120
135
test ( 'processNode processes dropdown with header slot taking priority over header attribute' , ( ) => {
136
+ const warnSpy = jest . spyOn ( logger , 'warn' ) ;
121
137
processAndVerifyTemplate ( testData . PROCESS_DROPDOWN_HEADER_SLOT_TAKES_PRIORITY ,
122
138
testData . PROCESS_DROPDOWN_HEADER_SLOT_TAKES_PRIORITY_EXPECTED ) ;
139
+ expect ( warnSpy ) . toHaveBeenCalledWith ( testData . PROCESS_DROPDOWN_HEADER_SLOT_TAKES_PRIORITY_WARN_MSG ) ;
123
140
} ) ;
124
141
125
142
test ( 'markdown coverts inline colour syntax correctly' , async ( ) => {
0 commit comments