@@ -47,6 +47,7 @@ describe('console', () => {
47
47
patchConsole ( {
48
48
appendComponentStack : true ,
49
49
breakOnWarn : false ,
50
+ showInlineWarningsAndErrors : false ,
50
51
} ) ;
51
52
52
53
const inject = global . __REACT_DEVTOOLS_GLOBAL_HOOK__ . inject ;
@@ -79,12 +80,61 @@ describe('console', () => {
79
80
expect ( fakeConsole . warn ) . not . toBe ( mockWarn ) ;
80
81
} ) ;
81
82
83
+ it ( 'should patch the console when appendComponentStack is enabled' , ( ) => {
84
+ unpatchConsole ( ) ;
85
+
86
+ expect ( fakeConsole . error ) . toBe ( mockError ) ;
87
+ expect ( fakeConsole . warn ) . toBe ( mockWarn ) ;
88
+
89
+ patchConsole ( {
90
+ appendComponentStack : true ,
91
+ breakOnWarn : false ,
92
+ showInlineWarningsAndErrors : false ,
93
+ } ) ;
94
+
95
+ expect ( fakeConsole . error ) . not . toBe ( mockError ) ;
96
+ expect ( fakeConsole . warn ) . not . toBe ( mockWarn ) ;
97
+ } ) ;
98
+
99
+ it ( 'should patch the console when breakOnWarn is enabled' , ( ) => {
100
+ unpatchConsole ( ) ;
101
+
102
+ expect ( fakeConsole . error ) . toBe ( mockError ) ;
103
+ expect ( fakeConsole . warn ) . toBe ( mockWarn ) ;
104
+
105
+ patchConsole ( {
106
+ appendComponentStack : false ,
107
+ breakOnWarn : true ,
108
+ showInlineWarningsAndErrors : false ,
109
+ } ) ;
110
+
111
+ expect ( fakeConsole . error ) . not . toBe ( mockError ) ;
112
+ expect ( fakeConsole . warn ) . not . toBe ( mockWarn ) ;
113
+ } ) ;
114
+
115
+ it ( 'should patch the console when showInlineWarningsAndErrors is enabled' , ( ) => {
116
+ unpatchConsole ( ) ;
117
+
118
+ expect ( fakeConsole . error ) . toBe ( mockError ) ;
119
+ expect ( fakeConsole . warn ) . toBe ( mockWarn ) ;
120
+
121
+ patchConsole ( {
122
+ appendComponentStack : false ,
123
+ breakOnWarn : false ,
124
+ showInlineWarningsAndErrors : true ,
125
+ } ) ;
126
+
127
+ expect ( fakeConsole . error ) . not . toBe ( mockError ) ;
128
+ expect ( fakeConsole . warn ) . not . toBe ( mockWarn ) ;
129
+ } ) ;
130
+
82
131
it ( 'should only patch the console once' , ( ) => {
83
132
const { error, warn} = fakeConsole ;
84
133
85
134
patchConsole ( {
86
135
appendComponentStack : true ,
87
136
breakOnWarn : false ,
137
+ showInlineWarningsAndErrors : false ,
88
138
} ) ;
89
139
90
140
expect ( fakeConsole . error ) . toBe ( error ) ;
@@ -339,6 +389,7 @@ describe('console', () => {
339
389
patchConsole ( {
340
390
appendComponentStack : true ,
341
391
breakOnWarn : false ,
392
+ showInlineWarningsAndErrors : false ,
342
393
} ) ;
343
394
act ( ( ) => ReactDOM . render ( < Child /> , document . createElement ( 'div' ) ) ) ;
344
395
0 commit comments