@@ -29,8 +29,7 @@ import React from 'react';
29
29
30
30
export default class MyComponent extends React.Component {
31
31
/* eslint no-empty-function: 0, class-methods-use-this: 0 */
32
- ${ body }
33
- }
32
+ ${ body } }
34
33
` ;
35
34
}
36
35
@@ -44,25 +43,24 @@ test('validate react prop order', (t) => {
44
43
t . test ( 'passes a good component' , ( t ) => {
45
44
t . plan ( 3 ) ;
46
45
const result = lint ( wrapComponent ( `
47
- componentWillMount() {}
48
46
componentDidMount() {}
49
47
setFoo() {}
50
48
getFoo() {}
51
49
setBar() {}
52
50
someMethod() {}
53
51
renderDogs() {}
54
- render() { return <div />; }` ) ) ;
52
+ render() { return <div />; }
53
+ ` ) ) ;
55
54
56
55
t . notOk ( result . warningCount , 'no warnings' ) ;
57
- t . notOk ( result . errorCount , 'no errors' ) ;
58
56
t . deepEquals ( result . messages , [ ] , 'no messages in results' ) ;
57
+ t . notOk ( result . errorCount , 'no errors' ) ;
59
58
} ) ;
60
59
61
60
t . test ( 'order: when random method is first' , ( t ) => {
62
61
t . plan ( 2 ) ;
63
62
const result = lint ( wrapComponent ( `
64
63
someMethod() {}
65
- componentWillMount() {}
66
64
componentDidMount() {}
67
65
setFoo() {}
68
66
getFoo() {}
@@ -72,13 +70,12 @@ test('validate react prop order', (t) => {
72
70
` ) ) ;
73
71
74
72
t . ok ( result . errorCount , 'fails' ) ;
75
- t . equal ( result . messages [ 0 ] . ruleId , 'react/sort-comp' , 'fails due to sort' ) ;
73
+ t . deepEqual ( result . messages . map ( x => x . ruleId ) , [ 'react/sort-comp' ] , 'fails due to sort' ) ;
76
74
} ) ;
77
75
78
76
t . test ( 'order: when random method after lifecycle methods' , ( t ) => {
79
77
t . plan ( 2 ) ;
80
78
const result = lint ( wrapComponent ( `
81
- componentWillMount() {}
82
79
componentDidMount() {}
83
80
someMethod() {}
84
81
setFoo() {}
@@ -89,6 +86,6 @@ test('validate react prop order', (t) => {
89
86
` ) ) ;
90
87
91
88
t . ok ( result . errorCount , 'fails' ) ;
92
- t . equal ( result . messages [ 0 ] . ruleId , 'react/sort-comp' , 'fails due to sort' ) ;
89
+ t . deepEqual ( result . messages . map ( x => x . ruleId ) , [ 'react/sort-comp' ] , 'fails due to sort' ) ;
93
90
} ) ;
94
91
} ) ;
0 commit comments