@@ -23,8 +23,13 @@ const expectedError = {
23
23
type : 'JSXOpeningElement' ,
24
24
} ;
25
25
26
+ const components = [ {
27
+ components : [ 'Heading' , 'Title' ] ,
28
+ } ] ;
29
+
26
30
ruleTester . run ( 'heading-has-content' , rule , {
27
31
valid : [
32
+ // DEFAULT ELEMENT TESTS
28
33
{ code : '<div />;' } ,
29
34
{ code : '<h1>Foo</h1>' } ,
30
35
{ code : '<h2>Foo</h2>' } ,
@@ -38,10 +43,25 @@ ruleTester.run('heading-has-content', rule, {
38
43
{ code : '<h1>{foo.bar}</h1>' } ,
39
44
{ code : '<h1 dangerouslySetInnerHTML={{ __html: "foo" }} />' } ,
40
45
{ code : '<h1 children={children} />' } ,
46
+
47
+ // CUSTOM ELEMENT TESTS FOR COMPONENTS OPTION
48
+ { code : '<Heading>Foo</Heading>' , options : components } ,
49
+ { code : '<Title>Foo</Title>' , options : components } ,
50
+ { code : '<Heading><Bar /></Heading>' , options : components } ,
51
+ { code : '<Heading>{foo}</Heading>' , options : components } ,
52
+ { code : '<Heading>{foo.bar}</Heading>' , options : components } ,
53
+ { code : '<Heading dangerouslySetInnerHTML={{ __html: "foo" }} />' , options : components } ,
54
+ { code : '<Heading children={children} />' , options : components } ,
41
55
] . map ( parserOptionsMapper ) ,
42
56
invalid : [
57
+ // DEFAULT ELEMENT TESTS
43
58
{ code : '<h1 />' , errors : [ expectedError ] } ,
44
59
{ code : '<h1><Bar aria-hidden /></h1>' , errors : [ expectedError ] } ,
45
60
{ code : '<h1>{undefined}</h1>' , errors : [ expectedError ] } ,
61
+
62
+ // CUSTOM ELEMENT TESTS FOR COMPONENTS OPTION
63
+ { code : '<Heading />' , errors : [ expectedError ] , options : components } ,
64
+ { code : '<Heading><Bar aria-hidden /></Heading>' , errors : [ expectedError ] , options : components } ,
65
+ { code : '<Heading>{undefined}</Heading>' , errors : [ expectedError ] , options : components } ,
46
66
] . map ( parserOptionsMapper ) ,
47
67
} ) ;
0 commit comments