@@ -34,54 +34,100 @@ describe('reactCssModules', () => {
3434 } ) ;
3535 } ) ;
3636 context ( 'a ReactComponent renders an element with the styleName prop' , ( ) => {
37- it ( 'that element should contain the equivalent className' , ( ) => {
38- let Foo ,
39- component ,
40- shallowRenderer ;
37+ context ( 'the component is a class that extends React.Component' , ( ) => {
38+ it ( 'that element should contain the equivalent className' , ( ) => {
39+ let Foo ,
40+ component ,
41+ shallowRenderer ;
4142
42- shallowRenderer = TestUtils . createRenderer ( ) ;
43+ shallowRenderer = TestUtils . createRenderer ( ) ;
4344
44- Foo = class extends React . Component {
45- render ( ) {
46- return < div styleName = 'foo' > Hello</ div > ;
47- }
48- } ;
45+ Foo = class extends React . Component {
46+ render ( ) {
47+ return < div styleName = 'foo' > Hello</ div > ;
48+ }
49+ } ;
50+
51+ Foo = reactCssModules ( Foo , {
52+ foo : 'foo-1'
53+ } ) ;
54+
55+ shallowRenderer . render ( < Foo /> ) ;
56+
57+ component = shallowRenderer . getRenderOutput ( ) ;
4958
50- Foo = reactCssModules ( Foo , {
51- foo : 'foo-1'
59+ expect ( component . props . className ) . to . equal ( 'foo-1' ) ;
5260 } ) ;
61+ } ) ;
62+ context ( 'the component is a stateless function component' , ( ) => {
63+ it ( 'that element should contain the equivalent className' , ( ) => {
64+ let Foo ,
65+ component ,
66+ shallowRenderer ;
67+
68+ shallowRenderer = TestUtils . createRenderer ( ) ;
69+
70+ Foo = ( ) => < div styleName = 'foo' > Hello</ div > ;
5371
54- shallowRenderer . render ( < Foo /> ) ;
72+ Foo = reactCssModules ( Foo , {
73+ foo : 'foo-1'
74+ } ) ;
5575
56- component = shallowRenderer . getRenderOutput ( ) ;
76+ shallowRenderer . render ( < Foo /> ) ;
5777
58- expect ( component . props . className ) . to . equal ( 'foo-1' ) ;
78+ component = shallowRenderer . getRenderOutput ( ) ;
79+
80+ expect ( component . props . className ) . to . equal ( 'foo-1' ) ;
81+ } ) ;
5982 } ) ;
6083 } ) ;
6184
6285 context ( 'a ReactComponent renders nothing' , ( ) => {
63- it ( 'linkClass must not intervene' , ( ) => {
64- let Foo ,
65- component ,
66- shallowRenderer ;
86+ context ( 'the component is a class that extends React.Component' , ( ) => {
87+ it ( 'linkClass must not intervene' , ( ) => {
88+ let Foo ,
89+ component ,
90+ shallowRenderer ;
6791
68- shallowRenderer = TestUtils . createRenderer ( ) ;
92+ shallowRenderer = TestUtils . createRenderer ( ) ;
6993
70- Foo = class extends React . Component {
71- render ( ) {
72- return null ;
73- }
74- } ;
94+ Foo = class extends React . Component {
95+ render ( ) {
96+ return null ;
97+ }
98+ } ;
99+
100+ Foo = reactCssModules ( Foo , {
101+ foo : 'foo-1'
102+ } ) ;
103+
104+ shallowRenderer . render ( < Foo /> ) ;
105+
106+ component = shallowRenderer . getRenderOutput ( ) ;
75107
76- Foo = reactCssModules ( Foo , {
77- foo : 'foo-1'
108+ expect ( typeof component ) . to . equal ( 'object' ) ;
78109 } ) ;
110+ } ) ;
111+ context ( 'the component is a stateless function component' , ( ) => {
112+ it ( 'that element should contain the equivalent className' , ( ) => {
113+ let Foo ,
114+ component ,
115+ shallowRenderer ;
116+
117+ shallowRenderer = TestUtils . createRenderer ( ) ;
118+
119+ Foo = ( ) => null ;
79120
80- shallowRenderer . render ( < Foo /> ) ;
121+ Foo = reactCssModules ( Foo , {
122+ foo : 'foo-1'
123+ } ) ;
81124
82- component = shallowRenderer . getRenderOutput ( ) ;
125+ shallowRenderer . render ( < Foo /> ) ;
83126
84- expect ( typeof component ) . to . equal ( 'object' ) ;
127+ component = shallowRenderer . getRenderOutput ( ) ;
128+
129+ expect ( typeof component ) . to . equal ( 'object' ) ;
130+ } ) ;
85131 } ) ;
86132 } ) ;
87133} ) ;
0 commit comments