1
1
import React from 'react' ;
2
- import renderer from 'react-test-renderer' ;
3
2
import { Buffer } from 'safe-buffer' ;
4
- import HelloMessage from './HelloMessage'
5
3
import test from '../../' ;
4
+ import HelloMessage from './hello-message' ;
6
5
7
6
// Older AVA versions that do not use Concordance don't handle globals very
8
7
// well. Use this so formatting output can be contrasted between versions.
9
- const formatGlobals = ! ! require ( process . env . AVA_PATH + '/package.json' ) . dependencies . concordance
8
+ const formatGlobals = Boolean ( require ( process . env . AVA_PATH + '/package.json' ) . dependencies . concordance ) ;
10
9
11
10
test ( 'date formatted' , t => {
12
11
const date = new Date ( '1969-07-20T20:17:40.000Z' ) ;
@@ -39,23 +38,23 @@ test('error formatted, constructor does not match name', t => {
39
38
t . true ( err ) ;
40
39
} ) ;
41
40
test ( 'error formatted, constructor does not match name, and string tag does not match constructor' , t => {
42
- class Custom extends Error {
41
+ class CustomError extends Error {
43
42
constructor ( message ) {
44
43
super ( message ) ;
45
- this . name = 'FamousWords' ;
44
+ this . name = 'FamousWords' ; // eslint-disable-line unicorn/custom-error-definition
46
45
}
47
46
}
48
- const err = new Custom ( 'Houston, we have a problem' ) ;
47
+ const err = new CustomError ( 'Houston, we have a problem' ) ;
49
48
t . true ( err ) ;
50
49
} ) ;
51
50
test ( 'error formatted, no name or constructor' , t => {
52
- class Custom extends Error {
51
+ class CustomError extends Error {
53
52
constructor ( message ) {
54
53
super ( message ) ;
55
- this . name = '' ;
54
+ this . name = '' ; // eslint-disable-line unicorn/custom-error-definition
56
55
}
57
56
}
58
- const err = new Custom ( 'Houston, we have a problem' ) ;
57
+ const err = new CustomError ( 'Houston, we have a problem' ) ;
59
58
Object . defineProperty ( err , 'constructor' , { } ) ;
60
59
t . true ( err ) ;
61
60
} ) ;
@@ -70,7 +69,7 @@ test('error diff, extra properties', t => {
70
69
date : new Date ( '1969-07-20T20:17:40.000Z' )
71
70
} ) ) ;
72
71
} ) ;
73
- test ( 'error thrown in test' , t => {
72
+ test ( 'error thrown in test' , ( ) => {
74
73
throw Object . assign ( new Error ( 'Houston, we have a problem' ) , {
75
74
date : new Date ( '1969-07-20T20:17:40.000Z' )
76
75
} ) ;
@@ -88,7 +87,7 @@ test('error thrown in test due to improper throws', t => {
88
87
} ;
89
88
t . throws ( improper ( ) ) ;
90
89
} ) ;
91
- test ( 'test returned rejected promise' , t => {
90
+ test ( 'test returned rejected promise' , ( ) => {
92
91
return Promise . reject ( Object . assign ( new Error ( 'Houston, we have a problem' ) , {
93
92
date : new Date ( '1969-07-20T20:17:40.000Z' )
94
93
} ) ) ;
@@ -130,7 +129,7 @@ test('map diff, extra properties', t => {
130
129
} ) ;
131
130
132
131
test ( 'function formatted' , t => {
133
- const fn = function foo ( ) { } ;
132
+ const fn = function foo ( ) { } ; // eslint-disable-line func-name-matching, func-names
134
133
t . true ( fn ) ;
135
134
} ) ;
136
135
test ( 'function diff' , t => {
@@ -147,7 +146,7 @@ test('anonymous function', t => {
147
146
t . true ( ( ) => { } ) ;
148
147
} ) ;
149
148
test ( 'generator function' , t => {
150
- t . true ( function * foo ( ) { } ) ;
149
+ t . true ( function * foo ( ) { } ) ; // eslint-disable-line func-names
151
150
} ) ;
152
151
153
152
test ( 'arguments formatted' , t => {
@@ -289,25 +288,25 @@ test('circular references', t => {
289
288
} ) ;
290
289
291
290
test ( 'react element, formatted' , t => {
292
- const element = React . createElement ( HelloMessage , { name : 'Sindre' } )
293
- t . true ( element )
294
- } )
291
+ const element = React . createElement ( HelloMessage , { name : 'Sindre' } ) ;
292
+ t . true ( element ) ;
293
+ } ) ;
295
294
test ( 'react element, complex attributes, formatted' , t => {
296
295
const element = React . createElement ( 'div' , {
297
296
multiline : 'Hello\nworld' ,
298
297
object : { foo : [ 'bar' ] }
299
- } )
300
- t . true ( element )
301
- } )
298
+ } ) ;
299
+ t . true ( element ) ;
300
+ } ) ;
302
301
test ( 'react element, opaque children, formatted' , t => {
303
- const element = React . createElement ( 'Foo' , null , new Set ( [ 'foo' ] ) , true )
304
- t . true ( element )
305
- } )
302
+ const element = React . createElement ( 'Foo' , null , new Set ( [ 'foo' ] ) , true ) ;
303
+ t . true ( element ) ;
304
+ } ) ;
306
305
test ( 'react element, diff' , t => {
307
- const element = React . createElement ( HelloMessage , { name : 'Sindre' } )
308
- const other = React . createElement ( HelloMessage , { name : 'Vadim' } )
309
- t . deepEqual ( element , other )
310
- } )
306
+ const element = React . createElement ( HelloMessage , { name : 'Sindre' } ) ;
307
+ const other = React . createElement ( HelloMessage , { name : 'Vadim' } ) ;
308
+ t . deepEqual ( element , other ) ;
309
+ } ) ;
311
310
312
311
test ( 'deep structure, formatted' , t => {
313
312
const deep = {
@@ -318,9 +317,9 @@ test('deep structure, formatted', t => {
318
317
}
319
318
}
320
319
}
321
- }
322
- t . true ( deep )
323
- } )
320
+ } ;
321
+ t . true ( deep ) ;
322
+ } ) ;
324
323
test ( 'deep structure, diff' , t => {
325
324
const deep = {
326
325
foo : {
@@ -330,6 +329,6 @@ test('deep structure, diff', t => {
330
329
}
331
330
}
332
331
}
333
- }
334
- t . deepEqual ( deep , Object . assign ( { corge : 'grault' } , deep ) )
335
- } )
332
+ } ;
333
+ t . deepEqual ( deep , Object . assign ( { corge : 'grault' } , deep ) ) ;
334
+ } ) ;
0 commit comments