@@ -5,36 +5,47 @@ import errorStackParserMock from './errorStackParserMock'
5
5
import framesStub from './framesStub.json'
6
6
import framesStubAbsoluteFilenames from './framesStubAbsoluteFilenames.json'
7
7
import framesStubMissingFilename from './framesStubMissingFilename.json'
8
- import RedBox from '../src'
8
+ import RedBox , { RedBoxError , __RewireAPI__ } from '../src'
9
9
import style from '../src/style'
10
10
import './lib' ;
11
11
12
12
13
13
const beforeEach = ( framesStub ) => {
14
- RedBox . __Rewire__ ( 'ErrorStackParser' , errorStackParserMock ( framesStub ) )
14
+ __RewireAPI__ . __Rewire__ ( 'ErrorStackParser' , errorStackParserMock ( framesStub ) )
15
15
}
16
16
17
17
const afterEach = ( ) => {
18
- RedBox . __ResetDependency__ ( 'ErrorStackParser' )
18
+ __RewireAPI__ . __ResetDependency__ ( 'ErrorStackParser' )
19
19
}
20
20
21
+ // RedBox tests
21
22
test ( 'RedBox static displayName' , t => {
22
23
t . plan ( 1 )
23
- beforeEach ( framesStub )
24
24
t . equal (
25
25
RedBox . displayName ,
26
26
'RedBox' ,
27
- 'correct static displayName property on class'
27
+ 'correct static displayName property on class RedBox'
28
+ )
29
+ } )
30
+
31
+ // TODO: add missing new tests for RedBox "portal" component
32
+
33
+ // RedBoxError tests
34
+ test ( 'RedBoxError static displayName' , t => {
35
+ t . plan ( 1 )
36
+ t . equal (
37
+ RedBoxError . displayName ,
38
+ 'RedBoxError' ,
39
+ 'correct static displayName property on class RedBoxError'
28
40
)
29
- afterEach ( )
30
41
} )
31
42
32
- test ( 'RedBox error message' , t => {
43
+ test ( 'RedBoxError error message' , t => {
33
44
t . plan ( 3 )
34
45
beforeEach ( framesStub )
35
46
const ERR_MESSAGE = 'funny error name'
36
47
const error = new Error ( ERR_MESSAGE )
37
- const component = createComponent ( RedBox , { error} )
48
+ const component = createComponent ( RedBoxError , { error} )
38
49
// renderedError = div.redbox > div.message > *
39
50
const renderedError = component
40
51
. props . children [ 0 ]
@@ -57,11 +68,11 @@ test('RedBox error message', t => {
57
68
afterEach ( )
58
69
} )
59
70
60
- test ( 'RedBox stack trace' , t => {
71
+ test ( 'RedBoxError stack trace' , t => {
61
72
t . plan ( 1 )
62
73
beforeEach ( framesStub )
63
74
const error = new Error ( )
64
- const component = createComponent ( RedBox , { error} )
75
+ const component = createComponent ( RedBoxError , { error} )
65
76
66
77
const renderedStack = component
67
78
. props . children [ 1 ]
@@ -87,12 +98,12 @@ test('RedBox stack trace', t => {
87
98
afterEach ( )
88
99
} )
89
100
90
- test ( 'RedBox with filename from react-transform-catch-errors' , t => {
101
+ test ( 'RedBoxError with filename from react-transform-catch-errors' , t => {
91
102
t . plan ( 1 )
92
103
beforeEach ( framesStub )
93
104
const error = new Error ( )
94
105
const filename = 'some-optional-webpack-loader!/filename'
95
- const component = createComponent ( RedBox , { error, filename} )
106
+ const component = createComponent ( RedBoxError , { error, filename} )
96
107
97
108
const renderedStack = component
98
109
. props . children [ 1 ]
@@ -117,13 +128,13 @@ test('RedBox with filename from react-transform-catch-errors', t => {
117
128
afterEach ( )
118
129
} )
119
130
120
- test ( 'RedBox with filename and editorScheme' , t => {
131
+ test ( 'RedBoxError with filename and editorScheme' , t => {
121
132
t . plan ( 1 )
122
133
beforeEach ( framesStub )
123
134
const error = new Error ( )
124
135
const filename = 'some-optional-webpack-loader!/filename'
125
136
const editorScheme = 'subl'
126
- const component = createComponent ( RedBox , { error, filename, editorScheme} )
137
+ const component = createComponent ( RedBoxError , { error, filename, editorScheme} )
127
138
128
139
const renderedStack = component
129
140
. props . children [ 1 ]
@@ -148,13 +159,13 @@ test('RedBox with filename and editorScheme', t => {
148
159
afterEach ( )
149
160
} )
150
161
151
- test ( 'RedBox with absolute filenames' , t => {
162
+ test ( 'RedBoxError with absolute filenames' , t => {
152
163
t . plan ( 1 )
153
164
beforeEach ( framesStubAbsoluteFilenames )
154
165
const error = new Error ( )
155
166
const filename = 'some-optional-webpack-loader!/filename'
156
167
const editorScheme = 'subl'
157
- const component = createComponent ( RedBox , { error, filename, editorScheme} )
168
+ const component = createComponent ( RedBoxError , { error, filename, editorScheme} )
158
169
159
170
const renderedStack = component
160
171
. props . children [ 1 ]
@@ -179,14 +190,14 @@ test('RedBox with absolute filenames', t => {
179
190
afterEach ( )
180
191
} )
181
192
182
- test ( 'RedBox with absolute filenames but unreliable line numbers' , t => {
193
+ test ( 'RedBoxError with absolute filenames but unreliable line numbers' , t => {
183
194
t . plan ( 1 )
184
195
beforeEach ( framesStubAbsoluteFilenames )
185
196
const error = new Error ( )
186
197
const filename = 'some-optional-webpack-loader!/filename'
187
198
const editorScheme = 'subl'
188
199
const useLines = false
189
- const component = createComponent ( RedBox , { error, filename, editorScheme, useLines} )
200
+ const component = createComponent ( RedBoxError , { error, filename, editorScheme, useLines} )
190
201
191
202
const renderedStack = component
192
203
. props . children [ 1 ]
@@ -211,14 +222,14 @@ test('RedBox with absolute filenames but unreliable line numbers', t => {
211
222
afterEach ( )
212
223
} )
213
224
214
- test ( 'RedBox with absolute filenames but unreliable column numbers' , t => {
225
+ test ( 'RedBoxError with absolute filenames but unreliable column numbers' , t => {
215
226
t . plan ( 1 )
216
227
beforeEach ( framesStubAbsoluteFilenames )
217
228
const error = new Error ( )
218
229
const filename = 'some-optional-webpack-loader!/filename'
219
230
const editorScheme = 'subl'
220
231
const useColumns = false
221
- const component = createComponent ( RedBox , { error, filename, editorScheme, useColumns} )
232
+ const component = createComponent ( RedBoxError , { error, filename, editorScheme, useColumns} )
222
233
223
234
const renderedStack = component
224
235
. props . children [ 1 ]
@@ -243,11 +254,11 @@ test('RedBox with absolute filenames but unreliable column numbers', t => {
243
254
afterEach ( )
244
255
} )
245
256
246
- test ( 'RedBox stack trace with missing filename' , t => {
257
+ test ( 'RedBoxError stack trace with missing filename' , t => {
247
258
t . plan ( 1 )
248
259
beforeEach ( framesStubMissingFilename )
249
260
const error = new Error ( )
250
- const component = createComponent ( RedBox , { error} )
261
+ const component = createComponent ( RedBoxError , { error} )
251
262
252
263
const renderedStack = component
253
264
. props . children [ 1 ]
@@ -273,9 +284,9 @@ test('RedBox stack trace with missing filename', t => {
273
284
afterEach ( )
274
285
} )
275
286
276
- test ( 'RedBox with throwing stack trace parser' , t => {
287
+ test ( 'RedBoxError with throwing stack trace parser' , t => {
277
288
t . plan ( 3 )
278
- RedBox . __Rewire__ ( 'ErrorStackParser' , {
289
+ __RewireAPI__ . __Rewire__ ( 'ErrorStackParser' , {
279
290
parse : function ( ) {
280
291
// This mimicks the former behavior of stacktracejs,
281
292
// see https://github.com/stacktracejs/stackframe/issues/11.
@@ -284,7 +295,7 @@ test('RedBox with throwing stack trace parser', t => {
284
295
} )
285
296
const ERR_MESSAGE = "original error message"
286
297
const error = new TypeError ( ERR_MESSAGE )
287
- const component = createComponent ( RedBox , { error} )
298
+ const component = createComponent ( RedBoxError , { error} )
288
299
289
300
const renderedError = component
290
301
. props . children [ 0 ]
0 commit comments